Ref: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-terms-query.html#query-dsl-terms-query

ES 6.4.x

Executing a Terms Query request with a lot of terms can be quite slow, as each additional term demands extra processing and memory. To safeguard against this, the maximum number of terms that can be used in a Terms Query both directly or through lookup has been limited to 65536. This default maximum can be changed for a particular index with the index setting **index.max_terms_count**.

Top-level parameters for terms

  1. GET /_search
  2. {
  3. "query": {
  4. "terms": {
  5. "user.id": [ "kimchy", "elkbee" ],
  6. "boost": 1.0
  7. }
  8. }
  9. }


(Optional, object) Field you wish to search.
The value of this parameter is an array of terms you wish to find in the provided field. To return a document, one or more terms must exactly match a field value, including whitespace and capitalization.
By default, Elasticsearch limits the terms query to a maximum of 65,536 terms. You can change this limit using the index.max_terms_count setting.
To use the field values of an existing document as search terms, use the terms lookup parameters.
boost
(Optional, float) Floating point number used to decrease or increase the relevance scores of a query. Defaults to 1.0.
You can use the boost parameter to adjust relevance scores for searches containing two or more queries.
Boost values are relative to the default value of 1.0. A boost value between 0 and 1.0 decreases the relevance score. A value greater than 1.0 increases the relevance score.

Performance

Ref: https://stackoverflow.com/a/42758176/8945448
ES will search each term individually across your shards, so as more terms are added, it bogs the cluster down. As with anything Elasticsearch though, tuning shard amounts (replicas in your case), node counts, and other configuration options might help.
@jonaf
Describe the feature: I have seen a lot of cases where an application will generate some long list of terms for a TermsQuery and pass it off to Elasticsearch. In general, TermsQuery performance degrades quickly as more terms are added, and once you get into hundreds (or thousands), you can pretty much forget it. (Unless there’s a way to do a terms query with hundreds or thousands of terms and I just don’t know the secret.) I think we should consider short-circuiting on the number of terms if it goes beyond some threshold unless some overriding argument is given. Additionally, it might be a good idea for Elastic.co documentation to warn users that many terms can have a substantial impact on latency, and of course point out the default limit/safeguard (supposing it is decided that the number of terms should be limited).