lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thturk <tahatur...@hotmail.com>
Subject Re: Create Best Query For My Case
Date Fri, 07 Sep 2018 05:13:16 GMT
 problem is that i am getting back all of the results with matches on
fieldCity, whether i  have a match on fieldText or not, and i want all
results to have at least one match on fieldText.

What i have now is basically: +city text1 text2 text3. The only term
required to match is the city. The rest of the term will impact the score,
but won't restrict the result set. If i want to make sure i get at least one
fieldText match, i could change the query to look more like this: +city
+(text1 text2 text3):

BooleanQuery fieldTextSubQuery = new BooleanQuery.Builder()
    .add(new WildcardQuery(new Term(fieldText, str), Occur.SHOULD)
    .add(new FuzzyQuery(new Term(fieldText, strTemp), fuzzy), Occur.SHOULD)
    .add(new FuzzyQuery(new Term(fieldText, mergedKeyword), fuzzy),
Occur.SHOULD)
    .build();

BooleanQuery finalQuery = new BooleanQuery.Builder()
    .add(new FuzzyQuery(new Term(fieldCity, city), 0), Occur.FILTER)
    .add(fieldTextSubQuery, Occur.MUST)
    .build();

When i changed my query to this.  Final one. I get results which i wanted



--
Sent from: http://lucene.472066.n3.nabble.com/Lucene-Java-Users-f532864.html

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message