文档

json格式结果解析

更新时间:

config子句中format设置为json表示以JSON格式返回结果,JSON返回的结果示例如下:

{
    "result":{
        "searchtime":0.001, //查询时间
        "totalHits":10,  //总结果数
        "numHits":10, //本次返回的结果数
              "coveredPercent" : 100.0, //覆盖的分片的百分比
        "items":[ //返回结果的list
            {
                "fields":{  //返回的字段
                    "normal_key":"normal_value",
                    "multi_key":"valuetvalue1"
                },
                "property":{ //Qrs插件中定义的与每个doc相关的信息,没有定义时不用关心
                    "property_normal_key":"property_normal_value",
                    "property_multi_key":"valuetvalue1"
                },
                "attribute":{ //属性字段,有attribute子句时返回
                    "int_key":[
                        1,
                        2
                    ],
                    "double_key":[
                        1.1,
                        2.1
                    ],
                    "string_key":[
                        "1",
                        "2"
                    ],
                    "multi_key_attr":[
                        "valueu001Dvalue"
                    ]
                },
                "variableValue":{ //返回序列化的变量
                    "variable_int_key":[
                        1,
                        2
                    ],
                    "variable_double_key":[
                        1.1,
                        2.1
                    ],
                    "variable_string_key":[
                        "1",
                        "2"
                    ],
                    "variable_multi_key_attr":[
                        "valueu001Dvalue"
                    ]
                },
                "sortExprValues":[  //排序分数
                    "1.001",
                    "1.002"
                ],
                "tracerInfo":"tracer for hit" //排序trace
            }
        ],
        "facet":[ //统计信息
                                                {
                            "key":"expr1",
                            "items":[
                                {
                                    "value":"key1",
                                    "sum":"4444",
                                    "count":"123"
                                },
                                {
                                    "value":"key2",
                                    "sum":"5555",
                                    "count":"345"
                                }
                    ]
                }
        ]
    },
    "errors":[ //错误信息
        {
            "code":1,
            "message":"error"
        }
    ],
    "tracer":"trace infon" //请求基本的trace信息
}