0

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?

1 Answer 1

2

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"
  ]
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.