@@ -12,43 +12,53 @@ all available Arango Search View capabilities, including, `PHRASE` and
12
12
multi-lingual and language-specific, complex phrase, (proximity... TBD) and tokenized
13
13
search terms.
14
14
15
- For example, passing a search phrase like: `+mandatory -exclude ?"optional
16
- phrase"` to ` buildAQL` 's query object as the ` term` key, will produce a query
17
- like the following:
18
-
19
- ``` aql
20
- FOR doc IN search_view
21
- SEARCH
22
- MIN_MATCH(
23
- ANALYZER(
24
- TOKENS(@value0, @value1)
25
- ALL IN doc.@value2, @value1),
26
- @value3) OR (MIN_MATCH(
27
- ANALYZER(
28
- TOKENS(@value0, @value1)
29
- ALL IN doc.@value2, @value1),
30
- @value3) AND (PHRASE(doc.@value2, @value4, @value1)))
31
-
32
- AND
33
-
34
- MIN_MATCH(
35
- ANALYZER(
36
- TOKENS(@value5, @value1)
37
- NONE IN doc.@value2, @value1),
38
- @value3)
39
-
40
- OPTIONS @value6
41
- SORT TFIDF(doc) DESC
42
-
43
- LIMIT @value7, @value8
44
- RETURN doc
15
+ For example, passing a search phrase like: `some +words -not +"phrase search"
16
+ -"not these" ?"could have"` to ` buildAQL` 's query object as the ` term` key,
17
+ will produce a query like the following:
18
+
19
+ ``` asx
20
+ FOR doc IN view
21
+
22
+ SEARCH
23
+ (PHRASE(doc.text, "phrase search", analyzer)) AND MIN_MATCH(
24
+ ANALYZER(
25
+ TOKENS("words", analyzer)
26
+ ALL IN doc.text, analyzer),
27
+ 1) OR ((PHRASE(doc.text, "phrase search", analyzer)) AND MIN_MATCH(
28
+ ANALYZER(
29
+ TOKENS("words", analyzer)
30
+ ALL IN doc.text, analyzer),
31
+ 1) AND (PHRASE(doc.text, "could have", analyzer)) OR MIN_MATCH(
32
+ ANALYZER(
33
+ TOKENS(other, analyzer)
34
+ ANY IN doc.text, analyzer),
35
+ 1))
36
+
37
+ AND
38
+ NOT (PHRASE(doc.text, "not these", analyzer))
39
+ AND MIN_MATCH(
40
+ ANALYZER(
41
+ TOKENS("nor", analyzer)
42
+ NONE IN doc.text, analyzer),
43
+ 1)
44
+
45
+ OPTIONS {"collections": ["col"]}
46
+ SORT TFIDF(doc) DESC
47
+
48
+ LIMIT "phrase search"0, "phrase search"1
49
+ RETURN doc`
45
50
```
51
+
46
52
This query will retrieve all documents that __ include__ the term "mandatory"
47
53
AND __ do not include__ the term "exclude", AND whose ranking will be boosted by the
48
54
presence of the phrase "optional phrase". If no mandatory or exclude terms are
49
55
provided, optional terms are considered required, so as not to retrieve all
50
56
documents.
51
57
58
+ If multiple collections are passed, the above queried is essentially
59
+ replicated across all collections, see examples in 'tests/cols.ts'. In the
60
+ future this will also accommodate multiple key searches.
61
+
52
62
## setup
53
63
54
64
1 ) running generated AQL queries will require a working arangodb instance. In
@@ -159,24 +169,33 @@ Example:
159
169
```
160
170
161
171
### boolean search logic
172
+
162
173
Quoting [ mit's Database Search Tips] ( https://libguides.mit.edu/c.php?g=175963&p=1158594 ) :
174
+
163
175
> Boolean operators form the basis of mathematical sets and database logic.
164
176
They connect your search words together to either narrow or broaden your
165
177
set of results. The three basic boolean operators are: AND, OR, and NOT.
166
178
167
179
#### ` + ` AND
180
+
168
181
* Mandatory terms and phrases. All results MUST INCLUDE these terms and
169
182
phrases.
183
+
170
184
#### ` ? ` OR
185
+
171
186
* Optional terms and phrases. If there are ANDS or NOTS, these serve as match
172
187
score "boosters". If there are no ANDS or NOTS, ORS become required in
173
188
results.
189
+
174
190
#### ` - ` NOT
191
+
175
192
* Search results MUST NOT INCLUDE these terms and phrases. If a result that
176
193
would otherwise have matched, contains one or more terms or phrases, it will
177
- not be included in the result set.
194
+ not be included in the result set. If there are no required or optional
195
+ terms, all results that do NOT match these terms will be returned.
178
196
179
197
### default query syntax
198
+
180
199
for more information on boolean search logic see
181
200
[ above] ( #boolean-search-logic )
182
201
@@ -208,3 +227,4 @@ score higher than those that do not.
208
227
plase see [ bugs] ( https://github.com/HP4k1h5/AQLqueryBuilder.js/issues/new?assignees=HP4k1h5&labels=bug&template=bug_report.md&title=basic )
209
228
## contributing
210
229
plase see [ ./.github/CONTRIBUTING.md]
230
+
0 commit comments