:ref_current: https://www.elastic.co/guide/en/elasticsearch/reference/master

:github: https://github.com/elastic/elasticsearch-net

:nuget: https://www.nuget.org/packages

////
IMPORTANT NOTE
==============
This file has been generated from https://github.com/elastic/elasticsearch-net/tree/master/src/Tests/Tests/QueryDsl/TermLevel/Terms/TermsListQueryUsageTests.cs. 
If you wish to submit a PR for any spelling mistakes, typos or grammatical errors for this file,
please modify the original csharp file found at the link and submit the PR with that change. Thanks!
////

[[terms-list-query-usage]]
=== Terms List Query Usage

==== Fluent DSL example

[source,csharp]
----
q
.Terms(c => c
    .Name("named_query")
    .Boost(1.1)
    .Field(p => p.Description)
    .Terms(new List<string> { "term1", "term2" })
)
----

==== Object Initializer syntax example

[source,csharp]
----
new TermsQuery
{
    Name = "named_query",
    Boost = 1.1,
    Field = "description",
    Terms = new List<string> { "term1", "term2" }
}
----

[source,javascript]
.Example json output
----
{
  "terms": {
    "_name": "named_query",
    "boost": 1.1,
    "description": [
      "term1",
      "term2"
    ]
  }
}
----

==== Fluent DSL example

[source,csharp]
----
q
.Terms(c => c
    .Name("named_query")
    .Boost(1.1)
    .Field(p => p.Description)
    .Terms(_terms)
)
----

==== Object Initializer syntax example

[source,csharp]
----
new TermsQuery
{
    Name = "named_query",
    Boost = 1.1,
    Field = "description",
    Terms = _terms
}
----

[source,javascript]
.Example json output
----
{
  "terms": {
    "_name": "named_query",
    "boost": 1.1,
    "description": [
      [
        "term1",
        "term2"
      ]
    ]
  }
}
----

==== Handling Responses

[source,csharp]
----
response.ShouldNotBeValid();

response.ServerError.Should().NotBeNull();
response.ServerError.Status.Should().Be(400);
response.ServerError.Error.Should().NotBeNull();
var rootCauses = response.ServerError.Error.RootCause;
rootCauses.Should().NotBeNullOrEmpty();
var rootCause = rootCauses.First();
rootCause.Type.Should().Be("parsing_exception");
----

==== Fluent DSL example

[source,csharp]
----
q
.Terms(c => c
    .Name("named_query")
    .Boost(1.1)
    .Field(p => p.NumberOfCommits)
    .Terms(_terms)
)
----

==== Object Initializer syntax example

[source,csharp]
----
new TermsQuery
{
    Name = "named_query",
    Boost = 1.1,
    Field = "numberOfCommits",
    Terms = _terms,
}
----

[source,javascript]
.Example json output
----
{
  "terms": {
    "_name": "named_query",
    "boost": 1.1,
    "numberOfCommits": [
      [
        "term1",
        "term2"
      ]
    ]
  }
}
----

==== Handling Responses

[source,csharp]
----
response.ServerError.Should().NotBeNull();
response.ServerError.Status.Should().Be(400);
response.ServerError.Error.Should().NotBeNull();
var rootCauses = response.ServerError.Error.RootCause;
rootCauses.Should().NotBeNullOrEmpty();
var rootCause = rootCauses.First();
rootCause.Type.Should().Be("parsing_exception");
----

