# Query -elastic search-Facet slor vs aggregation

**URL:** <https://discuss.elastic.co/t/query-elastic-search-facet-slor-vs-aggregation/137694>\
**Category:** Elasticsearch\
**Created:** [June 27, 2018, 8:46pm UTC](https://discuss.elastic.co/t/query-elastic-search-facet-slor-vs-aggregation/137694 "2018-06-27T20:46:15Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![snigdharao](https://avatars.discourse-cdn.com/v4/letter/s/4af34b/32.png) [@snigdharao](https://discuss.elastic.co/u/snigdharao)\
**Post date:** [June 27, 2018, 8:46pm UTC](https://discuss.elastic.co/t/query-elastic-search-facet-slor-vs-aggregation/137694/1 "2018-06-27T20:46:15Z")

</div>

Hi  
Currently in solr we are using facets to implement autocomplete functionality and we are using title has the parameter also year for filtering the data.  
This looks something similar to this  
select title from tablename where title like'A%' and year=2018  
group by title  
Currently we are using facets in solr , what is the best approach .Should i use aggregation to do group by and can i use it along match query?  
Also if i am using aggs , i get an error coz of my mapping .  
I have made my changes to my mapping in reference to this url  
[https://www.elastic.co/guide/en/elasticsearch/reference/current/search-analyzer.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-analyzer.html)

---

<div class="post-metadata">

**Author:** ![snigdharao](https://avatars.discourse-cdn.com/v4/letter/s/4af34b/32.png) [@snigdharao](https://discuss.elastic.co/u/snigdharao)\
**Post date:** [June 27, 2018, 8:58pm UTC](https://discuss.elastic.co/t/query-elastic-search-facet-slor-vs-aggregation/137694/2 "2018-06-27T20:58:21Z")

</div>

GET indexname/type/\_Search  
{

"aggregations": {  
"total\_per\_year": {  
"terms": {  
"field": "title"  
}  
}  
}  
}  
I am getting this error "root\_cause": [

```
    "type": "illegal_argument_exception",
    "reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [civil_service_title] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead."
```

---

<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:** [June 28, 2018, 1:23am UTC](https://discuss.elastic.co/t/query-elastic-search-facet-slor-vs-aggregation/137694/3 "2018-06-28T01:23:37Z")

</div>

If you are using all defaults try on title.keyword field instead.

---

<div class="post-metadata">

**Author:** ![snigdharao](https://avatars.discourse-cdn.com/v4/letter/s/4af34b/32.png) [@snigdharao](https://discuss.elastic.co/u/snigdharao)\
**Post date:** [June 28, 2018, 5:39pm UTC](https://discuss.elastic.co/t/query-elastic-search-facet-slor-vs-aggregation/137694/4 "2018-06-28T17:39:45Z")

</div>

I get this as result if i use keyword "aggregations": {  
"service\_title": {  
"doc\_count\_error\_upper\_bound": 0,  
"sum\_other\_doc\_count": 0,  
"buckets": []  
}  
}  
}

---

<div class="post-metadata">

**Author:** ![snigdharao](https://avatars.discourse-cdn.com/v4/letter/s/4af34b/32.png) [@snigdharao](https://discuss.elastic.co/u/snigdharao)\
**Post date:** [June 28, 2018, 5:40pm UTC](https://discuss.elastic.co/t/query-elastic-search-facet-slor-vs-aggregation/137694/5 "2018-06-28T17:40:34Z")

</div>

Mapping for my title is as follows:  
"title":{  
"type":"text",  
"analyzer": "autocomplete",  
"search\_analyzer": "standard"

```
       }
```

---

<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:** [June 28, 2018, 6:39pm UTC](https://discuss.elastic.co/t/query-elastic-search-facet-slor-vs-aggregation/137694/6 "2018-06-28T18:39:26Z")

</div>

Could you provide a full recreation script as described in [About the Elasticsearch category](https://discuss.elastic.co/t/about-the-elasticsearch-category/21). It will help to better understand what you are doing. Please, try to keep the example as simple as possible.

A full reproduction script will help readers to understand, reproduce and if needed fix your problem. It will also most likely help to get a faster answer.

---

<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 26, 2018, 6:46pm UTC](https://discuss.elastic.co/t/query-elastic-search-facet-slor-vs-aggregation/137694/7 "2018-07-26T18:46:13Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
