Rui Martins
Rui Martins

Reputation: 51

Elasticsearch filter (numeric field) returns nothing

Type mapping

{
  "pois-en": {
    "mappings": {
      "poi": {
        "properties": {
           "address": {
              "type": "string",
              "analyzer": "portuguese"
           },
           "city": {
              "type": "integer"
           },
           (...)
           "type": {
              "type": "integer"
           }
        }
      }
    }
  }
}

Query all:

GET pois-en/_search
{
  "query":{
    "match_all":{}
  },
  "fields": ["city"]
}

returns:

"hits": [
     {
        "_index": "pois-en",
        "_type": "pois_poi",
        "_id": "491",
        "_score": 1,
        "fields": {
           "city": [
              91
           ]
        }
     },
     (...)

But when i filter using:

GET pois-en/_search
{
    "query" : {
        "filtered" : { 
            "query" : {
                "match_all" : {} 
            },
            "filter" : {
                "term" : { 
                    "city" : 91
                }
            }
        }
    }
}

Its returns nothing!

I can't figure out what i'm doing wrong. To Django and Elasticsearch communication i'm Elasticutils (https://github.com/mozilla/elasticutils) but i'm using Sense now to make those queries.

Thanks in advance

Upvotes: 1

Views: 597

Answers (1)

Olly Cruickshank
Olly Cruickshank

Reputation: 6180

The type name isn't consistent in your post (poi and pois_poi) - the returned document doesn't match your mapping.

Upvotes: 1

Related Questions