0
votes

I am trying to do a Match query using Nest using C#. The Match query does not return any results as the syntax of produced JSON seems off, I know for sure that there are documents that contains this keyword. Here is the C# code snippet

var response = conn.Search<DelOrder>(x => x
        .From(0)
        .Size(1000)
        .Query(q => q
               .Match
               (m => m
                    .Field(f => f.customerName).Query(searchValue)
                    .Analyzer("standard")))

this produces following query:

{
    "from": 0,
    "size": 1000,
    "query": {
        "match": {
            "customerName": {
                "**query**": "star",
                "analyzer": "standard"
            }
        }
    }
}

This query, returns 0 results, however when I tweak the same query in Kibana console Get _search

{
    "from":0,
    "size":1000,
    "query": 
    {
        "match":
        {
            "customername":"star"
        }

I get results for the searched term. Notice that the "second query token" is missing from the syntax of the Kibana query.

I did check the documentation and it seem my syntax is correct https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/match-usage.html

Any thoughts on what is going on or how to fix this issue.

1

1 Answers

0
votes

In the NEST query

  1. the standard analyzer is specified whilst the query executed in Kibana does not include this
  2. uses customerName for the field name, inferred from the member expression f => f.customerName, whilst Kibana uses customername (lower case n)

If you amend the NEST query to match the Kibana query, you'll get the results you're expecting.