Need Suggestion on match_phrase_prefix and field priority result top to bottom order

Hy Team, I have implemented the bool query "match_phrase_prefix" with "slop" in my search functionality and the query is giving me the result as expected. but the order of the result is not giving the field priority.

We have 3 fields below and the order of the result should show the following priority if the keyword phrase is matched.

Title : 1 Priority
Tag : 2 Priority
Description : 3d

Search Keyword like: "3rd generation intel Xeon"

if the title match with the phrase then the title should come up on top then tag then the description as per priority.

Order of phrase search first in the title and with updated date order by
Title: "3rd generation intel Xeon" ------Matched June-01-2021
Title: "3rd generation intel Xeon" ----another title--Matched May-01-2021
tag: "3rd generation intel Xeon" ------Matched June -02-2021
des: "3rd generation intel Xeon" ------Matched
title: "3rd generation" ------Matched
des: "3rd generation" ------Matched
tag: "intel Xeon" ------Matched

Here is my elastic query which I am currently used.

> {
>       "query": {
> "constant_score": {
>   "filter": {
>     "bool": {
>       "must": [
>         {
>           "match": {
>             "category": {
>               "query": "books",
>               "operator": "or",
>               "boost": 2
>             }
>           }
>         }
>       ],
>       "should": [
>         {
>           "match_phrase_prefix": {
>             "title": {
>               "query": "3rd generation intel Xeon",
>               "slop": 10,
>               "boost": 3
>             }
>           }
>         },
>         {
>           "match_phrase_prefix": {
>             "description": {
>               "query": "3rd generation intel Xeon",
>               "slop": 10,
>               "boost": 0.5
>             }
>           }
>         },
>         {
>           "match_phrase_prefix": {
>             "tag": {
>               "query": "3rd generation intel Xeon",
>               "slop": 10,
>               "boost": 2
>             }
>           }
>         }
>       ],
>       "must_not": [
>         {
>           "term": {
>             "ndacontent": "1"
>           }
>         }
>       ],
>       "filter": []
>     }
>   }
> }
> },
>   "aggs": {
> "associated": {
>   "nested": {
>     "path": "associated"
>   },"sort":[  
>   {  
> 	 "updatedDate":{  
> 		"order":"desc"
> 		 }
>  }
>   ],  "aggs": {
>     "associated_name": {
>       "terms": {
>         "field": "associated.id.keyword",
>         "size": 1000
>       }
>     }
>   }
> }
> }
> }

Any help that could appreciate

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