简体   繁体   中英

Lucene.Net manual query not returning expected results

I am creating a booleanquery in Lucene.net in order to search multiple fields for multiple values.

Running the below constructed query (returns +CustomerId:5) will bring back results.

var booleanQuery = new BooleanQuery();
        Query query = new TermQuery(new Term("CustomerId", "5"));
        booleanQuery.Add(query, Occur.MUST);

Running this other query

var booleanQuery = new BooleanQuery();
        Query query = new TermQuery(new Term("CustomerId", "5"));
        booleanQuery.Add(query, Occur.MUST);
        Query query1 = new TermQuery(new Term("Make", "Subaru"));
        booleanQuery.Add(query1, Occur.MUST);

returns (+CustomerId:5 +Make:Subaru)brings back 0 results even though i can see from the first query that both criteria can be met. As far as i know this should work. Any help is appreciated.

Just in case anyone else is having problems with their queries and feel like mine looked right. The search needed to be carried out using lower case for field value. Using standard analyzer this is how the data was indexed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM