Search code examples
elasticsearchnest

ElasticSearch Multi-Match in Nest


I have this DSL query which works. It returns the result as expected.

GET /filedocuments/_search
{
    "query": {
        "multi_match": {
          "query": "abc",
          "fields": ["fileName", "metadata"]
        }
    }
}

But, when it runs at NEST library below, it returns no result. What have I missed out?

var response = await _elasticClient.SearchAsync<FileDocument>(s => s
    .Query(q => q
        .MultiMatch(c => c
            .Fields(f => f.Field(p => p.FileName).Field(p => p.Metadata))
            .Query("abc")
        )
    )
);

This is the mapping:

"fileName" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        }

and

 "metadata" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        }

Solution

  • Solved after I convert it to .ToUpper()