# Nested Query have a default operator?

**URL:** <https://discuss.elastic.co/t/nested-query-have-a-default-operator/11985>\
**Category:** Elasticsearch\
**Created:** [May 16, 2013, 12:32am UTC](https://discuss.elastic.co/t/nested-query-have-a-default-operator/11985 "2013-05-16T00:32:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anderson\_Bento](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anderson_bento/32/2288_2.png) [@Anderson\_Bento](https://discuss.elastic.co/u/Anderson_Bento)\
**Post date:** [May 16, 2013, 12:32am UTC](https://discuss.elastic.co/t/nested-query-have-a-default-operator/11985/1 "2013-05-16T00:32:13Z")

</div>

I ask it before when I looking for "John Joe" it's return all users with  
John in the name.

my request

{  
"query":{  
"nested" : {  
"path" : "friends",  
"query" : {  
"bool" : {  
"must" : [  
{  
"match" : {"friends.name" : "John Doe"}  
}  
]

```
            }
        }
    }
}

```

}'

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Anderson\_Bento](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anderson_bento/32/2288_2.png) [@Anderson\_Bento](https://discuss.elastic.co/u/Anderson_Bento)\
**Post date:** [May 16, 2013, 12:51am UTC](https://discuss.elastic.co/t/nested-query-have-a-default-operator/11985/2 "2013-05-16T00:51:40Z")

</div>

I fixed it setting the name field with not\_analyzed param 🙂

Em quarta-feira, 15 de maio de 2013 21h32min13s UTC-3, Anderson Bento  
escreveu:

> I ask it before when I looking for "John Joe" it's return all users with  
> John in the name.
> 
> my request
> 
> {  
> "query":{  
> "nested" : {  
> "path" : "friends",  
> "query" : {  
> "bool" : {  
> "must" : [  
> {  
> "match" : {"friends.name" : "John Doe"}  
> }  
> ]
> 
> ```
> }
> }
> }
> }
> 
> ```
> 
> }'

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Anderson\_Bento](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anderson_bento/32/2288_2.png) [@Anderson\_Bento](https://discuss.elastic.co/u/Anderson_Bento)\
**Post date:** [May 16, 2013, 12:52am UTC](https://discuss.elastic.co/t/nested-query-have-a-default-operator/11985/3 "2013-05-16T00:52:03Z")

</div>

"name": {"type":"string","index": "not\_analyzed"},

Em quarta-feira, 15 de maio de 2013 21h51min40s UTC-3, Anderson Bento  
escreveu:

> I fixed it setting the name field with not\_analyzed param 🙂
> 
> Em quarta-feira, 15 de maio de 2013 21h32min13s UTC-3, Anderson Bento  
> escreveu:
> 
> > I ask it before when I looking for "John Joe" it's return all users  
> > with John in the name.
> > 
> > my request
> > 
> > {  
> > "query":{  
> > "nested" : {  
> > "path" : "friends",  
> > "query" : {  
> > "bool" : {  
> > "must" : [  
> > {  
> > "match" : {"friends.name" : "John Doe"}  
> > }  
> > ]
> > 
> > ```
> > }
> > }
> > }
> > }
> > 
> > ```
> > 
> > }'

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [May 16, 2013, 9:25am UTC](https://discuss.elastic.co/t/nested-query-have-a-default-operator/11985/4 "2013-05-16T09:25:57Z")

</div>

Hi Anderson

Setting it to not\_analyzed may be the way to go, but there are other  
approaches too.

For instance, right now a search for "john doe" won't match "John Doe". If  
that's what you want, then that's fine.

Alternatively, you could leave the field as analyzed, and change your  
search to:

```
{ match: {
    name: {
        query: "john doe",
        operator: "and"
   }
}

```

which will only match names that have both "john" and "doe" in them

clint

On 16 May 2013 02:52, Anderson Bento [deca.rox@gmail.com](mailto:deca.rox@gmail.com) wrote:

> "name": {"type":"string","index": "not\_analyzed"},
> 
> Em quarta-feira, 15 de maio de 2013 21h51min40s UTC-3, Anderson Bento  
> escreveu:
> 
> > I fixed it setting the name field with not\_analyzed param 🙂
> > 
> > Em quarta-feira, 15 de maio de 2013 21h32min13s UTC-3, Anderson Bento  
> > escreveu:
> > 
> > > I ask it before when I looking for "John Joe" it's return all users  
> > > with John in the name.
> > > 
> > > my request
> > > 
> > > {  
> > > "query":{  
> > > "nested" : {  
> > > "path" : "friends",  
> > > "query" : {  
> > > "bool" : {  
> > > "must" : [  
> > > {  
> > > "match" : {"friends.name" : "John Doe"}  
> > > }  
> > > ]
> > > 
> > > ```
> > > }
> > > }
> > > }
> > > }
> > > 
> > > ```
> > > 
> > > }'
> > > 
> > > --  
> > > 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).  
> > > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:36am UTC](https://discuss.elastic.co/t/nested-query-have-a-default-operator/11985/5 "2017-07-06T02:36:22Z")

</div>


