首页 > 解决方案 > Solr how to query a field containing a comma separated list?

问题描述

in our solr core we have a field like this:

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

i cannot figure out how i can construct a query that behaves like that:

theTopics_stringS:(IN 2 35 23 66)

so i would want all documents which have 2, 35, 23 or 66 in their theTopics_stringS value

what are my possible options?

version:

solr-spec 7.6.0

标签: searchsolr

解决方案


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

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


推荐阅读