Skip to content

Commit 17ca780

Browse files
Improve QL docs
Co-Authored-By: trinity-1686a <[email protected]>
1 parent 318e0f5 commit 17ca780

File tree

2 files changed

+25
-32
lines changed

2 files changed

+25
-32
lines changed

docs/get-started/query-language-intro.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ The main concept of this language is a clause, which represents a simple conditi
1313

1414
A clause operates on fields of your document. It has the following syntax :
1515
```
16-
field: condition
16+
field:condition
1717
```
1818

1919
For example, when searching documents where the field `app_name` contains the token `tantivy`, you would write the following clause:
@@ -29,14 +29,14 @@ Quickwit support various types of clauses to express different kinds of conditio
2929

3030
| type | syntax | examples | description| `default_search_field`|
3131
|-------------|--------|----------|------------|-----------------------|
32-
| term | `field: token` | `app_name: tantivy` <br/> `process_id:1234` <br/> `word` | A term clause tests the existence of avalue in the field's tokens | yes |
33-
| term prefix | `field: prefix*` | `app_name: tant*` <br/> `quick*` | A term clause tests the existence of a token starting with the provided value | yes |
34-
| term set | `field: IN [token token ..]` |`severity: IN [error warn]` | A term set clause tests the existence of any of the provided value in the field's tokens| yes |
35-
| phrase | `field: "sequence of tokens"` | `full_name: "john doe"` | A phrase clause tests the existence of the provided sequence of tokens | yes |
36-
| phrase prefix | `field: "sequence of tokens"*` | `title: "how to m"*` | A phrase prefix clause tests the exsitence of a sequence of tokens, the last one used like in a prefix clause | yes |
32+
| term | `field:token` | `app_name:tantivy` <br/> `process_id:1234` <br/> `word` | A term clause tests the existence of avalue in the field's tokens | yes |
33+
| term prefix | `field:prefix*` | `app_name:tant*` <br/> `quick*` | A term clause tests the existence of a token starting with the provided value | yes |
34+
| term set | `field:IN [token token ..]` |`severity:IN [error warn]` | A term set clause tests the existence of any of the provided value in the field's tokens| yes |
35+
| phrase | `field:"sequence of tokens"` | `full_name:"john doe"` | A phrase clause tests the existence of the provided sequence of tokens | yes |
36+
| phrase prefix | `field:"sequence of tokens"*` | `title:"how to m"*` | A phrase prefix clause tests the exsitence of a sequence of tokens, the last one used like in a prefix clause | yes |
3737
| all | `*` | `*` | A match-all clause will match every document | no |
38-
| exist | `field: *` | `error: *` | An exist clause tests the existence of any value for the field, it will match only if the field exists | no |
39-
| range | `field: bounds` |`duration: [0 1000}` <br/> `last_name: [banner miller]` | A term clause tests the existence of a token between the provided bounds | no |
38+
| exist | `field:*` | `error:*` | An exist clause tests the existence of any value for the field, it will match only if the field exists | no |
39+
| range | `field:bounds` |`duration:[0 TO 1000}` <br/> `last_name: [banner TO miller]` | A term clause tests the existence of a token between the provided bounds | no |
4040

4141
## Queries
4242

docs/reference/query-language.md

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ sidebar_position: 40
99
query = '(' query ')'
1010
| query operator query
1111
| unary_operator query
12+
| query query
1213
| clause
1314
1415
operator = 'AND' | 'OR'
@@ -26,12 +27,13 @@ defaultable_clause = term | term_prefix | term_set | phrase | phrase_prefix
2627
## Writing Queries
2728
### Escaping Special Characters
2829

29-
Special reserved characters are: `+` , `^`, `` ` ``, `:`, `{`, `}`, `"`, `[`, `]`, `(`, `)`, `~`, `!`, `\\`, `*`, `SPACE`. Such characters can still appear in query terms, but they need to be escaped by an anti-slash `\` .
30+
Some characters need to be escaped in non quoted terms because they are syntactically significant otherwise: special reserved characters are: `+` , `^`, `` ` ``, `:`, `{`, `}`, `"`, `[`, `]`, `(`, `)`, `~`, `!`, `\\`, `*`, `SPACE`. If such such characters appear in query terms, they need to be escaped by prefixing them with an anti-slash `\`.
3031

31-
<!-- NEED CLARIFICATION: where is escaping necessary ? non-quoted terms ? field names ?-->
32+
In quoted terms, the quote character in use `'` or `"` needs to be escaped.
3233

33-
### Allowed characters in field names
34-
<!-- NEED CLARIFICATION: this should refer to a section of the index documentation that explains allowed field names -->
34+
###### Allowed characters in field names
35+
36+
See the [Field name validation rules](https://quickwit.io/docs/configuration/index-config#field-name-validation-rules) in the index config documentation.
3537

3638
### Addressing nested structures
3739

@@ -66,7 +68,7 @@ There is no support for searching for a range of IP using CIDR notation, but you
6668

6769
### Term `field:term`
6870
```
69-
term: term_char+
71+
term = term_char+
7072
```
7173

7274
Matches documents if the targeted field contains a token equal to the provided term.
@@ -75,15 +77,14 @@ Matches documents if the targeted field contains a token equal to the provided t
7577

7678
### Term Prefix `field:prefix*`
7779
```
78-
term_prefix: term '*'
80+
term_prefix = term '*'
7981
```
8082

8183
Matches documents if the targeted field contains a token which starts with the provided value.
8284

8385
`field:quick*` will match any document where the field 'field' has a token like `quickwit` or `quickstart`, but not `qui` or `abcd`.
8486

85-
86-
### Term set `field: IN [a b c]`
87+
### Term set `field:IN [a b c]`
8788
```
8889
term_set = 'IN' '[' term_list ']'
8990
term_list = term_list term
@@ -92,7 +93,7 @@ term_list = term_list term
9293
Matches if the document contains any of the tokens provided.
9394

9495
###### Examples
95-
`field: IN [ab cd]` will match 'ab' or 'cd', but nothing else.
96+
`field:IN [ab cd]` will match 'ab' or 'cd', but nothing else.
9697

9798
###### Perfomance Note
9899
This is a lot like writing `field:ab OR field:cd`. When there are only a handful of terms to search for, using ORs is usually faster.
@@ -133,24 +134,20 @@ There is no slop for phrase prefix queries.
133134

134135
###### Limitation
135136

136-
Quickwit may trim some results matched by this clause in some cases. If you search for `"thanks for your co"*`, it will enumerate the first 50 tokens which start with "co", and search for any documents where "thanks for your" is followed by any of these tokens.
137+
Quickwit may trim some results matched by this clause in some cases. If you search for `"thanks for your co"*`, it will enumerate the first 50 tokens which start with "co" (in their storage order), and search for any documents where "thanks for your" is followed by any of these tokens.
137138

138139
If there are many tokens starting with "co", "contribution" might not be one of the 50 selected tokens, and the query won't match a document containing "thanks for your contribution". Normal prefix queries don't suffer from this issue.
139140

140-
141-
<!-- NEEDS CLARIFICATION : what does "first 50 tokens" mean ? in what order ? can the value be tuned ? -->
142-
143-
144-
### Range `field: [low_bound high_bound}`
141+
### Range `field:[low_bound TO high_bound}`
145142
```
146143
range = explicit_range | comparison_half_range
147144
148145
explicit_range = left_bound_char bounds right_bound_char
149146
left_bound_char = '[' | '{'
150147
right_bound_char = '}' | ']'
151-
bounds = term term
152-
| term '*'
153-
| '*' term
148+
bounds = term TO term
149+
| term TO '*'
150+
| '*' TO term
154151
155152
comparison_range = comparison_operator term
156153
comparision_operator = '<' | '>' | '<=' | '>='
@@ -171,7 +168,7 @@ Exclusive bounds are represented by curly brackets `{}`. They will not match tok
171168
You can make an half open range by using `*` as one of the bounds. `field:[b TO *]` will match 'bb' and 'zz', but not 'ab'.
172169
You can also use a comparison based syntax:`field:<b`, `field:>b`, `field:<=b` or `field:>=b`.
173170

174-
<!-- NEEDS CLARIFICATION : ordering of empty values ? -->
171+
<!-- NOTE : empty avlues likely not indexed -->
175172

176173
###### Examples
177174
- Inclusive Range: `ip:[127.0.0.1 TO 127.0.0.50]`
@@ -224,13 +221,9 @@ Without parentheses, `AND` takes precedence over `OR`. That is, `a AND b OR c` i
224221
## Other considerations
225222

226223
### Default Search Fields
227-
In many case it is possible to omit the field you search if it was configured in the `default_search_fields` array of the index configuration.
228-
229-
<!-- NEED CLARIFICATION : default fields clauses behavior on an array is combined using OR or AND ? -->
224+
In many case it is possible to omit the field you search if it was configured in the `default_search_fields` array of the index configuration. If more than one field is configured as default, the resulting implicit clauses are combined using a conjunction ('OR').
230225

231226
### Tokenization
232227
Note that the result of a query can depend on the tokenizer used for the field getting searched. Hence this document always speaks of tokens, which may be the exact value the document contain (in case of the raw tokenizer), or a subset of it (for instance any tokenizer cutting on spaces).
233228

234229
<!-- NOTE : should dig deeper ? -->
235-
Quickwit uses a query mini-language which is used by providing a `query` parameter to the search endpoints.
236-
<!-- todo also used in some place in ES: where? -->

0 commit comments

Comments
 (0)