How do I specify AND operation in URI based query? I\'m looking for something like:
http://localhost:9200/_search?q=\"profiletype:student AND username:s*\"
For URI search in ElasticSearch, you can use either the AND operator profiletype:student AND username:s
, as you say but without quotes:
_search?q=profiletype:student AND username:s*
You can also set the default operator to AND
_search?q=profiletype:student username:s*&default_operator=AND
Or you can use the +
operator for terms that must be present, i.e. one would use +profiletype:student +username:s
as query string. This doesn't work without URL encoding, though. In URL encoding +
is %2B
and space is %20
, therefore the alternative would be
_search?q=%2Bprofiletype:student%20%2Busername:s*