使用Spring Boot在Solr中搜索以逗号分隔的列表

时间:2021-07-19 00:23:43

I have an object Foo with a List<String> property names:

我有一个带有List 属性名称的对象Foo:

class Foo {
    List<String> names = []
}

In my schema.xml for Solr, I have it configured as a string:

在我的Solr的schema.xml中,我将它配置为字符串:

<field name="names" type="string" indexed="true" stored="true"/>

I am then trying to perform a search on it, where, as long as ANY of the values match ANY of the ones in the list, I expect a hit:

然后我尝试对它进行搜索,只要任何值与列表中的任何值匹配,我期望得到一个命中:

new Criteria('names').in(filter.names)

However, because the values are stored as a comma-separated String in Solr, I am not getting back any results.

但是,因为值在Solr中存储为逗号分隔的String,所以我没有收到任何结果。

Is there something I should change to be able to split or parameterize the field into a list so that I can perform my search?

有什么我应该改变,以便能够将字段拆分或参数化为一个列表,以便我可以执行我的搜索?

1 个解决方案

#1


One possible solution is to make the field in solr to be multi-valued.

一种可能的解决方案是使solr中的字段成为多值。

#1


One possible solution is to make the field in solr to be multi-valued.

一种可能的解决方案是使solr中的字段成为多值。