want to build the auto complete functionality of an e-commerce website, using Completion Suggester.
This is my Index:
PUT myIndex
{
"mappings": {
"_doc" : {
"properties" : {
"suggest" : {
"type" : "completion"
},
"title" : {
"type": "keyword"
},
"category" : {
"type": "keyword"
},
"description" : {
"type": "keyword"
}
}
}
}
}
Now, when uploading the advertisement I want the title field to be used for auto complete, so this is how I upload a document:
POST dummy/_doc
{
"title": "Blue asics running shoes",
"category": "sports",
"description": "Nice blue running shoes, size 44 eu",
"suggest": {
"input": "Blue Asics running shoes" // <-- use title
}
}
Problem is, this way, elastic search only matches the string from beginning... i.e. "Blu" will find result but "Asic" or "Run" or "Sho" won't return anything...
So what I need to do is to tokenize my input like this:
POST dummy/_doc
{
"title": "Blue asics running shoes",
"category": "sports",
"description": "Nice blue running shoes, size 44 eu",
"suggest": {
"input": ["Blue", "Asics", "running", "shoes"] // <-- tokenized title
}
}
This would work fine... But how am I supposed to tokenize my field? I know I can split the string in c#, but is there anyway that I can do this in Elasticsearch/Nest?