Reputation: 5445
Sample document in elasticsearch
{
"name": "Tom",
"hobbies": [
{
"hobby": "go for a walk"
},
{
"hobby": "board games"
}
]
}
How can I get all person who's hobby contains "walk" or "game(s)"?
Upvotes: 1
Views: 795
Reputation: 1727
Array Field Index This reference will give you more clarity about the Array fields index process.
To enable the full text search in an array you need to specify the path
foe the search array fields
in your case the path is hobbies.hobby
.
As you want to enable the search for game
& games
you need to specify the stem
analyzer[snowball
] to achieve the language search.
Upvotes: 2
Reputation: 19514
You need to specify path to it
POST indexName/_search
{
"query": {"terms": {
"hobbies.hobby": [
"walk",
"games"
]
}}
}
Upvotes: 0