You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by vempap <ph...@emc.com> on 2013/04/08 01:17:06 UTC
Token Stream with Offsets (Token Sources class)
Hi,
I've the following snippet code where I'm trying to extract weighted span
terms from the query (I do have term vectors enabled on the fields):
File path = new File(
"<path-to-index-dir>");
FSDirectory directory = FSDirectory.open(path);
IndexReader indexReader = DirectoryReader.open(directory);
Map<String, WeightedSpanTerm> allWeightedSpanTerms = new HashMap<String,
WeightedSpanTerm>();
WeightedSpanTermExtractor extractor = null;
extractor = new WeightedSpanTermExtractor();
TokenStream tokenStream = null;
tokenStream = TokenSources.getTokenStreamWithOffsets(indexReader, 0,
"name");
allWeightedSpanTerms.putAll(extractor.getWeightedSpanTerms(q,
tokenStream));
In the end, if I look at the map "allWeightedSpanTerms" - I don't have any
weighted span terms & when I tried to debug the code I found that when it is
trying to build the TermContext the statement "fields.terms(field);" is
returning "null" which I don't understand.
My query is : "Running Apple" (a phrase query)
my doc contents are :
name : Running Apple 60 GB iPod with Video Playback Black - Apple
Please let me know on what I'm doing anything wrong.
Thanks.
Phani.
--
View this message in context: http://lucene.472066.n3.nabble.com/Token-Stream-with-Offsets-Token-Sources-class-tp4054384.html
Sent from the Solr - User mailing list archive at Nabble.com.