Sorting based on boost factor


(SG) #1

Hi,

I have created a search collection with the below boost factor:

{"content_collection"=>{"album"=>{"properties"=>{"title"=>{"type"=>"string"},
"track_titles"=>{"boost"=>2.0, "type"=>"string"},
"artists_names"=>{"boost"=>3.0, "type"=>"string"}}}}}

Tried to search using :
curl 'http://localhost:9200/content_collection/album/_search' -d '
{
"query" : {
"dis_max" : {
"queries" : [
{
"field" : { "artists_names" : { "query" : " Tetsu
utitled club", "boost" : 3.0}}
},
{
"field" : { "track_titles" : { "query" : "Tetsu
untitled club", "boost" : 2.0}}
},
{
"field" : { "title" : { "query" : "Tetsu untitled
club", "boost" : 1.0}}
}
]
}
}
}
'
Requirement is that the search result should order according to the
boost factor. If the search text is brain: Then it should search for
all the three fields with the search string and should respond with
the order of boost.
So the records which matches with the artist_names should appear first
followed by the records which matches against the track_titles and
title. But it is coming in some other sequence and not considering the
boost factor.

Thanks!


(SG) #2

I have accomplished with the following search:
curl 'http://localhost:9200/content_collection/album/_search' -d '
{
"query" : {
"dis_max" : {
"queries" : [
{
"constant_score" : {
"query" : {
"text" : { "artists_names" : "Tetsu untitled club"}
},
"boost" : 3.0
}
},
{
"constant_score" : {
"query" : {
"text" : { "track_titles" : "Tetsu untitled club"}
},
"boost" : 2.0
}

        },
        {
          "constant_score" : {
            "query" : {
              "text" : { "title" : "Tetsu untitled club"}
              },
             "boost" : 1.0
          }

        }
    ]
}

}
}

Please provide me the better solution if the given solution is not the exact one.

Thanks!


(system) #3