As I said, take a look at function score query. It allows to replace internal score.
curl -s -XDELETE "http://localhost:9200/test_index"
curl -s -XPUT "http://localhost:9200/test_index" -d '
{
"settings": {
"index": {
"number_of_shards": 1,
"number_of_replicas": 0,
"similarity": {
"default": {
"type": "classic"
}
}
}
}
}
'
curl -XPUT 'localhost:9200/test_index/test_type/_mapping' -d '
{
"test_type": {
"properties": {
"field1": {
"type": "text"
},
"field2": {
"type": "text"
}
}
}
}
'
curl -s -XPUT "localhost:9200/test_index/test_type/1" -d '
{"field1" : "bar foo", "field2" : "bar"}
'
curl -s -XPUT "localhost:9200/test_index/test_type/2" -d '
{"field1" : "bar bar bar", "field2" : "foo foo foo"}
'
curl -s -XPUT "localhost:9200/test_index/test_type/3" -d '
{"field1" : "bar bar foo foo", "field2" : "bar bar foo foo"}
'
curl -s -XPOST "http://localhost:9200/test_index/_refresh"
echo
echo
echo 'expecting doc 3 to have score 7.0'
curl -s "localhost:9200/test_index/test_type/_search?pretty=true" -d '
{
"explain": false,
"query": {
"bool": {
"disable_coord": true,
"should": [
{
"function_score": {
"boost": "1.0",
"weight": "2.0",
"boost_mode": "replace",
"query": {
"bool": {
"filter": {
"match": {
"field1": {
"query": "foo"
}
}
}
}
}
}
},
{
"function_score": {
"boost": "1.0",
"weight": "5.0",
"boost_mode": "replace",
"query": {
"bool": {
"filter": {
"match": {
"field2": {
"query": "foo"
}
}
}
}
}
}
}
]
}
}
}
'