Query type
QueryType |
Description |
Background code Sample |
Matchallquery |
Full match |
QueryBuilder QB = Matchallquery (); |
Matchquery |
Single match |
QueryBuilder QB = Matchquery ( "Name", "Kimchy Elasticsearch" ); |
Multimatchquery |
Multi-field Single value matching |
QueryBuilder QB = Multimatchquery ( "Kimchy Elasticsearch", "User", "message" ); |
Wildcardquery |
Fuzzy matching |
Wildcardquerybuilder queryBuilder1 = querybuilders.wildcardquery ("EmpName", "*emp*"); |
Compound query Type
Booltype |
Description |
Background code Sample |
and |
And |
Boolquerybuilder subcodequery = Querybuilders.boolquery (); Wildcardquerybuilder queryBuilder1 = querybuilders.wildcardquery ("EmpName", "*emp*"); Wildcardquerybuilder queryBuilder2 = querybuilders.wildcardquery ("Gender", "*male*"); Subcodequery.must (QueryBuilder1); Subcodequery.must (QUERYBUILDER2); |
OR |
Or |
Similar (subcodequery.should) |
Paging
Pagination is done through the From and size parameters. From defines the starting position of the query result, the size definition returns the maximum number of hits (a hit corresponding to one record).
RESTful sample |
Background code example |
{ "from": 0, "size": Ten, "query": {   &N bsp; "term": {"user": "Kimchy"} } } |
Searc Hresponse response = Client.preparesearch ("dept") settypes ("employee") setquery (QueryBuilder) setfrom (0). SetSize (2) execute () Actionget (); |