I am using elastic search version 2.x. And I have two records which are indexed as:
- bathroom wall tile (as "nickname" indexed document column)
- tile wall bathroom (as "nickname" indexed document column)
When I am trying to search for phrase "tile wall bathroom" ideally second should appear first because that is exact match and after that first will appear because all the 3 words matches(tile, wall and bathroom).
I put sorting in my query based on columns. Below is my elastic search query:
{
"query" : {
"filtered" : {
"query" : {
"query_string": {
"query": "*tile wall bathroom*",
"fields": [
"nickname",
"comments",
"category_name",
"subcategory_name",
"document_name",
"web_links",
"document_extension",
"property_name",
"document_content"
],
"analyze_wildcard": true
}
},
"filter" : {
"and" : [
{"term" : {"property_id" : "6"}}
]
}
}
},
"size": 10,
"sort": ["nickname", "comments", "web_links", "document_name"]
}
For reference please find attached image.
Thanks in advance!!!