Solr分面搜索:JSON格式不一致

14

我的solr架构中有以下两个字段:

<field name="brand_id"     type="string" indexed="true" stored="true" />
<field name="category_id"  type="string" indexed="true" stored="true" />
当我启用facets(以brand_id为例)来发出请求时, http://example.com/solr/select?wt=json&facet=true&facet.mincount=1&facet.field=brand_id&q=* :*, 返回的faceting输出以对象表示形式返回:
"facet_counts": {
    "facet_queries": { }
    "facet_fields": {
         "brand_id": [
            {"1350492":14},
            {"1350578":12},
            {"1350600":11},
            {"1350617":8}
        ]
    }
}

然而,使用“category_id”作为Facet字段重复相同的请求会返回一个数组符号。 http://example.com/solr/select?wt=json&facet=true&facet.mincount=1&facet.field=category_id&q=* :*

"facet_counts":{
    "facet_queries":{},
    "facet_fields":{
        "category_id":[
            "230",20,
            "259",13,
            "154",12,
            "249",11
        ]
    }
}

有没有一种方法可以强制对象注释格式?我正在使用Solr 3.6

-- 更新 --

使用XML格式返回正确的结果:

<lst name="facet_counts">
<lst name="facet_queries"/>
<lst name="facet_fields">
    <lst name="brand_id">
        <int name="269115">136</int>
        <int name="269394">110</int>
    </lst>


    <lst name="category_id">
        <int name="1348814">228</int>
        <int name="1350591">218</int>
    </lst>

1
当您将wt从JSON更改为XML时,输出是什么? - pensz
@pensz XML 返回正确的结构(我更新了问题)。 - mjalajel
8
你确定第一个查询没有添加json.nl=map而第二个查询添加了吗?请确认。 - Bill Dueber
1
@BillDueber 没有为任何一个设置。但是知道这个参数存在回答了我的问题。谢谢。 - mjalajel
3个回答

10

1
请查看此处的JSON特定参数 - Eagle_Eye

1

谢谢,我也遇到了类似的问题。json.nl 起作用了。 - Vivek Agrawal

0

我之前也遇到过类似的问题。

尝试在字段定义中添加标签multiValued=false。我记得这个方法对我有用。

不过你可能需要重新索引。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接