solr查询 - 数组至少具有一个值,而不是在特定列表中

发布于 2025-02-09 14:03:06 字数 618 浏览 2 评论 0原文

我需要一种过滤查询的方法,以获取包含至少一个值不在特定列表中的数组的文档。

例如:

{
  id:1,
  field:["dog", "cat", "bird"]
},
{
  id:2,
  field:["cat", "bird"]
},
{
  id:3,
  field:["bird"]
}

我想过滤文档,其中包含至少一个值,而不是“猫”和“鸟”。 预期结果:

{
  id:1,
  field:["dog", "cat", "bird"]
}

我发现了这个类似的问题,但是答案似乎仅适用于整数值: solr查询要过滤文档在数组中至少具有一个值的文档,但指定值

我可以更改文档结构,添加新字段,计算它们...如有必要。

感谢您的帮助 !

I need a way to filter query, in order to get documents containing array with at least one value not in a specific list.

For example :

{
  id:1,
  field:["dog", "cat", "bird"]
},
{
  id:2,
  field:["cat", "bird"]
},
{
  id:3,
  field:["bird"]
}

I want to filter documents which contains at least one value other than "cat" and "bird".
Expected result :

{
  id:1,
  field:["dog", "cat", "bird"]
}

I've found this similar question, but the answers seems to apply only with integers values :
Solr query to filter document with at least one value in array except of specified values

I can change the documents structure, add new fields, calculate them... if necessary.

Thanks for your help !

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

人生戏 2025-02-16 14:03:06

在测试期间对更复杂的值进行排序时,我犯了一个错误,因此看起来该方法不起作用。

解决方案:

qf=field&q=+([* TO bird} {bird TO cat} {cat TO *])

非常感谢Matslindh

I've made a mistake when sorting more complex values during my tests, so it looked like the method wasn't working.

Solution :

qf=field&q=+([* TO bird} {bird TO cat} {cat TO *])

Many thanks MatsLindh

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文