简体   繁体   English

是Lucene +经典查询搜索语法与使用AND相同

[英]is Lucene + classic query search syntax same as using AND

A Lucene query of the form 表单的Lucene查询

field1:+"term1" field2:+"term2"

seems to be equivalent to 似乎相当于

field1:"term1" OR field2:"term2"

I expected it to be equivalent to 我希望它等同于

field1:"term1" AND field2:"term2"

(ie for my particular query on my database query 1 and 2 are returning 10 records, whereas query 3 is returning 6 records, I would expect query 2 to only return six records) (即我的数据库查询1和2的特定查询返回10条记录,而查询3返回6条记录,我希望查询2只返回6条记录)

Im aware that if there is no OR or AND it defaults to OR but I thought the + means that term has to match, otherwise what is the point of the + What am i misunderstanding ? 林意识到,如果没有ORAND则默认为OR,但我认为,+意味着词有相匹配,否则什么是+什么是我的误解呢?

That query doesn't look equivalent to either of those, to me. 对我来说,那个查询看起来并不等同于其中任何一个。

field1:+"term1" field2:+"term2"

Is just invalid syntax, and the standard QueryParser does kick out a ParseException for it (maybe your code is swallowing the exception silently or something?). 只是无效的语法,标准的QueryParser会为它发出一个ParseException (也许你的代码是静默吞噬异常的东西?)。

It should be: 它应该是:

+field1:"term1" +field2:"term2"

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

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