This document discusses different types of searches that can be performed in Elasticsearch, including lite searches using query strings and full-body searches using the search query DSL. It describes various query clauses and filters that can be used like match, term, bool and range filters. It also covers sorting, relevance scoring and combining query and filter clauses.
8. Lite search
PROS
Powerful
Convenient for development and ad-
hoc queries
End-users can run queries directly
from their web-browser
CONS
Queries should be carefuly encoded
Opened API can cause potentially
slow queries or even kill your
cluster
Not so efficient for complex queries
10. FULL-BODY SEARCH
● Utilizes the same _search API
● Transfers parameters in request body e.g
curl localhost:9200/github/repository/_search -d '{"size": 2, "from": 10}'
● According to RFC 7231 there is no strict definition what to do when server
received GET query with body parameters (depends on server
implementation). So both GET and POST methods are allowed.
● Instead of encoded urls there is convenient search query domain-specific
language (DSL)
19. COMMON TERMS QUERY
curl localhost:9200/github/repository/_search?pretty -d '{
"query": {
"common": {
"description": {
"query": "for is and web",
"cutoff_frequency": 0.001
}
}
}
}'
Divides query terms into two groups:
● More important - low frequency
● Less important - high frequency (applied first)
23. BOOL FILTER
● must
○ Clauses must match, like and
● must_not
○ Clauses must not match, like not
● should
○ At least one of clauses must match, like or .
29. RELEVANCE
● How well a retrieved document or set of documents meets the information
need (criteria) of the user
● Positive FP number stored under _score property
● Calculated by term frequency/inverce document frequency (TF/IDF) algorithm:
○ Term Frequency (tf): more often - more
relevant (field)
○ Inverted Document Frequency(idf) more often - less relevant (index)
○ Field-length norm (fieldNorm) shorter - more relevant (field)
match query
The standard query for performing full text queries, including fuzzy matching and phrase or proximity queries.
multi_match query
The multi-field version of the match query.
common_terms query
A more specialized query which gives more preference to uncommon words.
query_string query
Supports the compact Lucene query string syntax, allowing you to specify AND|OR|NOT conditions and multi-field search within a single query string. For expert users only.
simple_query_string
A simpler, more robust version of the query_string syntax suitable for exposing directly to users.