0
votes

Why does issuing the Elasticsearch query below produce an error?

https://www.elastic.co/guide/en/elasticsearch/reference/1.4/query-dsl-terms-filter.html

Query

curl -XGET 'localhost:9200/bizruntime/biz/_search' -d'
{
  "term": {
    "user": "prakash"
  }
}'

Error message

{
  "error": {
    "root_cause": [
      {
        "type": "search_parse_exception",
        "reason": "failed to parse search source. unknown search element [term]",
        "line": 3,
        "col": 5
      }
    ],
    "type": "search_phase_execution_exception",
    "reason": "all shards failed",
    "phase": "query",
    "grouped": true,
    "failed_shards": [
      {
        "shard": 0,
        "index": "bizruntime",
        "node": "bECY7K9ORPSuLrXpL1DpDw",
        "reason": {
          "type": "search_parse_exception",
          "reason": "failed to parse search source. unknown search element [term]",
          "line": 3,
          "col": 5
        }
      }
    ]
  },
  "status": 400
}
1

1 Answers

0
votes

You need to send your query like this and it will work:

curl -XGET 'localhost:9200/bizruntime/biz/_search' -d '{
  "query": {
     "term" : { "user" : "prakash" } 
  }
}'