# Using custom analyzer and nGram to do partial search on a property

**URL:** <https://discuss.elastic.co/t/using-custom-analyzer-and-ngram-to-do-partial-search-on-a-property/14333>\
**Category:** Elasticsearch\
**Created:** [November 9, 2013, 2:01am UTC](https://discuss.elastic.co/t/using-custom-analyzer-and-ngram-to-do-partial-search-on-a-property/14333 "2013-11-09T02:01:03Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aditya\_Herlambang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aditya_herlambang/32/1798_2.png) [@Aditya\_Herlambang](https://discuss.elastic.co/u/Aditya_Herlambang)\
**Post date:** [November 9, 2013, 2:01am UTC](https://discuss.elastic.co/t/using-custom-analyzer-and-ngram-to-do-partial-search-on-a-property/14333/1 "2013-11-09T02:01:03Z")

</div>

I am trying to get partial search on a property of my entity working by  
using the nGram and edgeNGram working, however  
I am always getting 0 results all the time. Why is this? Here's my full  
code, mappings, and sample data[https://gist.github.com/aherlambang/027dd7316a999cb9a1ff](https://gist.github.com/aherlambang/027dd7316a999cb9a1ff)that I am trying to search on.

Essentially I wanted to search for 'moonl' and it should match the  
username, because the username is moonlyshop and should return the Shop,  
however I am getting 0 results. What am I doing wrong?

--  
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:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [November 9, 2013, 2:36am UTC](https://discuss.elastic.co/t/using-custom-analyzer-and-ngram-to-do-partial-search-on-a-property/14333/2 "2013-11-09T02:36:56Z")

</div>

I guess it's because you search in \_all field (default when you use q=moonl).  
You should try q=shop\_name:moonl or use a MatchQuery with the query DSL.

HTH

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 9 nov. 2013 à 03:01, Aditya Herlambang [aditya15417@gmail.com](mailto:aditya15417@gmail.com) a écrit :

I am trying to get partial search on a property of my entity working by using the nGram and edgeNGram working, however  
I am always getting 0 results all the time. Why is this? Here's my full code, mappings, and sample data that I am trying to search on.

Essentially I wanted to search for 'moonl' and it should match the username, because the username is moonlyshop and should return the Shop,  
however I am getting 0 results. What am I doing wrong?

--  
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:** ![Aditya\_Herlambang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aditya_herlambang/32/1798_2.png) [@Aditya\_Herlambang](https://discuss.elastic.co/u/Aditya_Herlambang)\
**Post date:** [November 9, 2013, 3:11pm UTC](https://discuss.elastic.co/t/using-custom-analyzer-and-ngram-to-do-partial-search-on-a-property/14333/3 "2013-11-09T15:11:55Z")

</div>

but doing q=shop\_name:moonl means that i will only be searching on the store name and not the shops picture caption, is there a way to make multiple search at one? so doing q=moonl and q=shop\_name:moonl at the same time?

--  
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:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [November 9, 2013, 6:31pm UTC](https://discuss.elastic.co/t/using-custom-analyzer-and-ngram-to-do-partial-search-on-a-property/14333/4 "2013-11-09T18:31:39Z")

</div>

You can search for q=moonl q=shop\_name:moonl  
Or +q=moonl and +q=shop\_name:moonl

But I really recommend using QueryDsl [http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html)

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 9 nov. 2013 à 16:11, Aditya Herlambang [aditya15417@gmail.com](mailto:aditya15417@gmail.com) a écrit :

but doing q=shop\_name:moonl means that i will only be searching on the store name and not the shops picture caption, is there a way to make multiple search at one? so doing q=moonl and q=shop\_name:moonl at the same time?

--  
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:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [November 9, 2013, 7:21pm UTC](https://discuss.elastic.co/t/using-custom-analyzer-and-ngram-to-do-partial-search-on-a-property/14333/5 "2013-11-09T19:21:08Z")

</div>

Sorry I meant: +q=moonl +q=shop\_name:moonl is equivalent to q=moonl and q=shop\_name:moonl.

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 9 nov. 2013 à 19:31, David Pilato [david@pilato.fr](mailto:david@pilato.fr) a écrit :

You can search for q=moonl q=shop\_name:moonl  
Or +q=moonl and +q=shop\_name:moonl

But I really recommend using QueryDsl [http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html)

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 9 nov. 2013 à 16:11, Aditya Herlambang [aditya15417@gmail.com](mailto:aditya15417@gmail.com) a écrit :

but doing q=shop\_name:moonl means that i will only be searching on the store name and not the shops picture caption, is there a way to make multiple search at one? so doing q=moonl and q=shop\_name:moonl at the same time?

## -- 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).

--  
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:** ![Aditya\_Herlambang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aditya_herlambang/32/1798_2.png) [@Aditya\_Herlambang](https://discuss.elastic.co/u/Aditya_Herlambang)\
**Post date:** [November 11, 2013, 4:36am UTC](https://discuss.elastic.co/t/using-custom-analyzer-and-ngram-to-do-partial-search-on-a-property/14333/6 "2013-11-11T04:36:54Z")

</div>

So I tried using multi match query by specifying the following:

{  
"multi\_match" : {  
"query" : "some query",  
"fields" : ["username", "fullname", "caption"]  
}  
}

however it seems now the search is not searching the caption (while in fact  
caption is the single most important one). Why is this? I believe this is  
because the caption is a nested property inside the shop.  
So how do I specify the nested property to be searched in a multi match?

On Sunday, November 10, 2013 2:21:08 AM UTC+7, David Pilato wrote:

> Sorry I meant: +q=moonl +q=shop\_name:moonl is equivalent to q=moonl and  
> q=shop\_name:moonl.
> 
> --  
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 9 nov. 2013 à 19:31, David Pilato \<[da...@pilato.fr](mailto:da...@pilato.fr) \<javascript:\>\> a  
> écrit :
> 
> You can search for q=moonl q=shop\_name:moonl  
> Or +q=moonl and +q=shop\_name:moonl
> 
> But I really recommend using QueryDsl  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html)
> 
> --  
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 9 nov. 2013 à 16:11, Aditya Herlambang \<[adity...@gmail.com](mailto:adity...@gmail.com)\<javascript:\>\>  
> a écrit :
> 
> but doing q=shop\_name:moonl means that i will only be searching on the  
> store name and not the shops picture caption, is there a way to make  
> multiple search at one? so doing q=moonl and q=shop\_name:moonl at the same  
> time?
> 
> --  
> 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:\>.  
> 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> 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:** ![Aditya\_Herlambang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aditya_herlambang/32/1798_2.png) [@Aditya\_Herlambang](https://discuss.elastic.co/u/Aditya_Herlambang)\
**Post date:** [November 11, 2013, 4:40am UTC](https://discuss.elastic.co/t/using-custom-analyzer-and-ngram-to-do-partial-search-on-a-property/14333/7 "2013-11-11T04:40:43Z")

</div>

I also think in this case I'd have to use the nested query?

On Monday, November 11, 2013 11:36:54 AM UTC+7, Aditya Herlambang wrote:

> So I tried using multi match query by specifying the following:
> 
> {  
> "multi\_match" : {  
> "query" : "some query",  
> "fields" : ["username", "fullname", "caption"]  
> }  
> }
> 
> however it seems now the search is not searching the caption (while in  
> fact caption is the single most important one). Why is this? I believe this  
> is because the caption is a nested property inside the shop.  
> So how do I specify the nested property to be searched in a multi match?
> 
> On Sunday, November 10, 2013 2:21:08 AM UTC+7, David Pilato wrote:
> 
> > Sorry I meant: +q=moonl +q=shop\_name:moonl is equivalent to q=moonl and  
> > q=shop\_name:moonl.
> > 
> > --  
> > David 😉  
> > Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> > 
> > Le 9 nov. 2013 à 19:31, David Pilato [da...@pilato.fr](mailto:da...@pilato.fr) a écrit :
> > 
> > You can search for q=moonl q=shop\_name:moonl  
> > Or +q=moonl and +q=shop\_name:moonl
> > 
> > But I really recommend using QueryDsl  
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html)
> > 
> > --  
> > David 😉  
> > Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> > 
> > Le 9 nov. 2013 à 16:11, Aditya Herlambang [adity...@gmail.com](mailto:adity...@gmail.com) a écrit :
> > 
> > but doing q=shop\_name:moonl means that i will only be searching on the  
> > store name and not the shops picture caption, is there a way to make  
> > multiple search at one? so doing q=moonl and q=shop\_name:moonl at the same  
> > time?
> > 
> > --  
> > 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).  
> > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@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:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [November 11, 2013, 5:52am UTC](https://discuss.elastic.co/t/using-custom-analyzer-and-ngram-to-do-partial-search-on-a-property/14333/8 "2013-11-11T05:52:16Z")

</div>

Why do you define a nested document?

As far as I can see, you probably don't need it here.

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 11 nov. 2013 à 05:40, Aditya Herlambang [aditya15417@gmail.com](mailto:aditya15417@gmail.com) a écrit :

I also think in this case I'd have to use the nested query?

> On Monday, November 11, 2013 11:36:54 AM UTC+7, Aditya Herlambang wrote:  
> So I tried using multi match query by specifying the following:
> 
> {  
> "multi\_match" : {  
> "query" : "some query",  
> "fields" : ["username", "fullname", "caption"]  
> }  
> }  
> however it seems now the search is not searching the caption (while in fact caption is the single most important one). Why is this? I believe this is because the caption is a nested property inside the shop.  
> So how do I specify the nested property to be searched in a multi match?
> 
> > On Sunday, November 10, 2013 2:21:08 AM UTC+7, David Pilato wrote:  
> > Sorry I meant: +q=moonl +q=shop\_name:moonl is equivalent to q=moonl and q=shop\_name:moonl.
> > 
> > --  
> > David 😉  
> > Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> > 
> > Le 9 nov. 2013 à 19:31, David Pilato [da...@pilato.fr](mailto:da...@pilato.fr) a écrit :
> > 
> > You can search for q=moonl q=shop\_name:moonl  
> > Or +q=moonl and +q=shop\_name:moonl
> > 
> > But I really recommend using QueryDsl [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html)
> > 
> > --  
> > David 😉  
> > Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> > 
> > Le 9 nov. 2013 à 16:11, Aditya Herlambang [adity...@gmail.com](mailto:adity...@gmail.com) a écrit :
> > 
> > but doing q=shop\_name:moonl means that i will only be searching on the store name and not the shops picture caption, is there a way to make multiple search at one? so doing q=moonl and q=shop\_name:moonl at the same time?
> > 
> > ## -- 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). 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@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).

--  
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:** ![Aditya\_Herlambang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aditya_herlambang/32/1798_2.png) [@Aditya\_Herlambang](https://discuss.elastic.co/u/Aditya_Herlambang)\
**Post date:** [November 11, 2013, 7:01am UTC](https://discuss.elastic.co/t/using-custom-analyzer-and-ngram-to-do-partial-search-on-a-property/14333/9 "2013-11-11T07:01:55Z")

</div>

Let me explain my scenario.

I have a Shop, the shop has a username and also a full name.  
The Shop has a nested property which is shopPictures, and each shopPictures  
has a caption associated with it. So this shopPictures is nested.

I wanted to do a search on the caption's first and then the username and  
full name as the priority. When I do the multi query it doesn't search the  
caption of the shopPictures.  
How do I do so?

On Monday, November 11, 2013 12:52:16 PM UTC+7, David Pilato wrote:

> Why do you define a nested document?
> 
> As far as I can see, you probably don't need it here.
> 
> --  
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 11 nov. 2013 à 05:40, Aditya Herlambang \<[adity...@gmail.com](mailto:adity...@gmail.com)\<javascript:\>\>  
> a écrit :
> 
> I also think in this case I'd have to use the nested query?
> 
> On Monday, November 11, 2013 11:36:54 AM UTC+7, Aditya Herlambang wrote:
> 
> > So I tried using multi match query by specifying the following:
> > 
> > {  
> > "multi\_match" : {  
> > "query" : "some query",  
> > "fields" : ["username", "fullname", "caption"]  
> > }  
> > }
> > 
> > however it seems now the search is not searching the caption (while in  
> > fact caption is the single most important one). Why is this? I believe this  
> > is because the caption is a nested property inside the shop.  
> > So how do I specify the nested property to be searched in a multi match?
> > 
> > On Sunday, November 10, 2013 2:21:08 AM UTC+7, David Pilato wrote:
> > 
> > > Sorry I meant: +q=moonl +q=shop\_name:moonl is equivalent to q=moonl and  
> > > q=shop\_name:moonl.
> > > 
> > > --  
> > > David 😉  
> > > Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> > > 
> > > Le 9 nov. 2013 à 19:31, David Pilato [da...@pilato.fr](mailto:da...@pilato.fr) a écrit :
> > > 
> > > You can search for q=moonl q=shop\_name:moonl  
> > > Or +q=moonl and +q=shop\_name:moonl
> > > 
> > > But I really recommend using QueryDsl  
> > > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html)
> > > 
> > > --  
> > > David 😉  
> > > Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> > > 
> > > Le 9 nov. 2013 à 16:11, Aditya Herlambang [adity...@gmail.com](mailto:adity...@gmail.com) a écrit :
> > > 
> > > but doing q=shop\_name:moonl means that i will only be searching on the  
> > > store name and not the shops picture caption, is there a way to make  
> > > multiple search at one? so doing q=moonl and q=shop\_name:moonl at the same  
> > > time?
> > > 
> > > --  
> > > 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).  
> > > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > 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:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [November 11, 2013, 8:58am UTC](https://discuss.elastic.co/t/using-custom-analyzer-and-ngram-to-do-partial-search-on-a-property/14333/10 "2013-11-11T08:58:51Z")

</div>

Ok. Try BoolQuery with should clauses.  
For the nested field, use the NestedQuery with a MatchQuery.  
For the other fields, use the MultiMatch Query

## Does it help?

David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 11 nov. 2013 à 08:01, Aditya Herlambang [aditya15417@gmail.com](mailto:aditya15417@gmail.com) a écrit :

Let me explain my scenario.

I have a Shop, the shop has a username and also a full name.  
The Shop has a nested property which is shopPictures, and each shopPictures has a caption associated with it. So this shopPictures is nested.

I wanted to do a search on the caption's first and then the username and full name as the priority. When I do the multi query it doesn't search the caption of the shopPictures.  
How do I do so?

> On Monday, November 11, 2013 12:52:16 PM UTC+7, David Pilato wrote:  
> Why do you define a nested document?
> 
> As far as I can see, you probably don't need it here.
> 
> --  
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 11 nov. 2013 à 05:40, Aditya Herlambang [adity...@gmail.com](mailto:adity...@gmail.com) a écrit :
> 
> I also think in this case I'd have to use the nested query?
> 
> > On Monday, November 11, 2013 11:36:54 AM UTC+7, Aditya Herlambang wrote:  
> > So I tried using multi match query by specifying the following:
> > 
> > {  
> > "multi\_match" : {  
> > "query" : "some query",  
> > "fields" : ["username", "fullname", "caption"]  
> > }  
> > }  
> > however it seems now the search is not searching the caption (while in fact caption is the single most important one). Why is this? I believe this is because the caption is a nested property inside the shop.  
> > So how do I specify the nested property to be searched in a multi match?
> > 
> > > On Sunday, November 10, 2013 2:21:08 AM UTC+7, David Pilato wrote:  
> > > Sorry I meant: +q=moonl +q=shop\_name:moonl is equivalent to q=moonl and q=shop\_name:moonl.
> > > 
> > > --  
> > > David 😉  
> > > Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> > > 
> > > Le 9 nov. 2013 à 19:31, David Pilato [da...@pilato.fr](mailto:da...@pilato.fr) a écrit :
> > > 
> > > You can search for q=moonl q=shop\_name:moonl  
> > > Or +q=moonl and +q=shop\_name:moonl
> > > 
> > > But I really recommend using QueryDsl [Elastic — The Search AI Company | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html)
> > > 
> > > --  
> > > David 😉  
> > > Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> > > 
> > > Le 9 nov. 2013 à 16:11, Aditya Herlambang [adity...@gmail.com](mailto:adity...@gmail.com) a écrit :
> > > 
> > > but doing q=shop\_name:moonl means that i will only be searching on the store name and not the shops picture caption, is there a way to make multiple search at one? so doing q=moonl and q=shop\_name:moonl at the same time?
> > > 
> > > ## -- 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). 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@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).

--  
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:07am UTC](https://discuss.elastic.co/t/using-custom-analyzer-and-ngram-to-do-partial-search-on-a-property/14333/11 "2017-07-06T02:07:54Z")

</div>


