I want to exclude a field from resulted Documents in ElasticSearch. I went through this document of ElasticSearch.org http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-fields.html but this doesn't work when I try. I have seen the same question on SO Is there a way to exclude a field in an Elasticsearch query but unfortunately that also doesn't give the answer just pasted example from ElasticSearch site. Here is my code
{
"query":
{
"multi_match": {
"fields": [
"user",
"email"
],
"query": "John",
"operator": "and",
"type": "phrase_prefix"
}
}
},
"partial_fields" : {
"partial1" : {
"exclude" : "email"
}
},
"from" : 0,
"size" : 10
}
Here is the result of above query
{
"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"
}
}
]
}
}
in the above query everything works fine but that gives result with Email field as well and I want to exclude this Email field from being in resulted documents.