How can I query elasticsearch for only one type of record?
The following query will limit results to records with the type "your_type":
curl - XGET 'http://localhost:9200/_all/your_type/_search?q=your_query'
See http://www.elasticsearch.org/guide/reference/api/search/indices-types.html for more details.
You can also use query dsl to filter out results for specific type like this:
$ curl -XGET 'http://localhost:9200/_search' -d '{ "query": { "filtered" : { "filter" : { "type" : { "value" : "my_type" } } } }}'
Update for version 6.1:Type filter is now replaced by Type Query: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-type-query.htmlYou can use that in both Query and Filter contexts.
{"query" : { "filtered" : { "filter" : { "bool" : { "must" :[{"term":{"_type":"UserAudit"}}, {"term" : {"eventType": "REGISTRATION"}}] } } } }, "aggs":{ "monthly":{ "date_histogram":{ "field":"timestamp", "interval":"1y" }, "aggs":{ "existing_visitor":{ "terms":{ "field":"existingGuest" } } } } }}
"_type":"UserAudit" condition will look the records only specific to type