Queries Flashcards
How do you do an analysed query (full text)?
GET _search { query: { match: { "text_entry": "< text to search >"
What’s the maximum number of HITS a query can have?
10_000 by default.
If you want more you need to use the scroll API.
TODO: What is the scroll API?
What is the relevancy score?
A score of how relevant a document is given an analysed search.
This only affects analysed searches (match query), because it wouldn’t make sense for term queries.
How is the relevancy score calculated?
TODO: Learn more about this, is this required for the certification?
What’s the difference between match and match_phrase?
Match phrase will match the whole search term, while “match” will match any words in the search term.
What analyser is used by default when doing a query?
The analyser specified for the field in the index mappings.
How to do a simple multi match query?
GET _search { query: { multi_match: { query: "< text to search >", fields: ["< field to search >", .... ]
What is the “query string” query type?
Performs a query with “query string” style params. Allows booleans operation in the query like “this OR that”.
GET _search
{
query: {
“query_string”: {
default_field: “< field to search >”,
query: “< boolean query syntax >”
TODO: Learn more about this query DSL.
How do you do a term level query?
GET _search { query: { term: { < field name >: { value: " < keyword to search > "
What’s the difference between term and match searches?
Term searches match the whole field is is used with “keyword” type fields, while match queries are analysed: the text is tokenized and intersected with the analysed field in the document, thus allowing partial matches.
How do you search for multiple terms on the same field?
GET _search { query: { terms: { < field name >: [ " < value 1 >", ...., " < value n > ", ]
How do you do a numerical range search?
GET _search { query: { range: { "< field name >": { gte: < value >, lte: < value >,
TODO: Learn more about this query.
What fields can the range query operate on?
numerical and date fields.
How do you do a wildcard term query?
GET _search { query: { wildcard: { "< field name >": { value: "< wildcard term >"
TODO: What’s the performance impact on this?
How do you do a regex term query?
GET _search { query: { regexp: { "< field name >": "< regexp >"