简体   繁体   English

如何查询Solr apache php数组一个值

[英]How to query Solr apache php array one value

I have data我有数据

id = [1,2,3]
id = [2]
id = [2,3]
id = [1,3]
id = [2]

Expected results:预期成绩:

id = [2]
id = [2]

Current results:当前结果:

id = [1,2,3]
id = [2]
id = [2,3]
id = [2]

My current query:我目前的查询:

$query->createFilterQuery('id')->setQuery('id:2');

I just want to get arrays that have one value, and it will be equal to the value I passed in like 1 or 2 or 3. As in the above example, I pass the value = 3, the result will return null.我只想得到 arrays 有一个值,它会等于我传入的值,比如 1 或 2 或 3。如上例中,我传递的值 = 3,结果将返回 null。

Thank everyone!谢谢大家!

You can use a query like id:2 AND NOT id:[* TO 2} AND NOT id:{2 TO *] .您可以使用类似id:2 AND NOT id:[* TO 2} AND NOT id:{2 TO *]的查询。 It'll effectively search for any documents that have 2 in the id field, and then remove any documents that have any value less than or more than the desired id value.它将有效地搜索id字段中包含2的任何文档,然后删除任何值小于或大于所需id值的任何文档。

The difference between { and [ is that one is exclusive and the other is inclusive of the value itself. {[之间的区别在于,一个是独占的,另一个是包含值本身的。

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

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