所以我使用的是elasticsearch V2.3.1。以下是我的弹性搜索查询:
GET pibtest1/_search?q=white
{
"size": 1,
"fields": ["U", "UE", "UD", "T"]
}
运行上述查询后,我得到以下结果:
{
"took": 2,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 85,
"max_score": 0.15116164,
"hits": [
{
"_index": "pibtest1",
"_type": "SearchTech",
"_id": "1",
"_score": 0.15116164,
"fields": {
"UE": [
"Some value1"
],
"U": [
"Some value2"
],
"T": [
"Some value3"
],
"UD": [
"Some value4"
]
}
}
]
}
}
正如您在结果中看到的,Elasticsearch不提供有关搜索查询的任何信息。在我的例子中,查询是“白色”。那么有没有办法在结果中获得搜索查询(“白色”)?例如,我想在结果中得到类似的东西 - >
“query”: “white”
我检查了Elasticsearch的解释API。它确实提供了如何计算得分的详细信息,但它没有明确包含搜索查询的任何字段。谢谢大家。