Reputation: 245
Hi i'm elasticsearch newbie and i have troubles with a query. I have data's as
{
"user_id": "1",
"date": "141462121",
"name": "John",
"surname": "Doe"
"activity": [
{
"type": [
"Outdoor",
"Extreme"
],
"name": "Example",
"price": {
"value": 50,
"currency": "USD"
}
}
]
"searchs": ""
}
},
{
"user_id": "2",
"date": "141462121",
"name": "Jane",
"surname": "Doe"
"activity": [
{
"type": [
"Indoor"
],
"name": "Example2",
"price": {
"value": 100,
"currency": "USD"
}
},
{
"type": [
"Outdoor"
],
"name": "Example3",
"price": {
"value": 25,
"currency": "USD"
}
}
]
"searchs": ""
}
}
and i want to search these datas by activity type. i tried nested queries like
"query": {
"nested": {
"path": "activity",
"query": {
"bool": {
"must": [
{"match": {
"activity.type": "outdoor"
}}
]
}
}
}
and like
"query": {
"nested": {
"path": "activity",
"query": {
"nested": {
"path": "type",
"query": {
"bool": {
"must": [
{"match": {
"type.value": "outdoor"
}}
]
}
}
}
}
}
}
but i couldn't succeed.
How can i search these datas by activity type?
Upvotes: 0
Views: 269
Reputation: 128
You can use a simple match query if you're just looking for records with an activity type like
{
"query": {
"match": {
"activity.type": "Outdoor"
}
}
}
Upvotes: 1