简体   繁体   English

Lucene.Net手动查询未返回预期结果

[英]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. 我正在Lucene.net中创建一个布尔查询,以便在多个字段中搜索多个值。

Running the below constructed query (returns +CustomerId:5) will bring back results. 运行以下构造的查询(返回+ CustomerId:5)将带回结果。

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. 返回(+ CustomerId:5 + Make:Subaru)返回0个结果,即使我从第一个查询中可以看到两个条件都可以满足。 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. 使用标准分析器,这就是索引数据的方式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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