I have the user index with the following mappings:
user:{
properties:{
tags: {
type: "nested",
properties: {
type: {type: "string"}
value: {type: "string"}
}
}
}
}
And I want to search for the ES document with the following values:
user : {
tags: [
{
type: "joining_year", value: "2001"
},
{
type: "company", value: "Google"
},
{
type: "college", value: "daiict"
}
]
}
What will be my ES query? I can used nested query to find a single tag
having specific values. But when there are multiple nested tag documents, I
don't know how to query them.
Thanks,
Aash
--
After some tries, here the query that fetches the results:
filtered:{
query: {match_all: {}},
filter: {and: [
{nested: {path: "tags", query: {bool: {must: [{term: {"tags.type"
=> "joining_year"}}, {term: {"tags.value" => "2001"}}]}}}}
{nested: {path: "tags", query: {bool: {must: [{term: {"tags.type"
=> "company"}}, {term: {"tags.value" => "Google"}}]}}}}
]}
}
On Sat, Jan 5, 2013 at 11:19 AM, aash dhariya aash.discover@gmail.comwrote:
I have the user index with the following mappings:
user:{
properties:{
tags: {
type: "nested",
properties: {
type: {type: "string"}
value: {type: "string"}
}
}
}
}
And I want to search for the ES document with the following values:
user : {
tags: [
{
type: "joining_year", value: "2001"
},
{
type: "company", value: "Google"
},
{
type: "college", value: "daiict"
}
]
}
What will be my ES query? I can used nested query to find a single tag
having specific values. But when there are multiple nested tag documents, I
don't know how to query them.
Thanks,
Aash
--
Thanks,
Aash
--