solr - Why does this code - adding wordnet synonyms to index - fail? -


i writing code part of customanalyzer:

public class customanalyzer extends analyzer {  synonymmap mysynonymmap = null;  customanalyzer() throws ioexception {     synonymmap.builder builder = new synonymmap.builder(true);      filereader fr = new filereader("/home/watsonuser/downloads/wordnetsynonyms.txt");     bufferedreader br = new bufferedreader(fr);     string line = "";      while ((line = br.readline()) != null) {       string[] synset = line.split(",");       for(string syn: synset)           builder.add(new charsref(synset[0]), new charsref(syn), true);     }      br.close();     fr.close();      try {         mysynonymmap = builder.build();     } catch (ioexception e) {         system.out.println("unable build synonymmap");         e.printstacktrace();     } }  public tokenstream tokenstream(string fieldname, reader reader) {     tokenstream result = new porterstemfilter(new synonymfilter(                                               (new stopfilter(true,new lowercasefilter                                                (new standardfilter(new standardtokenizer                                                  (version.lucene_36,reader)                                                 )                                                ),stopanalyzer.english_stop_words_set)), mysynonymmap, true)                                                );   } } 

now, if use same customanalyzer part of querying, if enter query as

myfieldname: manager 

it expands query synonyms manager.

but, want synonyms part of index , don't want query expanded synonyms.

so, when removed synonymfilter customanalyzer when querying index, query remains as

myfieldname: manager 

but, fails retrieve documents have synonyms of manager.

how solve problem?

if not have synonym builder during query processing term match mapped during indexing. , not showing part here.

the best way troubleshoot @ admin/core/analysis screen (in solr 4+) , put text in. show happens text after each stage in indexing , queries run.

you don't need run reindexer. can define bunch of different types trying figure out , run analysis of sample sentences directly against types.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -