I was trying to do a simple POC for related items using the elasticsearch's http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-mlt-query.html#query-dsl-mlt-query,
But I was not getting how to use the boosting so that the important fields in my document carry more weight in the final output. Also how can I apply a boost in more like this query such that the recent documents carry more weight.
Thanks.
One way to achieve specific boosts if a document is more like a particular doc or if the match is on particular field you can use multiple mlt queries and wrap them in a should clause(bool)/dis_max based on whether you want "sum of"/"max of" logic while scoring:
Example using dis_max would be :
POST test_index/_search?explain=true
{
"fields": [
"field1",
"field2"
],
"query": {
"dis_max": {
"queries": [
{
"more_like_this" : {
"fields" : ["field1"],
"like_text" : "this is some text",
"min_term_freq" : 1,
"max_query_terms" : 2,
"boost": 20
}
},
{
"more_like_this" : {
"fields" : ["field2"],
"like_text" : "this is some other text",
"min_term_freq" : 1,
"max_query_terms" : 2,
"boost": 20
}
}
]
}
}
}