Elasticsearch term filter not working?

Guilherme GM picture Guilherme GM · Jun 10, 2014 · Viewed 15k times · Source

I'm trying to do the following term filter

{
  "query": {
    "term": {
      "name": "terry harvey"
    }
  }
}

and I'm getting 0 hits

{
  took: 3
  timed_out: false
  _shards: {
  total: 5
  successful: 5
  failed: 0
}
hits: {
    total: 0
    max_score: 0
    hits: [ ]
  }
}

When I used the "match filter" instead "term filter", I get 48 hits.

What am I doing wrong? =(

Thanks!

Answer

Greg Marzouka picture Greg Marzouka · Jun 10, 2014

Term queries and filters are not analyzed, meaning they will only find exact matches. On the other hand, match queries are analyzed and your name field is probably being analyzed as well. More info here.