Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terms filter doesn't understand _id #2395

Closed
clintongormley opened this issue Nov 9, 2012 · 1 comment
Closed

Terms filter doesn't understand _id #2395

clintongormley opened this issue Nov 9, 2012 · 1 comment

Comments

@clintongormley
Copy link

A terms query can query the _id field, as can a term filter, but not a terms filter:

curl -XPUT 'http://127.0.0.1:9200/test/?pretty=1' 
curl -XPUT 'http://127.0.0.1:9200/test/test/1?pretty=1'  -d '
{
   "foo" : "bar"
}
'
curl -XPUT 'http://127.0.0.1:9200/test/test/2?pretty=1'  -d '
{
   "foo" : "baz"
}
'

terms query works:

curl -XGET 'http://127.0.0.1:9200/test/test/_search?pretty=1'  -d '
{
   "query" : {
      "terms" : {
         "_id" : [
            1,
            2
         ]
      }
   }
}
'

# [Fri Nov  9 18:00:28 2012] Response:
# {
#    "hits" : {
#       "hits" : [
#          {
#             "_source" : {
#                "foo" : "bar"
#             },
#             "_score" : 0.35355338,
#             "_index" : "test",
#             "_id" : "1",
#             "_type" : "test"
#          },
#          {
#             "_source" : {
#                "foo" : "baz"
#             },
#             "_score" : 0.35355338,
#             "_index" : "test",
#             "_id" : "2",
#             "_type" : "test"
#          }
#       ],
#       "max_score" : 0.35355338,
#       "total" : 2
#    },
#    "timed_out" : false,
#    "_shards" : {
#       "failed" : 0,
#       "successful" : 5,
#       "total" : 5
#    },
#    "took" : 0
# }

terms filter doesn't work:

curl -XGET 'http://127.0.0.1:9200/test/test/_search?pretty=1'  -d '
{
   "query" : {
      "constant_score" : {
         "filter" : {
            "terms" : {
               "_id" : [
                  1,
                  2
               ]
            }
         }
      }
   }
}
'

# {
#    "hits" : {
#       "hits" : [],
#       "max_score" : null,
#       "total" : 0
#    },
#    "timed_out" : false,
#    "_shards" : {
#       "failed" : 0,
#       "successful" : 5,
#       "total" : 5
#    },
#    "took" : 1
# }

term filter works:

curl -XGET 'http://127.0.0.1:9200/test/test/_search?pretty=1'  -d '
{
   "query" : {
      "constant_score" : {
         "filter" : {
            "term" : {
               "_id" : 1
            }
         }
      }
   }
}
'

# [Fri Nov  9 17:58:13 2012] Response:
# {
#    "hits" : {
#       "hits" : [
#          {
#             "_source" : {
#                "foo" : "bar"
#             },
#             "_score" : 1,
#             "_index" : "test",
#             "_id" : "1",
#             "_type" : "test"
#          }
#       ],
#       "max_score" : 1,
#       "total" : 1
#    },
#    "timed_out" : false,
#    "_shards" : {
#       "failed" : 0,
#       "successful" : 5,
#       "total" : 5
#    },
#    "took" : 1
# }
@s1monw
Copy link
Contributor

s1monw commented Feb 18, 2013

@clintongormley this seems to be fixed in master I am closing this

@s1monw s1monw closed this as completed Feb 18, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants