Terms List Query Usage

edit

Fluent DSL example

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

Object Initializer syntax example

edit
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 example

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

Object Initializer syntax example

edit
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 Responses

edit
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

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

Object Initializer syntax example

edit
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 Responses

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