lucene.net - Lucene Duplicated results / spaces in text search -


i’m using lucene 2.9.4.1 , works fine if search exists once in same line. per instance, if lucene find same string i’m looking in same line, have duplicated (or more) results.

i’m using following booleanquery:  booleanquery.add(new termquery(new term(propertyinfo.name, textsearch)), booleanclause.occur.should); 

the second issue searching spaces “hello world”: never works.

can advise me or me these 2 malfunctioning features, please?

thank in advance, best regards,

well, found answer solved both of issues =)

i using this:

booleanquery booleanquery = new booleanquery(); propertyinfo[] propertyinfos = typeof(t).getproperties(); foreach (propertyinfo propertyinfo in propertyinfos) {     booleanquery.add(new termquery(new term(propertyinfo.name, textsearch)), booleanclause.occur.should); } 

and use this:

var booleanquery = new booleanquery(); textsearch = queryparser.escape(textsearch.trim().tolower());  string[] properties = typeof(t).getproperties().select(x => x.name).toarray();  analyzer analyzer = new standardanalyzer(global::lucene.net.util.version.lucene_29); multifieldqueryparser titleparser = new multifieldqueryparser(lucene.net.util.version.lucene_29, properties, analyzer); query titlequery = titleparser.parse(textsearch);  booleanquery.add(titlequery, booleanclause.occur.should); 

it seems analyzer , multifieldqueryparser solution problems: no more duplicated results, can search spaces , … performance raised (faster results) =)


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -