lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thturk <>
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),

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

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

Sent from:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message