# Search on nested multi fields

**URL:** <https://discuss.elastic.co/t/search-on-nested-multi-fields/22726>\
**Category:** Elasticsearch\
**Created:** [March 18, 2015, 12:24am UTC](https://discuss.elastic.co/t/search-on-nested-multi-fields/22726 "2015-03-18T00:24:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chen\_Wang](https://avatars.discourse-cdn.com/v4/letter/c/b5a626/32.png) [@Chen\_Wang](https://discuss.elastic.co/u/Chen_Wang)\
**Post date:** [March 18, 2015, 12:24am UTC](https://discuss.elastic.co/t/search-on-nested-multi-fields/22726/1 "2015-03-18T00:24:04Z")

</div>

Folks,  
I have defined a nested object with multi\_fields attribute: the "cat" in  
store\_purchase

I loaded some data into Es:  
{  
"\_index": "user\_activity\_v2",  
"\_type": "combined",  
"\_id": "1229369",  
"\_score": 1,  
"\_source": {  
"store\_purchase": [  
{  
"item\_id": "10423846",  
"subcat": "First Aid",  
"brand\_name": "brand name",  
"event\_time": "2015-03-09",  
"cat": "otc"  
},  
{  
"item\_id": "34897214",  
"subcat": "coffee",  
"brand\_name": "brand name2",  
"event\_time": "2015-03-09",  
"cat": "cat2 with space"  
},  
}

However, I cannot find any data from the following search

GET \_search  
{  
"query": {  
"bool": {  
"must": [

```
    {
      "nested": {
        "path": "store_purchase", 
        "query": {
          "bool": {
            "must": [ 
              { "match": { "store_purchase.cat": "otc" }}
            ]
    }}}}
  ]

```

}}}

i also tried with { "match": { "store\_purchase.cat.original": "otc" }},  
it all returns nothing.

What I am missing here?  
Thanks,  
Chen

--  
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/7802f86f-fde6-4502-9e76-3c9347ba618a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/7802f86f-fde6-4502-9e76-3c9347ba618a%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Chen\_Wang](https://avatars.discourse-cdn.com/v4/letter/c/b5a626/32.png) [@Chen\_Wang](https://discuss.elastic.co/u/Chen_Wang)\
**Post date:** [March 18, 2015, 12:36am UTC](https://discuss.elastic.co/t/search-on-nested-multi-fields/22726/2 "2015-03-18T00:36:56Z")

</div>

the index definition is this:  
"settings": {  
"index": {  
"number\_of\_shards": 7,  
"number\_of\_replicas": 1,  
"analysis": {  
"analyzer": {  
"analyzer\_raw": {  
"tokenizer": "keyword",  
"filter": "lowercase"  
}  
}  
}  
}  
},  
"mappings": {  
"_default_": {  
"\_ttl": {  
"enabled": 'true',  
"default": ttl  
}  
},  
"user\_activity\_v2": {  
"\_id": {  
"path": "customer\_id"  
},  
"properties": {  
"customer\_id": {"type": "long"},  
"store\_purchase": {  
"type": "nested",  
"include\_in\_parent": "true",  
"properties": {  
"item\_id": {"type": "string"},  
"cat": {  
"type": "multi\_field",  
"fields": {  
"cat": {  
"type": "string",  
},  
"original": {  
"type": "string",  
"search\_analyzer":  
"analyzer\_raw",  
"index\_analyzer": "analyzer\_raw"  
}  
}  
}  
}

On Tuesday, March 17, 2015 at 5:24:04 PM UTC-7, Chen Wang wrote:

> Folks,  
> I have defined a nested object with multi\_fields attribute: the "cat" in  
> store\_purchase
> 
> I loaded some data into Es:  
> {  
> "\_index": "user\_activity\_v2",  
> "\_type": "combined",  
> "\_id": "1229369",  
> "\_score": 1,  
> "\_source": {  
> "store\_purchase": [  
> {  
> "item\_id": "10423846",  
> "subcat": "First Aid",  
> "brand\_name": "brand name",  
> "event\_time": "2015-03-09",  
> "cat": "otc"  
> },  
> {  
> "item\_id": "34897214",  
> "subcat": "coffee",  
> "brand\_name": "brand name2",  
> "event\_time": "2015-03-09",  
> "cat": "cat2 with space"  
> },  
> }
> 
> However, I cannot find any data from the following search
> 
> GET \_search  
> {  
> "query": {  
> "bool": {  
> "must": [
> 
> ```
> {
> "nested": {
> "path": "store_purchase", 
> "query": {
> "bool": {
> "must": [ 
> { "match": { "store_purchase.cat": "otc" }}
> ]
> }}}}
> ]
> 
> ```
> 
> }}}
> 
> i also tried with { "match": { "store\_purchase.cat.original": "otc" }},  
> it all returns nothing.
> 
> What I am missing here?  
> Thanks,  
> Chen

--  
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/185cfeaf-1788-48c7-af72-ee98fa8ed956%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/185cfeaf-1788-48c7-af72-ee98fa8ed956%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Chen\_Wang](https://avatars.discourse-cdn.com/v4/letter/c/b5a626/32.png) [@Chen\_Wang](https://discuss.elastic.co/u/Chen_Wang)\
**Post date:** [March 18, 2015, 1:16am UTC](https://discuss.elastic.co/t/search-on-nested-multi-fields/22726/3 "2015-03-18T01:16:19Z")

</div>

Its my bad.  
I defined the index in a wrong way: Once I move properties under  
user\_activity\_v2 to _default_  
It starts working.  
Chen

On Tuesday, March 17, 2015 at 5:36:57 PM UTC-7, Chen Wang wrote:

> the index definition is this:  
> "settings": {  
> "index": {  
> "number\_of\_shards": 7,  
> "number\_of\_replicas": 1,  
> "analysis": {  
> "analyzer": {  
> "analyzer\_raw": {  
> "tokenizer": "keyword",  
> "filter": "lowercase"  
> }  
> }  
> }  
> }  
> },  
> "mappings": {  
> "_default_": {  
> "\_ttl": {  
> "enabled": 'true',  
> "default": ttl  
> }  
> },  
> "user\_activity\_v2": {  
> "\_id": {  
> "path": "customer\_id"  
> },  
> "properties": {  
> "customer\_id": {"type": "long"},  
> "store\_purchase": {  
> "type": "nested",  
> "include\_in\_parent": "true",  
> "properties": {  
> "item\_id": {"type": "string"},  
> "cat": {  
> "type": "multi\_field",  
> "fields": {  
> "cat": {  
> "type": "string",  
> },  
> "original": {  
> "type": "string",  
> "search\_analyzer":  
> "analyzer\_raw",  
> "index\_analyzer":  
> "analyzer\_raw"  
> }  
> }  
> }  
> }
> 
> On Tuesday, March 17, 2015 at 5:24:04 PM UTC-7, Chen Wang wrote:
> 
> > Folks,  
> > I have defined a nested object with multi\_fields attribute: the "cat" in  
> > store\_purchase
> > 
> > I loaded some data into Es:  
> > {  
> > "\_index": "user\_activity\_v2",  
> > "\_type": "combined",  
> > "\_id": "1229369",  
> > "\_score": 1,  
> > "\_source": {  
> > "store\_purchase": [  
> > {  
> > "item\_id": "10423846",  
> > "subcat": "First Aid",  
> > "brand\_name": "brand name",  
> > "event\_time": "2015-03-09",  
> > "cat": "otc"  
> > },  
> > {  
> > "item\_id": "34897214",  
> > "subcat": "coffee",  
> > "brand\_name": "brand name2",  
> > "event\_time": "2015-03-09",  
> > "cat": "cat2 with space"  
> > },  
> > }
> > 
> > However, I cannot find any data from the following search
> > 
> > GET \_search  
> > {  
> > "query": {  
> > "bool": {  
> > "must": [
> > 
> > ```
> > {
> > "nested": {
> > "path": "store_purchase", 
> > "query": {
> > "bool": {
> > "must": [ 
> > { "match": { "store_purchase.cat": "otc" }}
> > ]
> > }}}}
> > ]
> > 
> > ```
> > 
> > }}}
> > 
> > i also tried with { "match": { "store\_purchase.cat.original": "otc"  
> > }}, it all returns nothing.
> > 
> > What I am missing here?  
> > Thanks,  
> > Chen

--  
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/1237c72c-3fe6-48c0-b581-b80592470900%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/1237c72c-3fe6-48c0-b581-b80592470900%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:26am UTC](https://discuss.elastic.co/t/search-on-nested-multi-fields/22726/4 "2017-07-06T00:26:02Z")

</div>


