ES查詢返回值詳解

curl -XGET
‘localhost:9200/books/_search?pretty&q=title:elasticsearch’

Elasticsearch返回的響應如下所示

{
    "took":4,                            請求花了多少時間
    "time_out":false,				  	 有沒有超時
    "_shards":{    						 執行請求時查詢的分片信息
        "total":5,     					 查詢的分片數量
        "successful":5,  				 成功返回結果的分片數量
        "failed":0   					 失敗的分片數量
    },
    "hits":{
        "total":2,       				 查詢返回的文檔總數
        "max_score":0.625,  			 計算所得的最高分
        "hits":[						 返回文檔的hits數組
            {
                "_index":"books",		 索引
                "_type":"es",     		 屬性
                "_id":"1",      		 標誌符
                "_score":0.625,      	 得分
                "_source":{			  	 發送到索引的JSON對象
                    "title":"Elasticsearch Server",
                    "publish":2013
                }
            },
            {
                "_index":"books",
                "_type":"es",
                "_id":"2",
                "_score":0.19178301,
                "_source":{
                    "title":"Mastering Elasticsearch",
                    "published":2013
                }
            }
        ]
    }
}```

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章