0

I've inserted a record in ElasticSearch an I can see that here:
Elastic Search Bool Query

But this query returns nothing:

{
  "query": {
    "filtered": {
      "query": {
        "bool": {
          "must": {
            "term": {
              "name": "Ehsanl"
            }
          }
        }
      }
    }
  }
}

I post this query using post method to this user: http://127.0.0.1:9200/mydb/customers2/_search What's wrong with that?

ehsan shirzadi
  • 4,709
  • 16
  • 69
  • 112

2 Answers2

0

Try giving the name as "ehsanl". All in lower case.

0

What you see on your screenshot is the original document as you indexed it (_source field).

However, by default, string fields are analyzed (see this answer for more detail about analysis).

Using standard analyzer, your name value should have been lowercased to ehsanl and stored this way in the index : term queries search for the exact value Ehsanl in the index, which doesn't exist.

You can either :

  • use ehsanl value with term query
  • use Ehsanl value with a match query, which will apply the same analyzer before to search.
Community
  • 1
  • 1
ThomasC
  • 7,915
  • 2
  • 26
  • 26