Lucene V/S KQL
A Tour of KQL vs Lucene Elasticsearch is a search engine, and Kibana can be used to search documents in Elasticsearch. A search is executed by sending a query to Elasticsearch. A query can answer many different types of questions. For example: Who are the customers with the first name Edison? What are the names of customers in India? Are there any orders for Men’s Clothing OR Electronics section? Should I use KQL or Lucene in the Kibana query bar? It Depends, Both KQL and Lucine have a quite a lot in common. I recoment to start with KQL then switch to Lucine for Specific Aggrigation use Case. Learn By Executing. in order to learn use the Free trial or download the pre prepared data sets to run locally if cloud trial expires. KQL Features. once you load your data you can use kibana to explore and learn about the features. NOTE: KQL is case in sencitive and Lucine operaters are All Caps only Autocomplete - KQL Full Testsearch - KQL and Lucine Exact Match You can search for documents that contain an exact term in a provided field of data type keyword(opens in a new tab), which will not be analyzed. Not analyzed strings are case sensitive. Example: Customer_first_name.keyword: Elyssa Note: keyword is a type that only supports Exact search, if not given while searching then anything close to the word is returned. Phrase search To search text fields where the search terms are in the order provided, surround the value in double quotation marks, as follows: Example: “Elyssa Underwood” - this is all field search Example: Customer_full_name: “Elyssa Underwood” - this ia field specific search Fuzzy Search only available in Lucine arjun~1 - will match any word with 1ch differance, the number determines the no of charecters that can differ arj*n - whild charecter search one or more charecters can occur in between arj and n arj?n - single charecter only NOTE: bad idea to use ** or ?* as this can cause perfomance issues. to allow change the settings in elastic search. Regex A regular expression is a way to match patterns in data using placeholder characters called operators. It returns documents that contain terms matching a regular expression. Syntax is based on the Lucene regular expression engine. Example: /.+91[0-9]{9}./ this will match number with +91 xxx xxx xxx Ranges To search documents that contain terms within a provided range, use KQL’s range syntax. You can use the range syntax for string values, IP addresses, and timestamps. KQL Supports the following syntax >, >=,

A Tour of KQL vs Lucene
Elasticsearch is a search engine, and Kibana can be used to search documents in Elasticsearch.
A search is executed by sending a query to Elasticsearch. A query can answer many different types of questions.
For example:
Who are the customers with the first name Edison?
What are the names of customers in India?
Are there any orders for Men’s Clothing OR Electronics section?
Should I use KQL or Lucene in the Kibana query bar?
It Depends, Both KQL and Lucine have a quite a lot in common.
I recoment to start with KQL then switch to Lucine for Specific Aggrigation use Case.
Learn By Executing.
in order to learn use the Free trial or download the pre prepared data sets to run locally if cloud trial expires.
KQL Features.
once you load your data you can use kibana to explore and learn about the features.
NOTE: KQL is case in sencitive and Lucine operaters are All Caps only
- Autocomplete - KQL
- Full Testsearch - KQL and Lucine
Exact Match
You can search for documents that contain an exact term in a provided field of data type keyword(opens in a new tab), which will not be analyzed. Not analyzed strings are case sensitive.
Example: Customer_first_name.keyword: Elyssa
Note: keyword is a type that only supports Exact search, if not given while searching then anything close to the word is returned.
Phrase search
To search text fields where the search terms are in the order provided, surround the value in double quotation marks, as follows:
Example: “Elyssa Underwood” - this is all field search
Example: Customer_full_name: “Elyssa Underwood” - this ia field specific search
Fuzzy Search only available in Lucine
- arjun~1 - will match any word with 1ch differance, the number determines the no of charecters that can differ
- arj*n - whild charecter search one or more charecters can occur in between arj and n
- arj?n - single charecter only
NOTE: bad idea to use **
or ?*
as this can cause perfomance issues.
to allow change the settings in elastic search.
Regex
A regular expression is a way to match patterns in data using placeholder characters called operators. It returns documents that contain terms matching a regular expression. Syntax is based on the Lucene regular expression engine.
Example: /.+91[0-9]{9}./
this will match number with +91 xxx xxx xxx
Ranges
To search documents that contain terms within a provided range, use KQL’s range syntax. You can use the range syntax for string values, IP addresses, and timestamps.
KQL Supports the following syntax >, >=, <, and <=
Lucene supports bracketed range syntax. Ranges can be specified for date, numeric or string fields. Inclusive ranges are specified with square brackets [min TO max] and exclusive ranges with curly brackets {min TO max}.
date:[2012-01-01 TO 2012-12-31]
count:[1 TO 5]
tag:{alpha TO omega}
## Proximity Search
Lucine Exclusive
Proximity search(opens in a new tab) allows the specified words to be further apart or in a different order, a proximity search allows us to specify a maximum edit distance of words in a phrase. The closer the text in a field is to the original order specified in the query string, the more relevant that document is considered to be
“open data”~1
The above example will find all the documents where “open data” is found as a phrase and also “open source data” is a hit where one more term is present in between open and data.
Boosting
Lucene
Use the boost operator ^ to make one term more relevant than another. For instance, if we want to find all documents about foxes, but we are especially interested in quick foxes:
quick^2 fox
The default boost value is 1, but can be any positive floating point number. Boosts between 0 and 1 reduce relevance.
Boosts can also be applied to phrases or to groups:
"john smith"^2 (foo bar)^4
Searching for IP addresses
KQL Lucene
Use "" around IP addresses while using Lucene syntax.
Lucene also supports CIDR notation.
Example: "192.168.03.01"
Nested fields
KQL
Querying nested fields requires a special syntax.
Example: user.names:{ first: "Alyssa" and last: "Underwood" }
Runtime fields
KQL Lucene
A runtime field is a field that is evaluated at query time.