There is a company index
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
green open company KTngnM6ASD-_KdU0FFAWRA 1 0 88243299 29462913 24.7gb 24.7gb
because many company name has same prefix, e.g. Shanghai. So if you only search Shanghai
it is very slow
Query from slowlog:
{
"size": 1,
"query": {
"function_score": {
"query": {
"bool": {
"should": [
{
"match": {
"name": {
"query": "Shanghai",
"operator": "AND",
"prefix_length": 0,
"max_expansions": 50,
"fuzzy_transpositions": true,
"lenient": false,
"zero_terms_query": "NONE",
"auto_generate_synonyms_phrase_query": true,
"boost": 1.0
}
}
},
{
"match": {
"shortName": {
"query": "Shanghai",
"operator": "OR",
"prefix_length": 0,
"max_expansions": 50,
"fuzzy_transpositions": true,
"lenient": false,
"zero_terms_query": "NONE",
"auto_generate_synonyms_phrase_query": true,
"boost": 2.9
}
}
},
{ "term": { "name.keyword": { "value": "Shanghai", "boost": 2.0 } } },
{ "match_phrase": { "name": { "query": "Shanghai", "slop": 0, "zero_terms_query": "NONE", "boost": 1.0 } } }
],
"adjust_pure_negative": true,
"minimum_should_match": "1",
"boost": 1.0
}
},
"functions": [
{
"filter": { "match_all": { "boost": 1.0 } },
"field_value_factor": { "field": "weight", "factor": 1.0, "missing": 0.0, "modifier": "none" }
},
{
"filter": { "match_all": { "boost": 1.0 } },
"field_value_factor": { "field": "viewCount", "factor": 1.0, "missing": 0.0, "modifier": "log1p" }
}
],
"score_mode": "sum",
"boost_mode": "sum",
"max_boost": 3.4028235e38,
"boost": 1.0
}
},
"profile": true
}
In normal situation user will search specific name, e.g. Alibaba , in this case the response time is not slow, but if user search common prefix e.g. Beijing Shanghai it will be slow.
Does exist some manner could implement this purpose that is if user search some common prefix, just return the requested size docs which just contains the common prefix do not need score or something else work
question from:
https://stackoverflow.com/questions/65561013/fast-return-when-search-common-prefix-keyword