Hi
I have a text field with the type set to "search as you type". When I request data I get all data corresponding to BLAKER OR 288 in the street field.
( the street field contains the streetname + house number )
But how can I only get data corresponding to names starting with BLAKER AND house numbers starting with 288 ??
http://localhost:9200/xxx-2023.01/_search
{
"query": {
"multi_match": {
"query": "BLAKER 288",
"type": "bool_prefix",
"fields": [
"street",
"street._2gram",
"street._3gram"
]
}
}
}
I get results like the one below
"hits": [
{
"_index": "tds-address-2023.01",
"_type": "_doc",
"_id": "O10peIUBAPhS0x2BjjMG",
"_score": 1.0,
"_source": {
"@timestamp": "2023-01-03T16:04:26.9587963+01:00",
"level": "Information",
"centralcode": null,
"area1": {
"number": "30",
"name": "VIKEN"
},
"area2": {
"number": "3030",
"name": "LILLESTRØM"
},
"area3": {
"number": "",
"name": ""
},
"post": {
"number": "1925",
"name": "BLAKER"
},
"city": "BLAKER",
"street": "BLAKERVEIEN 288A",
"location": "u68j2b"
}
},
{
"_index": "tds-address-2023.01",
"_type": "_doc",
"_id": "sV0peIUBAPhS0x2BkTi3",
"_score": 1.0,
"_source": {
"@timestamp": "2023-01-03T16:04:27.4872962+01:00",
"level": "Information",
"centralcode": null,
"area1": {
"number": "30",
"name": "VIKEN"
},
"area2": {
"number": "3030",
"name": "LILLESTRØM"
},
"area3": {
"number": "",
"name": ""
},
"post": {
"number": "1925",
"name": "BLAKER"
},
"city": "BLAKER",
"street": "FJUKVEIEN 288",
"location": "u68j6f"
}
},
{
"_index": "tds-address-2023.01",
"_type": "_doc",
"_id": "-l0peIUBAPhS0x2BqF6x",
"_score": 1.0,
"_source": {
"@timestamp": "2023-01-03T16:04:32.9391556+01:00",
"level": "Information",
"centralcode": null,
"area1": {
"number": "18",
"name": "NORDLAND"
},
"area2": {
"number": "1838",
"name": "GILDESKÅL"
},
"area3": {
"number": "",
"name": ""
},
"post": {
"number": "8130",
"name": "SANDHORNØY"
},
"city": "SANDHORNØY",
"street": "SANDHORNØYVEIEN 288",
"location": "u7fjcp"
}
},
{
"_index": "tds-address-2023.01",
"_type": "_doc",
"_id": "z10peIUBAPhS0x2Brm38",
"_score": 1.0,
"_source": {
"@timestamp": "2023-01-03T16:04:35.2106261+01:00",
"level": "Information",
"centralcode": null,
"area1": {
"number": "18",
"name": "NORDLAND"
},
"area2": {
"number": "1875",
"name": "HÁBMER"
},
"area3": {
"number": "",
"name": ""
},
"post": {
"number": "8294",
"name": "HAMARØY"
},
"city": "HAMARØY",
"street": "BUVÅGVEIEN 288",
"location": "uk5583"
}
},
{
"_index": "tds-address-2023.01",
"_type": "_doc",
"_id": "cV0peIUBAPhS0x2BvoEI",
"_score": 1.0,
"_source": {
"@timestamp": "2023-01-03T16:04:38.0302645+01:00",
"level": "Information",
"centralcode": null,
"area1": {
"number": "30",
"name": "VIKEN"
},
"area2": {
"number": "3003",
"name": "SARPSBORG"
},
"area3": {
"number": "",
"name": ""
},
"post": {
"number": "1747",
"name": "SKJEBERG"
},
"city": "SKJEBERG",
"street": "GRESSDALVEIEN 288",
"location": "u4xbw6"
}
},
I wanted only the first with BLAKERVEIEN 288A.
When I use the and operator it gives no results.
http://localhost:9200/xxx-2023.01/_search
{
"query": {
"multi_match": {
"query": "BLAKER 288",
"operator": "and",
"type": "bool_prefix",
"fields": [
"street",
"street._2gram",
"street._3gram"
]
}
}
}
Any help on this ?
Regards