2021年3月24日星期三

Elastic Search_as_you_type case insensitive match

I want to perform partial search on 3 fields: UUID, tracking_id, and zip_code. They only contain 1 word and no special characters/space except hypen for UUID. I'm not sure whether I should use search_as_you_type or edge ngram tokenizer or edge ngram token filter, so I tried search_as_you_type first.

I have created this index:

{      "settings": {          "index": {              "sort.field": [ "created_at", "id" ],              "sort.order": [ "desc", "desc" ]          }      },      "mappings": {          "properties": {              "id": { "type": "keyword", "fields": { "raw": { "type": "search_as_you_type" }}},              "current_status": { "type": "keyword" },              "tracking_id":     { "type": "wildcard" },              "invoice_number":  { "type": "keyword" },              "created_at":     { "type": "date" }          }      }  }  

and inserted this doc:

{      "id": "SIGRID",      "current_status": "unassigned",      "tracking_id": "AXXH",      "invoice_number": "xxx",      "created_at": "2021-03-24T09:36:10.717672467Z"  }  

I sent this query:

{"query": {      "multi_match": {        "query": "sigrid",        "type": "bool_prefix",        "fields": [          "id"        ]      }    }  }  

this returns no result, but SIGRID, S, SIG returns the result. How can I make search_as_you_type query be case insensitive? should i use edge ngram tokenizer instead? Thanks

https://stackoverflow.com/questions/66792606/elastic-search-as-you-type-case-insensitive-match March 25, 2021 at 11:23AM

没有评论:

发表评论