nest - Case insensitive fields in Elasticsearch -


i using nest elasticsearch , trying search allowing users type search phrases search box. working fine apart fact when user enters search phrase need make sure field name same case field name in elastic search.

for example, 1 of fields called booktitle. if search below works

booktitle:"a tale of 2 cities"

if search example below not work

booktitle:"a tale of 2 cities" booktitle:"a tale of 2 cities"

the code using search below. have ideas on how can fix this. hoping there elasticsearch/nest setting allows me opposed doing somehthing ugly search text finding "booktitle" , replacing "booktitle".

   public list<elasticsearchrecord> search(string searchterm) {          var results = _client.search<elasticsearchrecord>(s => s                         .query(q => q                             .querystring(qs => qs                                 .defaultfield("content")                                 .query(searchterm)                             )                         ));           return results.documents.tolist();     } 

any appreciated.

the way want not possible elasticsearch. in control of mapping, define names of fields, 1 who's controlling queries.

by judgement, need watch users type in search field, elasticsearch out-of-the-box not lowercasing field names or that.

so, whatever solution choose workaround.

my suggestion define set of rules, should communicated users. around these lines:

  • your field names lowercased, or camel-cased
  • you define mapping strict in full control of it
  • you notify users (in web interface or ui) should search field names given set of rules (lowercase only, or camel case etc)

another approach define what goes _all field. , in querystring don't use specific field names , es use query_string default setting. means es use _all, _all field know contains.

just sake of mentioning this, but means don't recommend it, think can use script whatever want field name in groovy. but, means you not use real power of elasticsearch.

educate users , define set of rules stick to, mentioned above.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -