When i am trying to add boost for multiple queries :
POST /new_master_query/_search
{
"query": {
"match" : {
"title": {
"query": "test",
"boost": 2
},
"object_summary":{
"query":"Test",
"boost": 1
}
}
}
}
but i am getting an error:
"error": {
"root_cause": [
{
"type": "parsing_exception",
"reason": "[match] query doesn't support multiple fields, found [title] and [object_summary]",
"line": 8,
"col": 30
}
I do not want to add query parameter. In above example query is present. I only want to add different boost to different fields. for example: for title, value for boost is 3, for object_summary it is 2 and so on. Can this is possible?
My requirement is when user searches any term or word, depending upon boost number of fields it should display the results.
For example, if user searches for “Test” and title has boost value as 2 and object_summary has boost value as 1, then according to boost number more weightage should be given to title (as it has max boost value). And user will get the proper results. That means it should first search in title field and then in object_sumary.
Is this possible using boost? If not what exactly boost does?
If you still don't make it work, could you provide a full recreation script as described in About the Elasticsearch category. It will help to better understand what you are doing. Please, try to keep the example as simple as possible.
A full reproduction script will help readers to understand, reproduce and if needed fix your problem. It will also most likely help to get a faster answer.
I am getting what you are trying to say. Still I have one doubt, in below example, I have used 2 fields “title" and "object_summary and boost value is 2. So when user searches they will get results by applying boost value as 2 for both fields.
GET new_master_query/_search
{
"query": {
"multi_match" : {
"query": "this is a test",
"fields": [ "title", "object_summary" ] ,
"boost":2
}
}
}
What if I want to give boost value 2 to title and 1 to object_summary? Or is it assumed that if we have provided multiple fields then boost value for title is 2 and object_summary is 1?
As mentioned in above example, 2 is representing boost value for title. And that means when any user searches , first it will give preference to title and then to object _summary and will show the results. Correct me if I am wrong.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.