Created
July 25, 2012 19:00
-
-
Save dadoonet/3177911 to your computer and use it in GitHub Desktop.
Count Query with not_analyzed mapping
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -XDELETE 'http://localhost:9200/myindex' | |
curl -XPUT 'http://localhost:9200/myindex' | |
curl -XPUT 'http://localhost:9200/myindex/myindext/_mapping' -d '{ | |
"myindext": { | |
"properties": { | |
"user": { | |
"type": "string" | |
}, | |
"message": { | |
"type": "string" | |
}, | |
"post_date": { | |
"type": "date" | |
}, | |
"UserGender": { | |
"type": "string", | |
"index": "not_analyzed" | |
} | |
} | |
} | |
}' | |
curl -XPUT 'http://localhost:9200/myindex/myindext/1' -d '{ | |
"_id" : 1, | |
"user" : "sachin", | |
"post_date" : "2012-1-02T00:00:00", | |
"message" : "lovely world 0", | |
"UserGender":"M" | |
}' | |
curl -XPUT 'http://localhost:9200/myindex/myindext/2' -d '{ | |
"_id" : 2, | |
"user" : "sachin", | |
"post_date" : "2012-1-03T00:00:00", | |
"message" : "lovely world 1", | |
"UserGender":"M" | |
}' | |
curl -XPUT 'http://localhost:9200/myindex/myindext/3' -d '{ | |
"_id" : 3, | |
"user" : "ni", | |
"post_date" : "2012-1-10T00:00:00", | |
"message" : "lovely world 2", | |
"UserGender":"F" | |
}' | |
curl -XPUT 'http://localhost:9200/myindex/myindext/4' -d '{ | |
"_id" : 4, | |
"user" : "sumit", | |
"post_date" : "2012-1-04T00:00:00", | |
"message" : "lovely world 3", | |
"UserGender":"M" | |
}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -XGET 'http://localhost:9200/myindex/myindext/_count' -d '{ | |
"filtered": { | |
"query": { | |
"range": { | |
"post_date": { | |
"from": "2012-1-02T00:00:00", | |
"to": "2012-1-03T00:00:00" | |
} | |
} | |
}, | |
"filter": { | |
"term": { | |
"UserGender": "M" | |
} | |
} | |
} | |
}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment