Thanks to its powerful backend, Portrait can use operators to extend the possibilities of a search.
Operators
The following operators can be used inside Portrait:
Op. | Description | Example |
---|---|---|
| signifies AND operation. | Vienna +Orchestra |
| signifies OR operation | Vienna | Salzburg |
| negates a single term | Orchestra -Vienna |
| wraps a number of terms to signify a phrase for searching | “Vienna Philarmonic Orchestra” |
| at the end of a term signifies a prefix query | Vie* |
| signify precedence | Orchestra (Salzburg | Vienna) |
| fuzzy search See below “Fuzziness” | Vienne~ |
| after a word signifies edit distance (fuzziness) See below “Fuzziness” | Vienne~1 |
| after a phrase signifies slop amount See below “Slop value” | “Vienna Centre“~3 |
In order to search for any of these special characters, they will need to be escaped with \
. E.g: C\+\+
.
By default terms are connected by AND; so you don’t need to use the operator +
in practice.
Fuzziness
A fuzzy search will return a list of results based on likely relevance even though search argument words and spellings may not exactly match. Exact and highly relevant matches appear near the top of the list.
Example: Vienne~ will also find “Vienna”.
This is useful if you do not know the exact spelling of a word - e.g. “Mayer”, “Maier” or “Meyer”.
If you use a trailing number after the tilde (“Vienne~1”), you can limit the distance of the fuzziness. Although the value can be at maximum 3
.
Slop value
The slop
parameter tells the query how far apart terms are allowed to be while still considering the document a match. By how far apart we mean how many times do you need to move a term in order to make the query and document match?
Example: “Vienna Centre”~3
will find the phrase “Vienna International Centre“.
Read more about it here: https://www.elastic.co/guide/en/elasticsearch/guide/current/slop.html