Reputation: 1
I have too many fields in my documents. But I need only a few selected ones to be present in my response. Is there someway to do this?
Upvotes: 0
Views: 94
Reputation: 217254
Specifying the request fields
is generally not recommended.
The best practice is to use source filtering and specify the fields you want to retrieve from the source of your document. This feature is much more powerful as not only can you specify which fields to include, but you can also specify which fields to exclude. And you can also use patterns, such as obj.*
as your field names.
The most basic way of using source filtering is by specifying the fields you want:
{
"query": {
"match": {
"title": "text"
}
},
"_source": [
"title",
"summary"
]
}
Upvotes: 2