Hello everyone,
I want to add some contains like functionality on my SimpleQueryString query. Currently, I am using Custom Shingle Analyzer and if I have tokens like [“elastic”, “search”, “kibana”], it can search its combinations, but combinations I want to achieve are something like this…
elasti + searc or
search + ela or
elast + sear + kib
My index settings:
PUT index { "settings" : { "number_of_shards" : "1", "analysis" : { "filter" : { "custom_shingle" : { "max_shingle_size" : "2", "min_shingle_size" : "2", "output_unigrams" : true, "type" : "shingle" }, "my_char_filter" : { "pattern" : " ", "type" : "pattern_replace", "replacement" : "" } }, "analyzer" : { "bigram_combiner" : { "filter" : [ "lowercase", "custom_shingle", "my_char_filter" ], "tokenizer" : "standard" } } }, "number_of_replicas" : "1" } }
Index mappings:
PUT index/_mapping
{
"properties" : {
"analyzedName" : {
"type" : "nested",
"properties" : {
"text" : {
"type" : "text",
"analyzer" : "bigram_combiner"
}
}
}
}
Query
{
"_source": "analyzedName.text",
"from": 0,
"query": {
"bool": {
"must": [
{
"nested": {
"path": "analyzedName",
"query": {
"simple_query_string": {
"default_operator": "and",
"fields": [
"analyzedName.text"
],
"query": ""
}
}
}
}
]
}
},
"size": 10
}