温馨提示:本文翻译自stackoverflow.com,查看原文请点击:lucene - Looking for solr query which will include results with both missing field and the same field which h
lucene solr

lucene - 寻找solr查询,其中将包含缺少字段和与h相同的字段的结果

发布于 2020-05-02 19:22:10

假设我有以下数据

{
 fruit: "Mango",
 cost : 2.00,
 variety : "alphanso",
},
{
 fruit : "apple",
 cost : 1.40,
 variety : "Gala"
},
{
 fruit : "apple",
 variety : "cosmic crisp",
},
{
fruit : "apple",
variety : "honey crisp",
cost : 2.99
}

我正在寻找一个返回成本在1到2之间的苹果,并且还返回没有设置成本字段的品种的搜索。

在这种情况下,结果将包含“嘎拉”和“宇宙脆”

查看更多

提问者
user2938885
被浏览
49
MatsLindh 2020-02-13 17:00

从完整的文档集开始*:*,减去具有值的文档[* TO *],然后添加相匹配的文档variety:Gala

q=(*:* -cost:[* TO *]) OR variety:Gala