【问题标题】:How to turnoff 'hits' in elasticsearch response如何在弹性搜索响应中关闭“命中”
【发布时间】:2014-07-22 16:16:03
【问题描述】:

以下是

的示例响应

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 是一个数组?
  • 每个 hits 对象是什么意思?
  • 有没有办法抑制弹性搜索响应的命中?

【问题讨论】:

  • 为什么投反对票?注意:构面被聚合取代:facets have been replaced by aggregations in Elasticsearch 1.0, which are a superset of facets.我想要没有命中结果的聚合结果,我认为这就是文卡特问题的精神。即使 Elasticsearch 以任何一种方式执行相同的工作,空的 hits 数组也会使响应变小。
  • @TheRedPea 你说得对。

标签: elasticsearch


【解决方案1】:
  • hits.hits 是找到的满足您搜索查询的文档数组
  • 每个对象代表单个找到的文档 - 您可以在此处查看其在 _source 对象中的 ID、类型和属性
  • 您可以在搜索查询中指定"size" : 0 子句,然后hits.hits 数组将为空

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-03-28
    • 1970-01-01
    • 1970-01-01
    • 2017-01-26
    • 2019-05-13
    • 1970-01-01
    • 1970-01-01
    • 2014-06-18
    相关资源
    最近更新 更多