Skip to content

Commit aa5b376

Browse files
Add more examples about advanced search in docs (#4132)
* Mention maximum edit distance allowed in search queries See https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#fuzziness * Extend advanced search docs with more examples
1 parent d741f9b commit aa5b376

File tree

1 file changed

+104
-4
lines changed
  • docs/src/pages/users/search/advanced

1 file changed

+104
-4
lines changed

docs/src/pages/users/search/advanced/index.mdx

Lines changed: 104 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,7 @@ What this translates to: Give me matches that include the keyword "Putin", but a
7777
density={2}
7878
/>
7979

80-
<Callout>Using this operator with too high a number (greater than 3, for example) will cause slow searches and may return too many false results.</Callout>
81-
82-
{/* TODO The max value for fuzzy searches is 2. */}
80+
<Callout>You can only search for spelling variations with a maximum difference of two letters.</Callout>
8381

8482
## Search for words that should be in proximity to each other
8583

@@ -123,7 +121,109 @@ You can build on these searches even further like so:
123121

124122
This translates to: Give me all matches in which each match must contain the keyword Trump and must contain either the keyword Salman or the keyword Putin, but must not contain the keywords South Korea.
125123

126-
## Full search syntax
124+
## Filter search results based on specific properties
125+
126+
You can filter search results based on the values of specific entity properties. For example, the following query will return only entities with `[email protected]` as a value of the `email` property:
127+
128+
```
129+
properties.email:[email protected]
130+
```
131+
132+
An important difference to other search queries is that these filters only match exact values. For example, the query above wouldn’t match an entity with `[email protected]` (without the dot between the first and last name). If you want to match such variations, you can use the `~` operator introduced above or a regular expression search.
133+
134+
Using the spelling variations operator:
135+
136+
```
137+
properties.email:[email protected]~1
138+
```
139+
140+
Using a regular expression:
141+
142+
```
143+
properties.email:/[email protected]/
144+
```
145+
146+
<Callout>
147+
Filtering search results based on property values isn’t available for properties of type [`text`](https://followthemoney.tech/explorer/types/text/). For example, the following query won’t return any results (even if there is an entity with a matching `notes` property), because [`notes`](https://followthemoney.tech/explorer/schemata/Thing/#property-notes) is of the `text` property type.
148+
</Callout>
149+
150+
### Filter based on date properties
151+
152+
In addition to the queries described in the previous section, you can use special operators to filter search results based on date properties.
153+
154+
For example, the following query returns only entities with a value greater than `2010-07-01` (July 1st, 2010) in the `incorporationDate` property:
155+
156+
```
157+
properties.incorporationDate:>2010-07-01
158+
```
159+
160+
To search for entities with an incorporation date including July 1st, use the `>=` operator:
161+
162+
```
163+
properties.incorporationDate:>=2010-07-01
164+
```
165+
166+
Searching for values less than a value works analogously:
167+
168+
```
169+
properties.incorporationDate:<2010-07-01
170+
properties.incorporationDate:<=2017-07-01
171+
```
172+
173+
You can also query results with values in a range. FOr example, the following query returns only entities with a value between `2010-01-01` and `2015-12-31`:
174+
175+
```
176+
properties.incorporationDate:[2010-01-01 TO 2015-12-31]
177+
```
178+
179+
The bounds of the range are inclusive, that is, in case of the query above, it includes entities with values of `2015-01-01` and `2015-12-31` in the `incorporationDate` property.
180+
181+
### Filter based on numeric properties
182+
183+
You can use the same operators described in the previous section to filter search results based on numeric properties. However, you need to prefix the property names with `numeric.` instead of `properties.`.
184+
185+
For example, the following query returns only entities with a value greater than `99` in the `rowCount` property:
186+
187+
```
188+
numeric.rowCount:>99
189+
```
190+
191+
## Filter search results based on metadata
192+
193+
Aleph stores additional information about entities that isn’t part of the entity properties. This includes the entity schema and the ID of the dataset or investigation the entity is part of. While you can filter based on this information using Aleph’s search UI, you can also use it in search queries:
194+
195+
### Filter based on entity schema
196+
197+
The following query returns only `LegalEntity` entities:
198+
199+
```
200+
schema:LegalEntity
201+
```
202+
203+
Note that this does not include entities with a schema that inherits from `LegalEntity`. For example, while the `Company` schema inherits from `LegalEntity`, it wouldn’t return `Company` entities.
204+
205+
Instead, you can use the following query to return only entities that use the `LegalEntity` schema or any schema inheriting from `LegalEntity` (such as `Person` or `Company`):
206+
207+
```
208+
schemata:LegalEntity
209+
```
210+
211+
### Filter based on dataset or investigation
212+
213+
To filter based on a dataset or investigation, you need to know its ID. You can find the ID in the URL of the dataset or investigation. For example, in the following two URLs, the IDs are `123` and `456`, respectively.
214+
215+
```
216+
https://aleph.occrp.org/datasets/123
217+
https://aleph.occrp.org/investigations/456
218+
```
219+
220+
You can then use the ID to filter search results to include only entities from a particular dataset or investigation. For example, the following query returns only entities from the dataset with the ID `123`:
221+
222+
```
223+
collection_id:123
224+
```
225+
226+
## Full search query syntax
127227

128228
Under the hood, Aleph uses a search engine called Elasticsearch. In addition to the advanced search options explained above, you can also use the full Elasticsearch query syntax. Please refer to the [Elasticsearch documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#query-string-syntax) for more information.
129229

0 commit comments

Comments
 (0)