php - How to search in elastic search having an array field?
one text
Solution:
Since you do not have the mapping for features and you are adding index data, so a default mapping is generated.
Try this below search query, this will return all the documents that contain features such as 'Satellite navigation' and 'Cruise control'
Search Query:
{
"query": {
"bool": {
"must": [
{
"match_phrase": {
"features": "Satellite Navigation"
}
},
{
"match_phrase": {
"features": "Cruise Control"
}
}
]
}
}
}
Search Result:
"hits": [
{
"_index": "my-index",
"_type": "_doc",
"_id": "1",
"_score": 1.7178956,
"_source": {
"features": [
"Anti-Lock Brakes",
"Alarm",
"Air Bag Driver",
"Cruise Control",
"Satellite Navigation"
]
Source