Is it possible to query elasticsearch such that it follows two queries?
For example, if I have the following,
[{
"items": [
{
"color" : "blue",
"shape" : "circle",
},{
"color" : "yellow",
"shape" : "square",
},{
"color" : "yellow",
"shape" : "square",
}
},{
"items": [
{
"color" : "blue",
"shape" : "triangle",
},{
"color" : "pink",
"shape" : "circle",
},{
"color" : "red",
"shape" : "circle",
}
},{
"items": [
{
"color" : "red",
"shape" : "rectangle",
},{
"color" : "blue",
"shape" : "circle",
},{
"color" : "purple",
"shape" : "oval",
}
}]
and I want to search for items only with color (blue) AND shape (circle). Only the first and third should be returned. Therefore, the response should be
[{
"items": [
{
"color" : "blue",
"shape" : "circle",
},{
"color" : "yellow",
"shape" : "square",
},{
"color" : "yellow",
"shape" : "square",
}
},
{
"items": [
{
"color" : "red",
"shape" : "rectangle",
},{
"color" : "blue",
"shape" : "circle",
},{
"color" : "purple",
"shape" : "oval",
}
}]
However, currently if I use the call below, all entries would be returned since they all have color:blue and shape:circle.
{
"query": {
"query_string": {
"query": "color:blue AND shape:circle"
}
}
}
(but I need both to be contained together as one item)... Is this possible with Elasticsearch?