【问题标题】:Solr how to query a field containing a comma separated list?Solr如何查询包含逗号分隔列表的字段?
【发布时间】:2020-07-15 12:26:52
【问题描述】:

在我们的 solr 核心中,我们有一个这样的字段:

doc1: "theTopics_stringS":"2,4,143"
doc2: "theTopics_stringS":"34,11,56,73"

我不知道如何构造一个这样的查询:

theTopics_stringS:(IN 2 35 23 66)

所以我想要所有在 theTopics_stringS 值中有 2、35、23 或 66 的文档

我有哪些可能的选择?

版本:

solr-spec 7.6.0

【问题讨论】:

    标签: search solr


    【解决方案1】:

    在索引时拆分内容;即将其索引为多值字段 - [2, 4, 13],或使用将其拆分为适当标记的标记器。标准标记器应该适用于您拥有的格式,其中, 用作分隔符。默认的 text_en 字段可能适用于此。

    然后,您可以使用 theTopics_ints:(2 35 23 66) 作为查询来获取该列表中包含 2、35、23 或 66 的任何文档(给定 q.op=OR)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-11-28
      • 2018-02-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多