Elasticsearch-net: Couln'nt find case_insensitive option in High Level Client Term Query(NEST)

Created on 16 Mar 2021  路  5Comments  路  Source: elastic/elasticsearch-net

Hi,
I am using ElasticSearch version 7.11. My TermQuery only returns case-sensitive matching results,to avoid that I set case_insensitive as true in DSL term query like below and it returns data as expected.

{
    "query": {
        "term": {
            "title": {
                "value": "BIG THEORY",
                "case_insensitive": true
            }
        }
    }
}

But when I am trying to implement in code using High Level Client [Nest], could'nt find the option to set case_insensitive as true.

   var searchResults = eClient.Search<Dictionary<string, object>>(s => s
                                 .Index("wss")
                                 .Query(q =>
                                    q.Term(t => t.Field("title").Value("BIG THEORY"))
                                )).Documents.ToList();

In above code how should I set the case_insensitive option as true in Term Query.

Thanks in Advance

Feature

All 5 comments

Hi @Sangeetha-Murugesan! Thanks for raising this. It's something I have in fact been working on that slightly dropped off my radar so this has been a useful reminder! I'm aiming to have it implemented in time for the next release. If it's blocking you then an option, albeit not extremely nice, is to drop to the low-level client for this case and send your query as PostData.

```c#
var postData = PostData.String(@"{
""query"": {
""term"": {
""name"": {
""value"": ""STEVE"",
""case_insensitive"": true
}
}
}
}");

var response = _client.LowLevel.DoRequest>>(HttpMethod.POST, "wss/_search", postData);
```

@stevejgordon Any option to implement it in High Level Client?

@Sangeetha-Murugesan Yes, absolutely! I'm working on it as we speak, but it won't be available until the next release so I wanted to give you a workaround until we have a date for 7.12.0.

@stevejgordon Thanks !!

PR is merged for 7.12.0 release.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Mpdreamz picture Mpdreamz  路  21Comments

kaaresylow picture kaaresylow  路  14Comments

niemyjski picture niemyjski  路  13Comments

meriturva picture meriturva  路  13Comments

testos944 picture testos944  路  15Comments