我想从ElasticSearch中的结果文档中排除一个字段。我仔细阅读了ElasticSearch.org http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-fields.html的这份文档,但是当我尝试时这不起作用。我在SO Is there a way to exclude a field in an Elasticsearch query上看到了相同的问题,但不幸的是,这也没有给出仅来自ElasticSearch网站的示例粘贴答案。这是我的代码
{
"query":
{
"multi_match": {
"fields": [
"user",
"email"
],
"query": "John",
"operator": "and",
"type": "phrase_prefix"
}
}
},
"partial_fields" : {
"partial1" : {
"exclude" : "email"
}
},
"from" : 0,
"size" : 10
}
这是上面查询的结果
{
"took": 5,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 2,
"max_score": 1,
"hits": [
{
"_index": "abc",
"_type": "users",
"_id": "4",
"_score": 1,
"_source": {
"user": "John Smith",
"email": "johnsmith_88@yahoo.com",
"pic": "95052dc5bb0bd2575.01687359.jpg"
"utype": "m"
}
},
{
"_index": "abc",
"_type": "users",
"_id": "1",
"_score": 1,
"_source": {
"user": "Johnathan",
"email": "johnathan@ymail.com",
"pic": "428952deea899c6ad3.87100416.jpg"
"utype": "m"
}
}
]
}
}
在上面的查询中,一切工作正常,但是也给出了带有电子邮件字段的结果,我想从结果文档中排除此电子邮件字段。
最佳答案
由于该查询已解决,因此输入错误。有几种方法可以在发送之前检查查询。
elasticsearch-head
插件,该插件可以帮助您通过简单而有用的界面关于json - 从ElasticSearch中的结果文档中排除字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21280407/