I'm performing a rank_feature query and there is a possibility that the fields that I will rank i.e bid field (please below) won't be available.
I wonder if there is a way to set a default for bid if the field is not present.
For example, here is my document mapping
PUT /tier-sort-2
{
"mappings": {
"properties": {
"popularity_scores": {
"type": "nested",
"properties": {
"score": {
"type": "rank_feature"
},
"study_field": {
"type": "text"
}
}
},
"bid": {
"type": "rank_feature"
}
}
}
}
Here are my test documents:
POST _bulk
{"index":{"_index":"tier-sort","_id":"1"}}
{"title":"Job 1","popularity_scores":{"score":"0.105", "study_field":"45"}}
{"index":{"_index":"tier-sort","_id":"2"}}
{"title":"Job 2","popularity_scores":{"score":"0.06", "study_field":"45"},"bid":"50"}
{"index":{"_index":"tier-sort","_id":"3"}}
{"title":"Job 3","popularity_scores":{"score":"0.099", "study_field":"45"},"bid":"25"}
{"index":{"_index":"tier-sort","_id":"4"}}
{"title":"Job 4","popularity_scores":{"score":"0.155", "study_field":"45"},"bid":"5"}
{"index":{"_index":"tier-sort","_id":"5"}}
{"title":"Job 5","popularity_scores":{"score":"0.028", "study_field":"45"},"bid":"100"}
Here is my query:
GET tier-sort/_search
{
"size": 100,
"query": {
"bool": {
"should": [
{
"nested": {
"path": "popularity_scores",
"query": {
"rank_feature": {
"field": "popularity_scores.score",
"boost": 1
}
}
}
},
{
"rank_feature": {
"field": "bid",
"boost": 1
}
}
]
}
}
}
As you can see, for document with _job="1", the bid field is no present.
Is there a way to set a default value that field i.e bid="50"
Thanks in advance!