Skip to content

Commit 7495136

Browse files
nataliaElvpre-commit-ci[bot]frascuchon
authored
Docs: advanced queries dsl (#5435)
# Description <!-- Please include a summary of the changes and the related issue. Please also include relevant motivation and context. List any dependencies that are required for this change. --> Closes #<issue_number> **Type of change** <!-- Please delete options that are not relevant. Remember to title the PR according to the type of change --> - Bug fix (non-breaking change which fixes an issue) - New feature (non-breaking change which adds functionality) - Breaking change (fix or feature that would cause existing functionality to not work as expected) - Refactor (change restructuring the codebase without changing functionality) - Improvement (change adding some improvement to an existing functionality) - Documentation update **How Has This Been Tested** <!-- Please add some reference about how your feature has been tested. --> **Checklist** <!-- Please go over the list and make sure you've taken everything into account --> - I added relevant documentation - I followed the style guidelines of this project - I did a self-review of my code - I made corresponding changes to the documentation - I confirm My changes generate no new warnings - I have added tests that prove my fix is effective or that my feature works - I have added relevant notes to the CHANGELOG.md file (See https://keepachangelog.com/) --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Francisco Aranda <[email protected]>
1 parent e28ef13 commit 7495136

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

argilla/docs/how_to_guides/annotate.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,12 @@ The UI offers various features designed for data exploration and understanding.
136136

137137
From the **control panel** at the top of the left pane, you can search by keyword across the entire dataset. If you have more than one field in your records, you may specify if the search is to be performed “All” fields or on a specific one. Matched results are highlighted in color.
138138

139+
!!! note
140+
If you introduce more than one keyword, the search will return results where **all** keywords have a match.
141+
142+
!!! tip
143+
For more advanced searches, take a look at the [advanced queries DSL](query.md#advanced-queries).
144+
139145
### Order by record semantic similarity
140146

141147
You can retrieve records based on their similarity to another record if vectors have been added to the dataset.

argilla/docs/how_to_guides/query.md

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ You can search for records in your dataset by **querying** or **filtering**. The
3535

3636
To search for records with terms, you can use the `Dataset.records` attribute with a query string. The search terms are used to search for records that contain the terms in the text field. You can search a single term or various terms, in the latter, all of them should appear in the record to be retrieved.
3737

38-
=== "Single search term"
38+
=== "Single term search"
3939

4040
```python
4141
import argilla as rg
@@ -49,7 +49,7 @@ To search for records with terms, you can use the `Dataset.records` attribute wi
4949
queried_records = dataset.records(query=query).to_list(flatten=True)
5050
```
5151

52-
=== "Multiple search term"
52+
=== "Multiple terms search"
5353

5454
```python
5555
import argilla as rg
@@ -63,6 +63,23 @@ To search for records with terms, you can use the `Dataset.records` attribute wi
6363
queried_records = dataset.records(query=query).to_list(flatten=True)
6464
```
6565

66+
### Advanced queries
67+
68+
If you need more complex searches, you can use [Elasticsearch's simple query string syntax](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-simple-query-string-query.html#simple-query-string-syntax). Here is a summary of the different available operators:
69+
70+
| operator | description | example |
71+
| ------------ | --------------------------- | --------------------------------------------------------------------- |
72+
|`+` or `space`| **AND**: search both terms | `argilla + distilabel` or `argilla distilabel`</br> return records that include the terms "argilla" and "distilabel"|
73+
|`|` | **OR**: search either term | `argilla | distilabel` </br> returns records that include the term "argilla" or "distilabel"|
74+
|`-` | **Negation**: exclude a term| `argilla -distilabel` </br> returns records that contain the term "argilla" and don't have the term "distilabel"|
75+
|`*` | **Prefix**: search a prefix | `arg*`</br> returns records with any words starting with "arg-"|
76+
|`"` | **Phrase**: search a phrase | `"argilla and distilabel"` </br> returns records that contain the phrase "argilla and distilabel"|
77+
|`(` and `)` | **Precedence**: group terms | `(argilla | distilabel) rules` </br> returns records that contain either "argilla" or "distilabel" and "rules"|
78+
|`~N` | **Edit distance**: search a term or phrase with an edit distance| `argilla~1` </br> returns records that contain the term "argilla" with an edit distance of 1, e.g. "argila"|
79+
80+
!!! tip
81+
To use one of these characters literally, escape it with a preceding backslash `\`, e.g. `"1 \+ 2"` would match records where the phrase "1 + 2" is found.
82+
6683
## Filter by conditions
6784

6885
You can use the `Filter` class to define the conditions and pass them to the `Dataset.records` attribute to fetch records based on the conditions. Conditions include "==", ">=", "<=", or "in". Conditions can be combined with dot notation to filter records based on metadata, suggestions, or responses. You can use a single condition or multiple conditions to filter records.
@@ -72,7 +89,7 @@ You can use the `Filter` class to define the conditions and pass them to the `Da
7289
| `==` | The `field` value is equal to the `value` |
7390
| `>=` | The `field` value is greater than or equal to the `value` |
7491
| `<=` | The `field` value is less than or equal to the `value` |
75-
| `in` | TThe `field` value is included in a list of values |
92+
| `in` | The `field` value is included in a list of values |
7693

7794
=== "Single condition"
7895

argilla/mkdocs.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ plugins:
121121
- docs/scripts/gen_changelog.py
122122
- docs/scripts/gen_popular_issues.py
123123
# - docs/scripts/gen_ref_pages.py
124+
enabled: !ENV [CI, false] # enables the plugin only during continuous integration (CI), disabled on local build
124125
- literate-nav:
125126
nav_file: SUMMARY.md
126127
- section-index
@@ -148,7 +149,8 @@ plugins:
148149
# Signature
149150
separate_signature: false
150151
show_signature_annotations: false
151-
- social
152+
- social:
153+
enabled: !ENV [CI, false] # enables the plugin only during continuous integration (CI), disabled on local build
152154
- mknotebooks
153155
- material-plausible
154156

0 commit comments

Comments
 (0)