Hi all,
How can I tune this query so that the 4th result (see below) which matches on both words ('A61' & 'roundabout') appears first in the list? Or is there a better way to query for this altogether (note the mapping at the bottom of the post)?
_search query
{
"from": 0,
"size": 10,
"highlight": {
... stripped for brevity ...
}
},
"_source": {
"excludes": [
"*"
]
},
"query": {
"bool": {
"should": [
{
"multi_match": {
"type": "best_fields",
"query": "a61 roundabout",
"fields": [
"code",
"code.standard",
"name",
"notes",
"notes.english",
"shortName"
]
}
},
{
"nested": {
"query": {
"multi_match": {
"type": "best_fields",
"query": "a61 roundabout",
"fields": [
"screenData.valueString",
"screenData.valueString.english"
]
}
},
"path": "screenData"
}
}
],
"minimum_should_match": 1
}
}
}
_search results
{
"took": 16,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 5,
"max_score": 8.464119,
"hits": [
{
"_index": "matters",
"_type": "matter",
"_id": "71",
"_score": 8.464119,
"_source": {},
"highlight": {
"screenData.valueString": [
"<mark>A61</mark>"
],
"screenData.valueString.english": [
"<mark>A61</mark>"
]
}
},
{
"_index": "matters",
"_type": "matter",
"_id": "14",
"_score": 7.368354,
"_source": {},
"highlight": {
"screenData.valueString": [
"Lawnswood <mark>Roundabout</mark>"
],
"screenData.valueString.english": [
"Lawnswood <mark>Roundabout</mark>"
]
}
},
{
"_index": "matters",
"_type": "matter",
"_id": "62",
"_score": 6.31734,
"_source": {},
"highlight": {
"screenData.valueString": [
"Meanwood <mark>Roundabout</mark>"
],
"screenData.valueString.english": [
"Meanwood <mark>Roundabout</mark>"
]
}
},
{
"_index": "matters",
"_type": "matter",
"_id": "59",
"_score": 5.680235,
"_source": {},
"highlight": {
"screenData.valueString": [
"<mark>A61</mark> direction Leeds, before the Leeds ring road <mark>roundabout</mark>."
],
"screenData.valueString.english": [
"<mark>A61</mark> direction Leeds, before the Leeds ring road <mark>roundabout</mark>."
]
}
},
{
"_index": "matters",
"_type": "matter",
"_id": "67",
"_score": 3.277606,
"_source": {},
"highlight": {
"screenData.valueString": [
"<mark>A61</mark> Harrogate Road, directions Leeds city centre"
],
"screenData.valueString.english": [
"<mark>A61</mark> Harrogate Road, directions Leeds city centre"
]
}
}
]
}
}
_mapping
{
"matters": {
"mappings": {
"matter": {
"dynamic": "false",
"date_detection": false,
"numeric_detection": false,
"properties": {
... stripped for brevity ...
"screenData": {
"type": "nested",
"dynamic": "false",
"properties": {
"fieldId": {
"type": "long"
},
"group": {
"type": "integer"
},
"isConfidential": {
"type": "boolean"
},
"matterTypeId": {
"type": "integer"
},
"screenId": {
"type": "long"
},
"systemId": {
"type": "integer"
},
"valueBool": {
"type": "boolean"
},
"valueDatetime": {
"type": "date"
},
"valueDouble": {
"type": "double"
},
"valueInt": {
"type": "long"
},
"valueString": {
"type": "text",
"fields": {
"english": {
"type": "text",
"analyzer": "english"
}
}
}
}
}
... stripped for brevity ...
}
}
}
}