# Does nested query with operator honor the operator or does it always display some default behavior

**URL:** <https://discuss.elastic.co/t/does-nested-query-with-operator-honor-the-operator-or-does-it-always-display-some-default-behavior/20814>\
**Category:** Elasticsearch\
**Created:** [November 18, 2014, 3:23pm UTC](https://discuss.elastic.co/t/does-nested-query-with-operator-honor-the-operator-or-does-it-always-display-some-default-behavior/20814 "2014-11-18T15:23:38Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ramdev\_Wudali](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ramdev_wudali/32/7894_2.png) [@Ramdev\_Wudali](https://discuss.elastic.co/u/Ramdev_Wudali)\
**Post date:** [November 18, 2014, 3:23pm UTC](https://discuss.elastic.co/t/does-nested-query-with-operator-honor-the-operator-or-does-it-always-display-some-default-behavior/20814/1 "2014-11-18T15:23:38Z")

</div>

Hi :  
I have the following query :  
{  
"query": {  
"bool": {  
"must": {  
"nested": {  
"query": {  
"bool": {  
"must": [  
{  
"match": {  
"NESTED\_FIELD.v": {  
"query": ["AAPL.OQ", "GOOGL.OQ"],  
"operator": "and"

```
                }
              }
            },
            {
              "range": {
                "NESTED_FIELD.s": {
                  "from": 0.6,
                  "to": null,
                  "include_lower": true,
                  "include_upper": true
                }
              }
            }
          ]
        }
      },
      "path": "NESTED_FIELD"
    }
  }
}

```

},  
"filter": {  
"bool": {  
"must": [  
{  
"range": {  
"DOC\_DATE.v": {  
"from": "2014-08-19T20:00:00.000-04:00",  
"to": "2014-10-18T23:59:59.999Z",  
"include\_lower": true,  
"include\_upper": true  
}  
}  
}  
]  
}  
}  
}

The behavior I expect is the following :

In the documents that are returned, they should contain both values for  
the NESTED\_FIELD.v (AAPL.OQ and GOOG.OQ) that satisfy the condition where  
their corresponding NESTED\_FIELD.v range also is satisfied.

The behavior I see :  
the documents returned contain either one of the values (as in its got  
AAPL.OQ (OR) GOOG.OQ (OR) Both.

I want documents that only have both the values. So the "operator" :"and"  
(and its variant "operator":"AND") does not seem to have any effect.  
any pointers suggestions regarding this is much appreciated. I am using the  
JAVA API to construct my queries. (but I do not think it should matter)

Thanks

Ramdev

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/c07cc19b-9ff1-4074-b79c-1861afb7e866%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/c07cc19b-9ff1-4074-b79c-1861afb7e866%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [November 18, 2014, 8:45pm UTC](https://discuss.elastic.co/t/does-nested-query-with-operator-honor-the-operator-or-does-it-always-display-some-default-behavior/20814/2 "2014-11-18T20:45:44Z")

</div>

I have never seen the array syntax with the match query, so I am not sure  
what the behavior should be. Since your search terms are not analyzed in  
your example, a terms query with a minimum match of 100% should work. If  
not, perhaps creating a single search term of your existing terms?

--  
Ivan

On Tue, Nov 18, 2014 at 10:23 AM, Ramdev Wudali [agastya71@gmail.com](mailto:agastya71@gmail.com) wrote:

> Hi :  
> I have the following query :  
> {  
> "query": {  
> "bool": {  
> "must": {  
> "nested": {  
> "query": {  
> "bool": {  
> "must": [  
> {  
> "match": {  
> "NESTED\_FIELD.v": {  
> "query": ["AAPL.OQ", "GOOGL.OQ"],  
> "operator": "and"
> 
> ```
> }
> }
> },
> {
> "range": {
> "NESTED_FIELD.s": {
> "from": 0.6,
> "to": null,
> "include_lower": true,
> "include_upper": true
> }
> }
> }
> ]
> }
> },
> "path": "NESTED_FIELD"
> }
> }
> }
> 
> ```
> 
> },  
> "filter": {  
> "bool": {  
> "must": [  
> {  
> "range": {  
> "DOC\_DATE.v": {  
> "from": "2014-08-19T20:00:00.000-04:00",  
> "to": "2014-10-18T23:59:59.999Z",  
> "include\_lower": true,  
> "include\_upper": true  
> }  
> }  
> }  
> ]  
> }  
> }  
> }
> 
> The behavior I expect is the following :
> 
> In the documents that are returned, they should contain both values for  
> the NESTED\_FIELD.v (AAPL.OQ and GOOG.OQ) that satisfy the condition where  
> their corresponding NESTED\_FIELD.v range also is satisfied.
> 
> The behavior I see :  
> the documents returned contain either one of the values (as in its got  
> AAPL.OQ (OR) GOOG.OQ (OR) Both.
> 
> I want documents that only have both the values. So the "operator" :"and"  
> (and its variant "operator":"AND") does not seem to have any effect.  
> any pointers suggestions regarding this is much appreciated. I am using  
> the JAVA API to construct my queries. (but I do not think it should matter)
> 
> Thanks
> 
> Ramdev
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/c07cc19b-9ff1-4074-b79c-1861afb7e866%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/c07cc19b-9ff1-4074-b79c-1861afb7e866%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/c07cc19b-9ff1-4074-b79c-1861afb7e866%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/c07cc19b-9ff1-4074-b79c-1861afb7e866%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQDwgN1Ja2EBjyp2\_eZs29h6cb1iZ55CCU0DRjXiEzY5%3Dg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQDwgN1Ja2EBjyp2_eZs29h6cb1iZ55CCU0DRjXiEzY5%3Dg%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Ramdev\_Wudali](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ramdev_wudali/32/7894_2.png) [@Ramdev\_Wudali](https://discuss.elastic.co/u/Ramdev_Wudali)\
**Post date:** [November 19, 2014, 3:24pm UTC](https://discuss.elastic.co/t/does-nested-query-with-operator-honor-the-operator-or-does-it-always-display-some-default-behavior/20814/3 "2014-11-19T15:24:15Z")

</div>

The fields (I am searching against) are analyzed, by the default analyzer.  
The query as you I noted in my question was generated by using the JAVA  
API, So the array syntax is generated by the API's interpretation. That  
said, I ran a few more experiments. If the field were not analyzed (unlike  
my non experiment case), The query function works and returns the right  
documents. (meaning where both the values exist) in the returned documents.  
But if they are analyzed, the operator is not honored.

So now my question is, why would not analyzed fields cause the operator to  
be honored ?  
and Does the operator field within a nested query depend on if the field in  
the nested field is actually analyzed or not. ?

Ramdev

On Tuesday, 18 November 2014 14:45:53 UTC-6, Ivan Brusic wrote:

> I have never seen the array syntax with the match query, so I am not sure  
> what the behavior should be. Since your search terms are not analyzed in  
> your example, a terms query with a minimum match of 100% should work. If  
> not, perhaps creating a single search term of your existing terms?
> 
> --  
> Ivan
> 
> On Tue, Nov 18, 2014 at 10:23 AM, Ramdev Wudali \<[agas...@gmail.com](mailto:agas...@gmail.com)  
> \<javascript:\>\> wrote:
> 
> > Hi :  
> > I have the following query :  
> > {  
> > "query": {  
> > "bool": {  
> > "must": {  
> > "nested": {  
> > "query": {  
> > "bool": {  
> > "must": [  
> > {  
> > "match": {  
> > "NESTED\_FIELD.v": {  
> > "query": ["AAPL.OQ", "GOOGL.OQ"],  
> > "operator": "and"
> > 
> > ```
> > }
> > }
> > },
> > {
> > "range": {
> > "NESTED_FIELD.s": {
> > "from": 0.6,
> > "to": null,
> > "include_lower": true,
> > "include_upper": true
> > }
> > }
> > }
> > ]
> > }
> > },
> > "path": "NESTED_FIELD"
> > }
> > }
> > }
> > 
> > ```
> > 
> > },  
> > "filter": {  
> > "bool": {  
> > "must": [  
> > {  
> > "range": {  
> > "DOC\_DATE.v": {  
> > "from": "2014-08-19T20:00:00.000-04:00",  
> > "to": "2014-10-18T23:59:59.999Z",  
> > "include\_lower": true,  
> > "include\_upper": true  
> > }  
> > }  
> > }  
> > ]  
> > }  
> > }  
> > }
> > 
> > The behavior I expect is the following :
> > 
> > In the documents that are returned, they should contain both values for  
> > the NESTED\_FIELD.v (AAPL.OQ and GOOG.OQ) that satisfy the condition where  
> > their corresponding NESTED\_FIELD.v range also is satisfied.
> > 
> > The behavior I see :  
> > the documents returned contain either one of the values (as in its got  
> > AAPL.OQ (OR) GOOG.OQ (OR) Both.
> > 
> > I want documents that only have both the values. So the "operator" :"and"  
> > (and its variant "operator":"AND") does not seem to have any effect.  
> > any pointers suggestions regarding this is much appreciated. I am using  
> > the JAVA API to construct my queries. (but I do not think it should matter)
> > 
> > Thanks
> > 
> > Ramdev
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/c07cc19b-9ff1-4074-b79c-1861afb7e866%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/c07cc19b-9ff1-4074-b79c-1861afb7e866%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/c07cc19b-9ff1-4074-b79c-1861afb7e866%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/c07cc19b-9ff1-4074-b79c-1861afb7e866%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/20a3c1d1-e2cc-44a5-affe-5b30777bcc8d%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/20a3c1d1-e2cc-44a5-affe-5b30777bcc8d%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [November 19, 2014, 8:13pm UTC](https://discuss.elastic.co/t/does-nested-query-with-operator-honor-the-operator-or-does-it-always-display-some-default-behavior/20814/4 "2014-11-19T20:13:34Z")

</div>

As mentioned before, that syntax seems strange to me. I have never seen an  
array used with a match query. I wonder what the resulting Lucene query is.  
I think that analyzed/non-analyzed just might be a red herring. What does  
the explanation output say?

--  
Ivan

On Wed, Nov 19, 2014 at 10:24 AM, Ramdev Wudali [agastya71@gmail.com](mailto:agastya71@gmail.com) wrote:

> The fields (I am searching against) are analyzed, by the default analyzer.  
> The query as you I noted in my question was generated by using the JAVA  
> API, So the array syntax is generated by the API's interpretation. That  
> said, I ran a few more experiments. If the field were not analyzed (unlike  
> my non experiment case), The query function works and returns the right  
> documents. (meaning where both the values exist) in the returned  
> documents. But if they are analyzed, the operator is not honored.
> 
> So now my question is, why would not analyzed fields cause the operator  
> to be honored ?  
> and Does the operator field within a nested query depend on if the field  
> in the nested field is actually analyzed or not. ?
> 
> Ramdev
> 
> On Tuesday, 18 November 2014 14:45:53 UTC-6, Ivan Brusic wrote:
> 
> > I have never seen the array syntax with the match query, so I am not sure  
> > what the behavior should be. Since your search terms are not analyzed in  
> > your example, a terms query with a minimum match of 100% should work. If  
> > not, perhaps creating a single search term of your existing terms?
> > 
> > --  
> > Ivan
> > 
> > On Tue, Nov 18, 2014 at 10:23 AM, Ramdev Wudali [agas...@gmail.com](mailto:agas...@gmail.com)  
> > wrote:
> > 
> > > Hi :  
> > > I have the following query :  
> > > {  
> > > "query": {  
> > > "bool": {  
> > > "must": {  
> > > "nested": {  
> > > "query": {  
> > > "bool": {  
> > > "must": [  
> > > {  
> > > "match": {  
> > > "NESTED\_FIELD.v": {  
> > > "query": ["AAPL.OQ", "GOOGL.OQ"],  
> > > "operator": "and"
> > > 
> > > ```
> > > }
> > > }
> > > },
> > > {
> > > "range": {
> > > "NESTED_FIELD.s": {
> > > "from": 0.6,
> > > "to": null,
> > > "include_lower": true,
> > > "include_upper": true
> > > }
> > > }
> > > }
> > > ]
> > > }
> > > },
> > > "path": "NESTED_FIELD"
> > > }
> > > }
> > > }
> > > 
> > > ```
> > > 
> > > },  
> > > "filter": {  
> > > "bool": {  
> > > "must": [  
> > > {  
> > > "range": {  
> > > "DOC\_DATE.v": {  
> > > "from": "2014-08-19T20:00:00.000-04:00",  
> > > "to": "2014-10-18T23:59:59.999Z",  
> > > "include\_lower": true,  
> > > "include\_upper": true  
> > > }  
> > > }  
> > > }  
> > > ]  
> > > }  
> > > }  
> > > }
> > > 
> > > The behavior I expect is the following :
> > > 
> > > In the documents that are returned, they should contain both values for  
> > > the NESTED\_FIELD.v (AAPL.OQ and GOOG.OQ) that satisfy the condition where  
> > > their corresponding NESTED\_FIELD.v range also is satisfied.
> > > 
> > > The behavior I see :  
> > > the documents returned contain either one of the values (as in its  
> > > got AAPL.OQ (OR) GOOG.OQ (OR) Both.
> > > 
> > > I want documents that only have both the values. So the "operator"  
> > > :"and" (and its variant "operator":"AND") does not seem to have any effect.  
> > > any pointers suggestions regarding this is much appreciated. I am using  
> > > the JAVA API to construct my queries. (but I do not think it should matter)
> > > 
> > > Thanks
> > > 
> > > Ramdev
> > > 
> > > --  
> > > You received this message because you are subscribed to the Google  
> > > Groups "elasticsearch" group.  
> > > To unsubscribe from this group and stop receiving emails from it, send  
> > > an email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > msgid/elasticsearch/c07cc19b-9ff1-4074-b79c-1861afb7e866%  
> > > [40googlegroups.com](http://40googlegroups.com)  
> > > [https://groups.google.com/d/msgid/elasticsearch/c07cc19b-9ff1-4074-b79c-1861afb7e866%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/c07cc19b-9ff1-4074-b79c-1861afb7e866%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > .  
> > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/20a3c1d1-e2cc-44a5-affe-5b30777bcc8d%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/20a3c1d1-e2cc-44a5-affe-5b30777bcc8d%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/20a3c1d1-e2cc-44a5-affe-5b30777bcc8d%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/20a3c1d1-e2cc-44a5-affe-5b30777bcc8d%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQANjUjEjCr%3D0jwf-UB5mEVmFUF8YsJUgVbpLQcEhFpgkQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQANjUjEjCr%3D0jwf-UB5mEVmFUF8YsJUgVbpLQcEhFpgkQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Ramdev\_Wudali](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ramdev_wudali/32/7894_2.png) [@Ramdev\_Wudali](https://discuss.elastic.co/u/Ramdev_Wudali)\
**Post date:** [November 20, 2014, 2:59pm UTC](https://discuss.elastic.co/t/does-nested-query-with-operator-honor-the-operator-or-does-it-always-display-some-default-behavior/20814/5 "2014-11-20T14:59:05Z")

</div>

Hi Ivan:  
I tried using the \_explain API (end point to get an explanation, it  
returned this :  
{  
"\_index": "news",  
"\_type": "swift",  
"\_id": "\_explain",  
"\_version": 5,  
"created": false  
}

I tried adding "explain":true as part of my query which resulted in this :  
"\_explanation": {  
"value": 10.384945,  
"description": "Score based on child doc range from 75103316  
to 75103366"  
}

That said, If you think the syntax is not familiar, How do you suggest the  
query be created ? ( of course, I could split the query into a boolean  
query with two MUST nested conditions) which does result in the documents I  
am looking for).  
However, If I have a list of more than 2 values to be seated for, the query  
becomes unseemly. The JAVA API does seem to allow for list of values to be  
passed in.. here is a code snippet for who I am using the JAVA API :

```
          qb = QueryBuilders.nestedQuery(fieldName, QueryBuilders.

```

boolQuery().  
must(QueryBuilders.  
matchQuery(fieldName + ".v", values).  
operator(  
MatchQueryBuilder.Operator.AND)).

must(QueryBuilders

```
            .rangeQuery(fieldName + ".s")
                                                                        
            .gte(0.6))

```

Where values is a List of values

please let me know if I am using the API incorrectly.

Thanks

Ramdev

On Wednesday, 19 November 2014 14:13:41 UTC-6, Ivan Brusic wrote:

> As mentioned before, that syntax seems strange to me. I have never seen an  
> array used with a match query. I wonder what the resulting Lucene query is.  
> I think that analyzed/non-analyzed just might be a red herring. What does  
> the explanation output say?
> 
> --  
> Ivan
> 
> On Wed, Nov 19, 2014 at 10:24 AM, Ramdev Wudali \<[agas...@gmail.com](mailto:agas...@gmail.com)  
> \<javascript:\>\> wrote:
> 
> > The fields (I am searching against) are analyzed, by the default  
> > analyzer.  
> > The query as you I noted in my question was generated by using the JAVA  
> > API, So the array syntax is generated by the API's interpretation. That  
> > said, I ran a few more experiments. If the field were not analyzed (unlike  
> > my non experiment case), The query function works and returns the right  
> > documents. (meaning where both the values exist) in the returned  
> > documents. But if they are analyzed, the operator is not honored.
> > 
> > So now my question is, why would not analyzed fields cause the operator  
> > to be honored ?  
> > and Does the operator field within a nested query depend on if the field  
> > in the nested field is actually analyzed or not. ?
> > 
> > Ramdev
> > 
> > On Tuesday, 18 November 2014 14:45:53 UTC-6, Ivan Brusic wrote:
> > 
> > > I have never seen the array syntax with the match query, so I am not  
> > > sure what the behavior should be. Since your search terms are not analyzed  
> > > in your example, a terms query with a minimum match of 100% should work. If  
> > > not, perhaps creating a single search term of your existing terms?
> > > 
> > > --  
> > > Ivan
> > > 
> > > On Tue, Nov 18, 2014 at 10:23 AM, Ramdev Wudali [agas...@gmail.com](mailto:agas...@gmail.com)  
> > > wrote:
> > > 
> > > > Hi :  
> > > > I have the following query :  
> > > > {  
> > > > "query": {  
> > > > "bool": {  
> > > > "must": {  
> > > > "nested": {  
> > > > "query": {  
> > > > "bool": {  
> > > > "must": [  
> > > > {  
> > > > "match": {  
> > > > "NESTED\_FIELD.v": {  
> > > > "query": ["AAPL.OQ", "GOOGL.OQ"],  
> > > > "operator": "and"
> > > > 
> > > > ```
> > > > }
> > > > }
> > > > },
> > > > {
> > > > "range": {
> > > > "NESTED_FIELD.s": {
> > > > "from": 0.6,
> > > > "to": null,
> > > > "include_lower": true,
> > > > "include_upper": true
> > > > }
> > > > }
> > > > }
> > > > ]
> > > > }
> > > > },
> > > > "path": "NESTED_FIELD"
> > > > }
> > > > }
> > > > }
> > > > 
> > > > ```
> > > > 
> > > > },  
> > > > "filter": {  
> > > > "bool": {  
> > > > "must": [  
> > > > {  
> > > > "range": {  
> > > > "DOC\_DATE.v": {  
> > > > "from": "2014-08-19T20:00:00.000-04:00",  
> > > > "to": "2014-10-18T23:59:59.999Z",  
> > > > "include\_lower": true,  
> > > > "include\_upper": true  
> > > > }  
> > > > }  
> > > > }  
> > > > ]  
> > > > }  
> > > > }  
> > > > }
> > > > 
> > > > The behavior I expect is the following :
> > > > 
> > > > In the documents that are returned, they should contain both values  
> > > > for the NESTED\_FIELD.v (AAPL.OQ and GOOG.OQ) that satisfy the condition  
> > > > where their corresponding NESTED\_FIELD.v range also is satisfied.
> > > > 
> > > > The behavior I see :  
> > > > the documents returned contain either one of the values (as in its  
> > > > got AAPL.OQ (OR) GOOG.OQ (OR) Both.
> > > > 
> > > > I want documents that only have both the values. So the "operator"  
> > > > :"and" (and its variant "operator":"AND") does not seem to have any effect.  
> > > > any pointers suggestions regarding this is much appreciated. I am using  
> > > > the JAVA API to construct my queries. (but I do not think it should matter)
> > > > 
> > > > Thanks
> > > > 
> > > > Ramdev
> > > > 
> > > > --  
> > > > You received this message because you are subscribed to the Google  
> > > > Groups "elasticsearch" group.  
> > > > To unsubscribe from this group and stop receiving emails from it, send  
> > > > an email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > msgid/elasticsearch/c07cc19b-9ff1-4074-b79c-1861afb7e866%  
> > > > [40googlegroups.com](http://40googlegroups.com)  
> > > > [https://groups.google.com/d/msgid/elasticsearch/c07cc19b-9ff1-4074-b79c-1861afb7e866%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/c07cc19b-9ff1-4074-b79c-1861afb7e866%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > > .  
> > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > 
> > > --  
> > > You received this message because you are subscribed to the Google Groups  
> > > "elasticsearch" group.  
> > > To unsubscribe from this group and stop receiving emails from it, send an  
> > > email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > > To view this discussion on the web visit  
> > > [https://groups.google.com/d/msgid/elasticsearch/20a3c1d1-e2cc-44a5-affe-5b30777bcc8d%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/20a3c1d1-e2cc-44a5-affe-5b30777bcc8d%40googlegroups.com)  
> > > [https://groups.google.com/d/msgid/elasticsearch/20a3c1d1-e2cc-44a5-affe-5b30777bcc8d%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/20a3c1d1-e2cc-44a5-affe-5b30777bcc8d%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > .
> > 
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/41fa2f25-a36d-49e6-b114-ce3c0f48d488%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/41fa2f25-a36d-49e6-b114-ce3c0f48d488%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 12:48am UTC](https://discuss.elastic.co/t/does-nested-query-with-operator-honor-the-operator-or-does-it-always-display-some-default-behavior/20814/6 "2017-07-06T00:48:39Z")

</div>


