# Multi\_field and aggregations

**URL:** <https://discuss.elastic.co/t/multi-field-and-aggregations/18708>\
**Category:** Elasticsearch\
**Created:** [July 16, 2014, 6:20pm UTC](https://discuss.elastic.co/t/multi-field-and-aggregations/18708 "2014-07-16T18:20:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vinicius\_Carvalho](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vinicius_carvalho/32/770_2.png) [@Vinicius\_Carvalho](https://discuss.elastic.co/u/Vinicius_Carvalho)\
**Post date:** [July 16, 2014, 6:20pm UTC](https://discuss.elastic.co/t/multi-field-and-aggregations/18708/1 "2014-07-16T18:20:45Z")

</div>

Hi there, it's been a while since I last used es. My last project was based  
on 0.9.x branch. I'm new to the new fields and aggregations.

I have a field mapped as a multi\_field:

"genre": {  
"type": "string",  
"store": false,  
"index": "analyzed",  
"analyzer": "short",  
"fields" : {  
"raw" : {"type" : "string", "index" : "not\_analyzed"}  
}

The whole idea is that genre uses a custom analyzer that keeps stop words  
(we need some of them on our genre), and I've decided to keep a raw so I  
could execute a faceted search on counting genres

But when I try to run:

{  
"size": 0,  
"query": {  
"match\_all": {}  
},  
"aggs": {  
"genre\_count": {  
"terms": {  
"size": 0,  
"field": "genre.raw"  
}  
}  
}  
}

It fails with no results. What I wanted is to get something like :

Action & Adventure : 100

Adventure: 200

Instead, if I remove the search, the terms are split in such way:

Action : 100

Adventure : 300

What's the proper way to run the aggs query?

Regards

--  
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/368240bd-34ac-4a79-b085-17564e512954%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/368240bd-34ac-4a79-b085-17564e512954%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Vinicius\_Carvalho](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vinicius_carvalho/32/770_2.png) [@Vinicius\_Carvalho](https://discuss.elastic.co/u/Vinicius_Carvalho)\
**Post date:** [July 16, 2014, 7:10pm UTC](https://discuss.elastic.co/t/multi-field-and-aggregations/18708/2 "2014-07-16T19:10:12Z")

</div>

hum, sorry, noticed that the mapping was not set on that index. works fine  
now

On Wednesday, July 16, 2014 2:20:45 PM UTC-4, Vinicius Carvalho wrote:

> Hi there, it's been a while since I last used es. My last project was  
> based on 0.9.x branch. I'm new to the new fields and aggregations.
> 
> I have a field mapped as a multi\_field:
> 
> "genre": {  
> "type": "string",  
> "store": false,  
> "index": "analyzed",  
> "analyzer": "short",  
> "fields" : {  
> "raw" : {"type" : "string", "index" : "not\_analyzed"}  
> }
> 
> The whole idea is that genre uses a custom analyzer that keeps stop words  
> (we need some of them on our genre), and I've decided to keep a raw so I  
> could execute a faceted search on counting genres
> 
> But when I try to run:
> 
> {  
> "size": 0,  
> "query": {  
> "match\_all": {}  
> },  
> "aggs": {  
> "genre\_count": {  
> "terms": {  
> "size": 0,  
> "field": "genre.raw"  
> }  
> }  
> }  
> }
> 
> It fails with no results. What I wanted is to get something like :
> 
> Action & Adventure : 100
> 
> Adventure: 200
> 
> Instead, if I remove the search, the terms are split in such way:
> 
> Action : 100
> 
> Adventure : 300
> 
> What's the proper way to run the aggs query?
> 
> Regards

--  
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/c5c6677e-285d-45dd-a33a-42c1776bd8ce%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/c5c6677e-285d-45dd-a33a-42c1776bd8ce%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, 1:15am UTC](https://discuss.elastic.co/t/multi-field-and-aggregations/18708/3 "2017-07-06T01:15:21Z")

</div>


