1

I use following query:

var searchResults = client.Search<Contact>(s => s
            .Index("someIndex")
            .From(0)
            .Size(20)
            .AllTypes()
            .MatchAll()
            .Query(q => q
                .Bool(bq => bq
                    .Must(mb => mb
                        .QueryString(qs => qs
                            .DefaultField(c => c.ValueCollection.Channel)
                            .Query("E-Mail")
                        )
                    )
                )
            )
        );

When I comment out the .Query() part, I get 20 hits as expected, but with the .Query() part there are always 0 hits.

With elastichead I tried the same and it generates this JSON:

{
  "from": 0,
  "size": 20,
  "query": {
    "bool": {
      "must": [
        {
          "query_string": {
            "query": "E-Mail",
            "default_field": "contact.ValueCollection.Channel"
          }
        }
      ]
    }
  }
}

It results in 20 hits.

Then I inspected the ConnectionStatus.Request and the JSON there is different:

{
  "from": 0,
  "size": 20,
  "query": {
    "bool": {
      "must": [
        {
          "query_string": {
            "query": "E-Mail",
            "default_field": "valueCollection.channel" <--- WRONG!!!
          }
        }
      ]
    }
  }
}

The default_field is generated wrong. What am I doing wrong?

Saeed Zhiany
  • 2,051
  • 9
  • 30
  • 41

1 Answers1

2

Found something:

        var settings = new ConnectionSettings(uri)
            .SetDefaultPropertyNameInferrer(p => p);

This does the trick of telling NEST to not camelCase property names.