I'm new to ES, I would like to do a simple query to get all the matching values of a domain, but it does not return any thing. The match_all query returns:
curl -XGET localhost:9200/zone/20161201/_search -d '{"query": { "match_all": { }}}'
{"took":4,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":8,"max_score":1.0,"hits":[{"_index":"zone","_type":"20161201","_id":"AVkZ3-ic6lL49IXWU8TZ","_score":1.0,"_source":{"name":"domain2.com"}},{"_index":"zone","_type":"20161201","_id":"AVkZ3-ic6lL49IXWU8Ta","_score":1.0,"_source":{"name":"domain3.com"}},{"_index":"zone","_type":"20161201","_id":"AVkZ4AAQ6lL49IXWU8Te","_score":1.0,"_source":{"name":"domain3.com"}},{"_index":"zone","_type":"20161201","_id":"AVkZ3-ic6lL49IXWU8Tb","_score":1.0,"_source":{"name":"domain4.com"}},{"_index":"zone","_type":"20161201","_id":"AVkZ4AAQ6lL49IXWU8Tc","_score":1.0,"_source":{"name":"domain1.com"}},{"_index":"zone","_type":"20161201","_id":"AVkZ4AAQ6lL49IXWU8Td","_score":1.0,"_source":{"name":"domain2.com"}},{"_index":"zone","_type":"20161201","_id":"AVkZ4AAQ6lL49IXWU8Tf","_score":1.0,"_source":{"name":"domain4.com"}},{"_index":"zone","_type":"20161201","_id":"AVkZ3-ic6lL49IXWU8TY","_score":1.0,"_source":{"name":"domain1.com"}}]}}
but when I want to search for one specific value, it can not find anything:
curl -XGET localhost:9200/zone/20161201/_search -d '{"query":{"term":{"name":"domain3.com"}}}'
Can you please help me? What's wrong with this?
As I can't add comments yet , I need to create a full answer to help you.
What are the mappings for your type? Term queries are used for not analyzed fields and only return exact matches.
Please take a look at the documentation for more details. Specifically at the section "Why doesn’t the term query match my document?"
https://www.elastic.co/guide/en/elasticsearch/reference/2.3/query-dsl-term-query.html