Skip to content

Instantly share code, notes, and snippets.

@markharwood
Created April 16, 2015 10:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markharwood/d94f8c4c1a167297b3dd to your computer and use it in GitHub Desktop.
Save markharwood/d94f8c4c1a167297b3dd to your computer and use it in GitHub Desktop.
Numeric queries can't make use of norms.
DELETE users
POST /users
{
"settings" : {
"number_of_shards" : 1,
"number_of_replicas" : 0
},
"mappings":{
"user": {
"properties": {
"likes_as_nums" : {
"index" : "not_analyzed",
"omit_norms" : false,
"type" : "integer"
},
"likes_as_strings" : {
"index" : "not_analyzed",
"omit_norms" : false,
"type" : "string"
}
}
}
}
}
PUT users/user/1
{
"likes_as_strings":["1","2","3","4","5","6"],
"likes_as_nums": [1,2,3,4,5]
}
PUT users/user/2
{
"likes_as_strings":["1","2"],
"likes_as_nums": [1,2]
}
POST users/user/_search?explain=true
{
"query": {
"bool": {
"should": [
{
"match": {
"likes_as_nums": 1
}
},
{
"match": {
"likes_as_nums": 2
}
}
]
}
},
"size": 1
}
POST users/user/_search?explain=true
{
"query":{
"terms":{
"likes_as_nums":[1,2]
}
},
"size":1
}
POST users/user/_search?explain=true
{
"query":{
"query_string":{
"query":"likes_as_nums:(1 2)"
}
},
"size":1
}
POST users/user/_search?explain=true
{
"query":{
"query_string":{
"query":"likes_as_strings:(1 2)"
}
},
"size":1
}
POST users/user/_search?explain=true
{
"query":{
"terms":{
"likes_as_strings":[1, 2]
}
},
"size":1
}
POST users/user/_search?explain=true
{
"query": {
"bool": {
"should": [
{
"match": {
"likes_as_strings": "1"
}
},
{
"match": {
"likes_as_strings": "2"
}
}
]
}
},
"size": 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment