I can do a quick URI search like
GET twitter/tweet/_search?q=user:kimchy
Can I search multiple fields this way? For example, user:kimchy AND age:23
?
What I tried 1 (error):
curl -XDELETE localhost:9200/myindex/
curl localhost:9200/myindex/mytype/1 -d '{"a":1,"b":9}'
curl localhost:9200/myindex/mytype/2 -d '{"a":9,"b":9}'
curl localhost:9200/myindex/mytype/3 -d '{"a":9,"b":1}'
Say I want just the document {"a":9, "b":9}
, I tried
GET localhost:9200/myindex/_search?q=a:9&b:9
but I get error
{
error: {
root_cause: [{
type: "illegal_argument_exception",
reason: "request [/myindex/_search] contains unrecognized parameter: [b:9]"
}],
type: "illegal_argument_exception",
reason: "request [/myindex/_search] contains unrecognized parameter: [b:9]"
},
status: 400
}
What I tried 2 (works!):
GET localhost:9200/myindex/_search?q=a:9 AND b:9
The spaces are important. Alternatively, use %20
.
Yes, you can. Try something like this:
GET twitter/tweet/_search?q=user:kimchy%20AND%20age:23
Note that if you URI decode this, it's equivalent to:
GET twitter/tweet/_search?q=user:kimchy AND age:23
Note that when you are using this REST endpoint like this, I think you are really taking advantage of something like the query_string_query
. Refer to those docs to get an idea of the extent of the query string language and features available to you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With