Result in exact order


(Arul Sudarsanam) #1

Hi,

I have some issues when fetching the results.

I want the result to be order exact as i give

{
    "query": {
        "bool": {
            "should": [{
                "match": {
                    "movie_id": "127"
                }
            }, {
                "match": {
                    "movie_id": "111"
                }
            }, {
                "match": {
                    "movie_id": "131"
                }
            }, {
                "match": {
                    "movie_id": "106"
                }
            }]
        }
    }
}

i want it to be order in that exact order, but i am getting it in asc order even though i havent given any sort

i want it in the order 124,111,131,106

what is that i am missing


(Nik Everett) #2

Right now you are asking for all four documents in order sorted by score but your query doesn't provide useful scores. If you had a full text query in there then you'd get a useful score. You could try boost to get them in a particular order:

{
    "query": {
        "bool": {
            "should": [{
                "match": {
                    "movie_id": "127", "boost": 4
                }
            }, {
                "match": {
                    "movie_id": "111", "boost": 3
                }
            }, {
                "match": {
                    "movie_id": "131", "boost": 2
                }
            }, {
                "match": {
                    "movie_id": "106", "boost": 1
                }
            }]
        }
    }
}

(Arul Sudarsanam) #3

hi, thanks for your reply,

but when i give boost, i am not fetching any result at all.. can you tell me how can i use score to get my desired result.


(system) #4