[id='full-text-search_{context}']
= Full-text queries

You can perform full-text searches with the Ickle query language.

== Fuzzy queries

To execute a fuzzy query add `~` along with an integer, representing the distance from the term used, after the term.
For instance

[source,sql,tile="Fuzzy Queries in Ickle"]
----
FROM sample_bank_account.Transaction WHERE description : 'cofee'~2
----

== Range queries

To execute a range query define the given boundaries within a pair of braces, as seen in the following example:

[source,sql,tile="Range queries with Ickle"]
----
FROM sample_bank_account.Transaction WHERE amount : [20 to 50]
----

== Phrase queries

A group of words can be searched by surrounding them in quotation marks, as seen in the following example:

[source,sql,tile="Phrase queries with Ickle"]
----
FROM sample_bank_account.Transaction WHERE description : 'bus fare'
----

== Proximity queries

To execute a proximity query, finding two terms within a specific distance, add a `~` along with the distance after the phrase.
For instance, the following example will find the words canceling and fee provided they are not more than 3 words apart:

[source,sql,tile="Proximity queries with Ickle"]
----
FROM sample_bank_account.Transaction WHERE description : 'canceling fee'~3
----

== Wildcard queries

To search for "text" or "test", use the `?` single-character wildcard search:

[source,sql,tile="Single-character wildcard queries with Ickle"]
----
FROM sample_bank_account.Transaction where description : 'te?t'
----

To search for "test", "tests", or "tester", use the `*` multi-character wildcard search:

[source,sql,tile="Multi-character wildcard queries with Ickle"]
----
FROM sample_bank_account.Transaction where description : 'test*'
----

== Regular expression queries

Regular expression queries can be performed by specifying a pattern between `/`. Ickle uses Lucene’s regular expression syntax, so to search for the words `moat` or `boat` the following could be used:

[source,sql,tile="Regular Expression queries with Ickle"]
----
FROM sample_library.Book  where title : /[mb]oat/
----

== Boosting queries

Terms can be boosted by adding a `^` after the term to increase their relevance in a given query, the higher the boost factor the more relevant the term will be. For instance to search for titles containing beer and wine with a higher relevance on beer, by a factor of 3, the following could be used:

[source,sql,tile="Boosting queries with Ickle"]
----
FROM sample_library.Book WHERE title : beer^3 OR wine
----
