Phrase_prefix query is not resulting the first term in the term.In the scenerio in autocomplete

Hi Team ,

I am facing the issue while doing autocomplete in elasticsearch.

my Query:

GET /gensuite/itemfacetdata/_search
{
"size" : 100,

  "query" : {
    "match_phrase_prefix": {
      "3": "doo"
    }
  },

"highlight" : {
"fields" : {
"3" : {
"fragment_size" : 0,
"number_of_fragments" : 0
}
}
}

result:

{
"took": 15,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 99704,
"max_score": 21.841854,
"hits": [
{
"_index": "gensuite",
"_type": "itemfacetdata",
"_id": "1175344_1_1",
"_score": 21.841854,
"_source": {
"3": [
"PANEL, BOUNDER FRONT DOORSIDELUGGAGE DOO"
],
"7": [
"EA"
],
"8": [
"1.00"
],
"9": [
"USAS"
],
"10": [
"1"
],
"11": [
"627498"
],
"13": [
"false"
],
"14": [
"627498"
],
"37": "1",
"partId": 1175344,
"languageId": 1,
"mediaId": 0,
"partTypeId": 1,
"partNumber": "627498"
},
"highlight": {
"3": [
"PANEL, BOUNDER FRONT DOORSIDELUGGAGE DOO"
]
}
}
}

My expectation is the term which starts with 'doo' should br resulted first .

I have loaded the data to the ES By bulkupdate and do not have any analyzer.

Thanks in Advance .

Regards:
Venkatesh.

HI Venkatesh,

I think I didn't get perfectly what you are looking for. Did you expect that elasticsearch reordered the terms from your document? Elasticsearch will not change the document in the query result. It will present the documents exactly how they were indexed. But it will grant a better score to those documents where the term "doo" are more relevant.

In the highlight section you will find the matched terms surrounded by an <em>doo</em> so you can use it to mark the term as bold, for example.

Please, also consider using the completion suggester to create autocomplete behaviors as they are more specialized structures for this use case.

Hope it helps!

Cheers,
LG

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.