Terms List Query Usageedit

Fluent DSL exampleedit

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

Object Initializer syntax exampleedit

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

Example json output. 

{
  "terms": {
    "_name": "named_query",
    "boost": 1.1,
    "description": [
      "term1",
      "term2"
    ]
  }
}

Fluent DSL exampleedit

q
.Terms(c => c
    .Name("named_query")
    .Boost(1.1)
    .Field(p => p.Description)
    .Terms(_terms)
)

Object Initializer syntax exampleedit

new TermsQuery
{
    Name = "named_query",
    Boost = 1.1,
    Field = "description",
    Terms = _terms
}

Example json output. 

{
  "terms": {
    "_name": "named_query",
    "boost": 1.1,
    "description": [
      [
        "term1",
        "term2"
      ]
    ]
  }
}

Handling Responsesedit

response.IsValid.Should().BeFalse();

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 exampleedit

q
.Terms(c => c
    .Name("named_query")
    .Boost(1.1)
    .Field(p => p.NumberOfCommits)
    .Terms(_terms)
)

Object Initializer syntax exampleedit

new TermsQuery
{
    Name = "named_query",
    Boost = 1.1,
    Field = "numberOfCommits",
    Terms = _terms,
}

Example json output. 

{
  "terms": {
    "_name": "named_query",
    "boost": 1.1,
    "numberOfCommits": [
      [
        "term1",
        "term2"
      ]
    ]
  }
}

Handling Responsesedit

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");