Solr搜索以JSON格式返回返回值包含在数组中

时间:2016-04-13 08:34:11

标签: 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}] }}

2 个答案:

答案 0 :(得分:3)

我认为您已经提到了架构中定义的multiValued属性,是否允许该字段具有多个值。

例如: 如果你有一个multiValued = true的fieldType,

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

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

答案 1 :(得分:2)

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

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