Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Elasticsearch URI based query with AND operator

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*" 
like image 440
ram Avatar asked Dec 05 '12 05:12

ram


People also ask

Should and must not Elasticsearch?

Using must_not tells Elasticsearch that document matches cannot include any of the queries that fall under the must_not clause. should – It would be ideal for the matching documents to include all of the queries in the should clause, but they do not have to be included. Scoring is used to rank the matches.

How do I merge two queries in Elasticsearch?

You can combine the queries using bool query. Based on your requirement you can use 'should' or 'must' inside the bool clauses. You may want to schearch for both the field you want, and then aggregate by the most important field.

How do I search for a query in Elasticsearch?

You can use the search API to search and aggregate data stored in Elasticsearch data streams or indices. The API's query request body parameter accepts queries written in Query DSL. The following request searches my-index-000001 using a match query. This query matches documents with a user.id value of kimchy .


1 Answers

According to documentation, it should work as you described it. See http://www.elasticsearch.org/guide/reference/query-dsl/query-string-query.html

That said, you can also use the following:

http://localhost:9200/_search?q="+profiletype:student +username:s*" 
like image 152
dadoonet Avatar answered Oct 04 '22 02:10

dadoonet