# Elasticsearch term facet not showing negative terms

**URL:** <https://discuss.elastic.co/t/elasticsearch-term-facet-not-showing-negative-terms/11321>\
**Category:** Elasticsearch\
**Created:** [March 26, 2013, 6:08pm UTC](https://discuss.elastic.co/t/elasticsearch-term-facet-not-showing-negative-terms/11321 "2013-03-26T18:08:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Maaz\_Bin\_Tariq](https://avatars.discourse-cdn.com/v4/letter/m/ee7513/32.png) [@Maaz\_Bin\_Tariq](https://discuss.elastic.co/u/Maaz_Bin_Tariq)\
**Post date:** [March 26, 2013, 6:08pm UTC](https://discuss.elastic.co/t/elasticsearch-term-facet-not-showing-negative-terms/11321/1 "2013-03-26T18:08:27Z")

</div>

I am using elastic search term facets, My field contains some negative  
values but the facet is ignoring the negative sign

following is the facet query

_[http://myserver.com:9200/index/type/\_search](http://myserver.com:9200/index/type/_search)_

Get/Post body

{  
"facets" : {  
"school.id" : {  
"terms" : {  
"field" : "school.id",  
"size" : 10  
}  
}  
}  
}

Response

{  
"took": 281,  
"timed\_out": false,  
"\_shards": {  
"total": 5,  
"successful": 5,  
"failed": 0  
},  
"facets": {  
"school.id": {  
"\_type": "terms",  
"missing": 302,  
"total": 4390,  
"other": 0,  
"terms": [  
{  
"term": "1113515007867355135",  
"count": 4390  
}  
]  
}  
}  
}

The actual value of id is _-1113515007867355135_, am I doing something  
wrong or do I need to pass anything to include negative sign (stemming  
issue)?

--  
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:** [March 26, 2013, 6:14pm UTC](https://discuss.elastic.co/t/elasticsearch-term-facet-not-showing-negative-terms/11321/2 "2013-03-26T18:14:13Z")

</div>

Have a look at how ES analyzed your field.

curl -XGET 'localhost:9200/\_analyze?analyzer=standard&pretty' -d '-1113515007867355135'  
{  
"tokens" : [ {  
"token" : "1113515007867355135",  
"start\_offset" : 1,  
"end\_offset" : 20,  
"type" : "",  
"position" : 1  
} ]  
}

You should modify your mapping for this field and use for example a keyword analyzer  
curl -XGET 'localhost:9200/\_analyze?analyzer=keyword&pretty' -d '-1113515007867355135'  
{  
"tokens" : [ {  
"token" : "-1113515007867355135",  
"start\_offset" : 0,  
"end\_offset" : 20,  
"type" : "word",  
"position" : 1  
} ]  
}

## HTH

David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet | @elasticsearchfr | @scrutmydocs

Le 26 mars 2013 à 19:08, Maaz Bin Tariq [maaz786@gmail.com](mailto:maaz786@gmail.com) a écrit :

> I am using Elasticsearch term facets, My field contains some negative values but the facet is ignoring the negative sign
> 
> following is the facet query
> 
> [http://myserver.com:9200/index/type/\_search](http://myserver.com:9200/index/type/_search)
> 
> Get/Post body
> 
> {  
> "facets" : {  
> "school.id" : {  
> "terms" : {  
> "field" : "school.id",  
> "size" : 10  
> }  
> }  
> }  
> }  
> Response
> 
> {  
> "took": 281,  
> "timed\_out": false,  
> "\_shards": {  
> "total": 5,  
> "successful": 5,  
> "failed": 0  
> },  
> "facets": {  
> "school.id": {  
> "\_type": "terms",  
> "missing": 302,  
> "total": 4390,  
> "other": 0,  
> "terms": [  
> {  
> "term": "1113515007867355135",  
> "count": 4390  
> }  
> ]  
> }  
> }  
> }  
> The actual value of id is -1113515007867355135, am I doing something wrong or do I need to pass anything to include negative sign (stemming issue)?
> 
> --  
> 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:** [March 27, 2013, 5:50am UTC](https://discuss.elastic.co/t/elasticsearch-term-facet-not-showing-negative-terms/11321/3 "2013-03-27T05:50:35Z")

</div>

Yes.

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

Le 27 mars 2013 à 06:48, Maaz Bin Tariq [maaz786@gmail.com](mailto:maaz786@gmail.com) a écrit :

Thanks, but does it require reindexing all data as well?

On Tue, Mar 26, 2013 at 11:14 PM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:

> Have a look at how ES analyzed your field.
> 
> curl -XGET 'localhost:9200/\_analyze?analyzer=standard&pretty' -d '-1113515007867355135'  
> {  
> "tokens" : [ {  
> "token" : "1113515007867355135",  
> "start\_offset" : 1,  
> "end\_offset" : 20,  
> "type" : "",  
> "position" : 1  
> } ]  
> }
> 
> You should modify your mapping for this field and use for example a keyword analyzer  
> curl -XGET 'localhost:9200/\_analyze?analyzer=keyword&pretty' -d '-1113515007867355135'  
> {  
> "tokens" : [ {  
> "token" : "-1113515007867355135",  
> "start\_offset" : 0,  
> "end\_offset" : 20,  
> "type" : "word",  
> "position" : 1  
> } ]  
> }
> 
> ## HTH
> 
> David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
> @dadoonet | @elasticsearchfr | @scrutmydocs
> 
> Le 26 mars 2013 à 19:08, Maaz Bin Tariq [maaz786@gmail.com](mailto:maaz786@gmail.com) a écrit :
> 
> > I am using Elasticsearch term facets, My field contains some negative values but the facet is ignoring the negative sign
> > 
> > following is the facet query
> > 
> > [http://myserver.com:9200/index/type/\_search](http://myserver.com:9200/index/type/_search)
> > 
> > Get/Post body
> > 
> > {  
> > "facets" : {  
> > "school.id" : {  
> > "terms" : {  
> > "field" : "school.id",  
> > "size" : 10  
> > }  
> > }  
> > }  
> > }  
> > Response
> > 
> > {  
> > "took": 281,  
> > "timed\_out": false,  
> > "\_shards": {  
> > "total": 5,  
> > "successful": 5,  
> > "failed": 0  
> > },  
> > "facets": {  
> > "school.id": {  
> > "\_type": "terms",  
> > "missing": 302,  
> > "total": 4390,  
> > "other": 0,  
> > "terms": [  
> > {  
> > "term": "1113515007867355135",  
> > "count": 4390  
> > }  
> > ]  
> > }  
> > }  
> > }  
> > The actual value of id is -1113515007867355135, am I doing something wrong or do I need to pass anything to include negative sign (stemming issue)?
> > 
> > --  
> > 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 a topic in the Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit [https://groups.google.com/d/topic/elasticsearch/FeObbeT1eok/unsubscribe?hl=en-US](https://groups.google.com/d/topic/elasticsearch/FeObbeT1eok/unsubscribe?hl=en-US).  
> To unsubscribe from this group and all its topics, 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:** ![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:44am UTC](https://discuss.elastic.co/t/elasticsearch-term-facet-not-showing-negative-terms/11321/4 "2017-07-06T02:44:15Z")

</div>


