-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: HBSearch 5 - FieldBridge add document with custom analyzer
PostPosted: Fri Oct 17, 2014 7:14 am 
Beginner
Beginner

Joined: Wed Aug 06, 2014 10:53 am
Posts: 30
I'm indexing using my custom fieldbridge to enable the facet engine of the lucene 4.
In order to correctly add the SortedSetDocValue type documents, I need to obtain my custom analyzers. So is there any way to obtain the SearchFactory obejct?

I would like reach the SearchFactory object for calling the getAnalyzer method.


Top
 Profile  
 
 Post subject: Re: HBSearch 5 - FieldBridge add document with custom analyzer
PostPosted: Fri Oct 17, 2014 10:36 am 
Beginner
Beginner

Joined: Wed Aug 06, 2014 10:53 am
Posts: 30
I solved my problem.
I created a singleton for the my CustomAnalyzer object. I get the value for the document using this utility function:
<code>
public static List<String> tokenizeString(Analyzer analyzer, String string) {
List<String> result = new ArrayList<String>();
try {
TokenStream stream = analyzer.tokenStream(null, new StringReader(string));
stream.reset();
while (stream.incrementToken()) {
result.add(stream.getAttribute(CharTermAttribute.class).toString());
}
stream.end();
stream.close();
} catch (IOException e) {
// not thrown b/c we're using a string reader...
throw new RuntimeException(e);
}
return result;
}
</code>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.