My json is below
- I have to match first from sports
- In that i need to extract search string
- The issue is i am getting score 1.0 for every document
[{'id':1, 'name': 'christiano ronaldo', 'description': 'football@football.com', 'type': 'football', 'var':'sports'},
{'id':2, 'name': 'lionel messi', 'description': 'messi@fifa.com','type': 'soccer','var':'sports'},
{'id':3, 'name': 'sachin', 'description': 'was', 'type': 'cricket', 'var':'sports'}]
My dsl query is below
{
"query": {
"bool": {
"must": [
{
"terms": {
"var.keyword": [
"sports"
]
}
}
],
"filter": {
"query_string": {
"query": "sachin* OR messi",
"fields": [
"name^1024",
"description^32"
]
}
}
}
}
}
My out
{'took': 911,
'timed_out': False,
'_shards': {'total': 1, 'successful': 1, 'skipped': 0, 'failed': 0},
'hits': {'total': {'value': 2, 'relation': 'eq'},
'max_score': 1.0,
'hits': [{'_index': 'newtestplayer',
'_type': '_doc',
'_id': '2',
'_score': 1.0,
'_source': {'id': 2,
'name': 'lionel messi',
'description': 'messi@fifa.com',
'type': 'soccer',
'var': 'sports'}},
{'_index': 'newtestplayer',
'_type': '_doc',
'_id': '3',
'_score': 1.0,
'_source': {'id': 3,
'name': 'sachin',
'description': 'was',
'type': 'cricket',
'var': 'sports'}}]}}
You can see my score is '_score':1.0
for every where. How to change that it will be according to Fields
which i mentioned