如何关闭elasticsearch响应中的“命中”

时间:2014-07-17 15:08:34

标签: elasticsearch

以下是

的示例回复

curl -X POST "http://localhost:9200/articles/_search?pretty=true" -d ' { "facets": { "speaker" : { "terms" : {"field" : "speaker"} } } }'

样本回复

{
"took": 16,
"timed_out": false,
"_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
},
"hits": {
    "total": 111396,
    "max_score": 1,
    "hits": [
        {
            "_index": "shakespeare",
            "_type": "line",
            "_id": "63098",
            "_score": 1,
            "_source": {
                "line_id": 63099,
                "play_name": "Merchant of Venice",
                "speech_number": 5,
                "line_number": "3.3.14",
                "speaker": "SHYLOCK",
                "text_entry": "Ill have my bond; and therefore speak no more."
            }
        },
        {
            "_index": "shakespeare",
            "_type": "line",
            "_id": "63101",
            "_score": 1,
            "_source": {
                "line_id": 63102,
                "play_name": "Merchant of Venice",
                "speech_number": 5,
                "line_number": "3.3.17",
                "speaker": "SHYLOCK",
                "text_entry": "To Christian intercessors. Follow not;"
            }
        }

    ]
},
"facets": {
    "speaker": {
        "_type": "terms",
        "missing": 0,
        "total": 111396,
        "other": 100157,
        "terms": [
            {
                "term": "GLOUCESTER",
                "count": 1920
            },
            {
                "term": "HAMLET",
                "count": 1582
            }
        ]
    }
}

}

有人可以解释这个回应的部分内容。

  • 为什么hits.hits是一个数组?
  • 每个点击对象意味着什么?
  • 有没有办法抑制弹性搜索响应中的命中?

1 个答案:

答案 0 :(得分:3)

  • hits.hits是一系列符合您搜索查询的已找到文档
  • 每个对象代表单个找到的文档 - 您可以在此处看到_source对象
  • 中的ID,类型和属性
  • 您可以在搜索查询中指定"size" : 0子句,然后hits.hits数组将为空