简体   繁体   English

在lucene中查询字符串

[英]Querying a string in lucene

I am using Lucene for .net. 我正在将Lucene用于.net。 I have the following document with field and the value is like "5 1 You love banana 5 2 Hello" How can I query so that it will be a result when I query "5 1" & "banana"? 我有以下带有字段的文档,其值类似于“ 5 1您爱香蕉5 2你好”,如何查询,以便在查询“ 5 1”和“香蕉”时得到结果?

I am using StandardAnalyzer and the field is analyzed. 我正在使用StandardAnalyzer并对字段进行分析。

Thank you very much 非常感谢你

Assuming the test value is the default search field, you could write a query like +"5 1" +banana or alternately "5 1" AND banana (though I don't like the Lucene AND/OR/NOT syntax personally) 假设测试值为默认搜索字段,则可以编写一个查询,例如+"5 1" +banana"5 1" AND banana (尽管我个人不喜欢Lucene AND / OR / NOT语法)

If it's not the default field, just preface your terms with the search field, such as: +textfield:"5 1" +textfield:banana 如果不是默认字段,则只需在搜索字段前面加上您的字词即可,例如: +textfield:"5 1" +textfield:banana

Lucene standard query syntax is documented pretty well here: Version 3.6 Or Version 4.0 Lucene标准查询语法在此处记录得很好: 版本3.6版本4.0

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

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