Suppose I have the following document:
record 1:
{
"name": "A Regular Book",
"tags": [{ "name": "free-shipping" }, { "name": "summer-sale" }],
"information": [
{ "key": "school_name", "value": "Berkley bobs", "country": "USA" },
{ "key": "school_name", "value": "Stanford summer", "country": "USA" },
{ "key": "id", "value": "1234", "country": "USA" },
{ "key": "id", "value": "2345", "country": "USA" }
]
}
record 2:
{
"name": "A Regular Book 2",
"tags": [{ "name": "free-shipping" }, { "name": "summer-sale" }],
"information": [
{ "key": "school_name", "value": "Stanford summer", "country": "USA" },
{ "key": "school_name", "value": "Berkley bubbles", "country": "USA" },
{ "key": "id", "value": "1234", "country": "USA" },
{ "key": "id", "value": "2345", "country": "USA" }
]
}
And I am trying to do fuzzy search on one of the nested fields "key" how shall I approach it?
{
"query": {
"bool": {
"must": [
{
"term": {
"information.key": {
"value": "school_name",
}
}
},
]
},
"fuzzy": {
"information.value": {
"value": variable_to_be_fuzzy_searched,
}
}
}
}
How shall I do fuzzy search in such a way on the key field where key=school_name and it's value can be fuzzy search - variable_to_be_fuzzy_searched = Ber would return records 1&2 with this-> Berkley bobs, Berkley bubbles.
any hints will be appreciated :)
information.key= "school_name"andinformation.valuebeginning withBer. Is this correct ?