Search code examples
elasticsearchfaceted-searchfacet

Elasticsearch term facet not showing negative terms


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

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)?


Solution

  • Got the answer from Elasticsearch Google Group. Need to update the mapping of the field

    Possible Solution:

    Update the mapping and use

    "index":"analyzed","analyzer" : "keyword"

    or

    "index": "not_analyzed"