JSON格式的Solr搜索返回的值封装在数组中



我不明白为什么我的搜索结果总是返回数组中的值——我作为一个普通的键值文档进行索引,但这些值似乎在数组中。

索引数据时是否遗漏了什么,或者与查询格式有关?

{ "responseHeader":{ "status":0, "QTime":1, "params":{ "q":"ember", "indent":"on", "start":"0", "rows":"20", "wt":"json", "_":"1460536046068"}}, "response":{"numFound":1,"start":0,"docs":[ { "content":["A little while back, I wrote a blog post introducing ember-suave,n an addon that we created at DockYard to help enforce a common code nstyle across all of our projects. With the addon installed, any code nthat doesn't align with the established styleguide will cause the build nto fail. During development, as files are modified, the linter will nreprocess the changed files, displaying errors in the console right naway.https://dockyard.com/blog/2016/02/29/code-linting-inside-look"], "createdAt":["2016-04-13T08:19:24.321Z"], "updatedAt":["2016-04-13T08:19:24.823Z"], "id":"7102mmzmya4e", "type":["post"], "_version_":1531482543265677312}] }}

我想您已经提到了在模式中定义的multiValued属性,无论字段是否允许有多个值。

例如:如果您的字段类型为multiValued=true,则

True如果该字段可能包含每个文档的多个值,即如果它可以在文档中多次出现

您必须将其添加为multiValued=true,因此它会认为该字段有多个值…因此将其作为数组返回。。

如果使用schemales设置,则所有自动创建的字段都将是多值的,并在类型本身上定义该标志。这是因为算法不知道单个值是始终保持单个值,还是以后变成多值。

您可以在solrconfig.xml中更改算法(映射),也可以在托管架构中添加multiValued="false",重新加载并重新索引。

最新更新