Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Elasticsearch term filter not working?

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!

like image 284
Guilherme GM Avatar asked Jun 10 '14 17:06

Guilherme GM


1 Answers

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.

like image 195
Greg Marzouka Avatar answered Oct 16 '22 08:10

Greg Marzouka