# Embedded field search

**URL:** <https://discuss.elastic.co/t/embedded-field-search/4217>\
**Category:** Elasticsearch\
**Created:** [April 11, 2011, 6:28pm UTC](https://discuss.elastic.co/t/embedded-field-search/4217 "2011-04-11T18:28:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gitfy](https://avatars.discourse-cdn.com/v4/letter/g/85f322/32.png) [@gitfy](https://discuss.elastic.co/u/gitfy)\
**Post date:** [April 11, 2011, 6:28pm UTC](https://discuss.elastic.co/t/embedded-field-search/4217/1 "2011-04-11T18:28:45Z")

</div>

Hi,  
I have something like this :

{  
customer : {  
key : 12121,  
displayName: 'Customer 1'

.....

}

When i search

[http://localhost:9200/test/\_search?q=customer.displayName:customer](http://localhost:9200/test/_search?q=customer.displayName:customer)

i get results. But when i do

[http://localhost:9200/test/\_search?q=customer:customer](http://localhost:9200/test/_search?q=customer:customer)

without the embedded field name, i don't get it. Is there way to  
accomplish this using tokenizers or analyzers...i coudn't firgure out  
from the documentation how to write a custom tokenizer script, rather  
the documentation provides only how to define a new one.

One way to achieve this, to transform the document before posting to  
the search engine, but that changes the doc structure of the results  
and i want to keep the structure same throughout the application.

Any help.

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [April 11, 2011, 6:37pm UTC](https://discuss.elastic.co/t/embedded-field-search/4217/2 "2011-04-11T18:37:18Z")

</div>

You can't find it on customer because its does not end up as a field being indexed. In theory, elasticsearch could build a complex query to boolean search on all the customer sub fields. Its a possible feature....

Its not related to tokenizers, unless you want to create something similar to the \_all field, just on the customer level.  
On Monday, April 11, 2011 at 9:28 PM, gitfy wrote:  
Hi,

> I have something like this :
> 
> {  
> customer : {  
> key : 12121,  
> displayName: 'Customer 1'
> 
> .....
> 
> }
> 
> When i search
> 
> [http://localhost:9200/test/\_search?q=customer.displayName:customer](http://localhost:9200/test/_search?q=customer.displayName:customer)
> 
> i get results. But when i do
> 
> [http://localhost:9200/test/\_search?q=customer:customer](http://localhost:9200/test/_search?q=customer:customer)
> 
> without the embedded field name, i don't get it. Is there way to  
> accomplish this using tokenizers or analyzers...i coudn't firgure out  
> from the documentation how to write a custom tokenizer script, rather  
> the documentation provides only how to define a new one.
> 
> One way to achieve this, to transform the document before posting to  
> the search engine, but that changes the doc structure of the results  
> and i want to keep the structure same throughout the application.
> 
> Any help.

---

<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, 4:08am UTC](https://discuss.elastic.co/t/embedded-field-search/4217/3 "2017-07-06T04:08:34Z")

</div>


