You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This query will retrieve all documents that __include__ the term "mandatory"
91
-
AND __do not include__ the term "exclude", AND whose ranking will be boosted
92
-
by the presence of the phrase "optional phrase". If no mandatory or exclude
93
-
terms are provided, optional terms are considered required, so as not to
94
-
retrieve all documents.
95
-
96
-
See [default query syntax](#default-query-syntax) and this schematic
97
-
[example](#example) for more details.
91
+
See [default query syntax](#default-query-syntax) and this schematic [example](#example) for more details.
98
92
99
-
If multiple collections are passed, the above query is replicated across all
100
-
passed collections, see examples in 'tests/cols.ts'. In the future this will
101
-
also accommodate multiple key searches.
93
+
If multiple collections are passed, the query is replicated across all passed collections, see examples in 'tests/cols.ts'. In the future this will also accommodate multiple key searches.
102
94
103
95
___
104
96
## setup
105
97
106
98
1) running generated AQL queries will require a running ArangoDB v3.8+ instance. This package is tested against arangodb v3.8.4 🥑
107
99
108
100
## installation
109
-
currently there is only support for server-side use.
110
101
111
102
1) run `yarn add @hp4k1h5/AQLqueryBuilder.js`
112
103
or `npm install --save @hp4k1h5/AQLqueryBuilder.js`
@@ -116,34 +107,27 @@ currently there is only support for server-side use.
116
107
inside the directory.
117
108
118
109
2) import/require the exported functions
110
+
119
111
```js
120
112
// use either
121
113
import {buildAQL, parseQuery} from '@hp4k1h5/AQLqueryBuilder.js'
__for up-to-date documentation, run `yarn doc && serve docs/` from the project
131
-
directory root.__
132
123
133
-
AQLqueryBuilder aims to provide cross-collection and cross-language, multi-key
134
-
boolean search capabilities to the library's user.
124
+
__for up-to-date documentation, run `yarn doc && serve docs/` from the project directory root.__
135
125
136
-
Please ensure that the data you are trying to query against is indexed by an
137
-
ArangoSearch View. The query will target all combinations of provided
138
-
collections, analyzers and keys an simultaneously. This allows for granular
139
-
multi-language search. This library is primarily built for academic and
140
-
textual searches, and is ideally suited for documents like books, articles,
141
-
and other text-heavy media.
126
+
AQLqueryBuilder aims to provide cross-collection and cross-language, multi-key boolean search capabilities to the library's user.
142
127
143
-
AQLqueryBuilder works best as a document query tool. Leveraging ArangoSearch's
144
-
built-in language stemming analyzers allows for complex search phrases to be
145
-
run against any number of language-specific collections simultaneously.
128
+
Please ensure that the data you are trying to query against is indexed by an ArangoSearch View. The query will target all combinations of provided collections, analyzers and keys an simultaneously. This allows for granular multi-language search. This library is primarily built for academic and textual searches, and is ideally suited for documents like books, articles, and other text-heavy media.
146
129
130
+
AQLqueryBuilder works best as a document query tool. Leveraging ArangoSearch's built-in language stemming analyzers allows for complex search phrases to be run against any number of language-specific collections simultaneously.
Generate documenation with `yarn doc && serve docs/` or see more examples in
171
-
e.g. [tests/search.ts](tests/search.ts)
154
+
Generate documentation with `yarn doc && serve docs/` or see more examples in [tests/search.ts](tests/search.ts)
172
155
173
156
___
174
157
158
+
## Exported Functions
159
+
175
160
### `buildAQL()`
176
161
177
162
`buildAQL` accepts two parameters: `query` and `limit`
178
163
179
164
#### query
165
+
166
+
`query` is an object with the following keys:
167
+
180
168
• **view**: *string* (required): the name of the ArangoSearch view the query
181
169
will be run against
182
170
@@ -189,12 +177,8 @@ to query. Objects have the following shape:
189
177
"keys": ["text", "summary", "notes"]
190
178
}
191
179
```
192
-
`keys` are optional, though if key names are provided to `query.key`, and
193
-
not all those keys are indexed by the collection, it is advisable to
194
-
explicitly list only those keys on documents in that collection that are
195
-
indexed by the analyzer. If a collection is indexed by multiple analyzers
196
-
please list each collection-analyzer combination along with their relevant
197
-
keys, unless a unified set of keys is provided to `query.key`.
180
+
181
+
`keys` are optional, though if key names are provided to `query.key`, and not all those keys are indexed by the collection, it is advisable to explicitly list only those keys on documents in that collection that are indexed by the analyzer. If a collection is indexed by multiple analyzers please list each collection-analyzer combination along with their relevant keys, unless a unified set of keys is provided to `query.key`.
198
182
199
183
• **terms** (required): either an array of `term` interfaces or a query string
200
184
to be parsed by `parseQuery()`.
@@ -207,14 +191,10 @@ to be parsed by `parseQuery()`.
207
191
-**type***string* (required): **one of `"phr"`** for PHRASES **or `"tok"`**
208
192
for TOKENS.
209
193
210
-
• **key** (optional | default: "text"): the name of the Arango document key to
211
-
search within.
194
+
• **key** (optional | default: "text"): the name of the Arango document key to search within.
195
+
196
+
• **filters** (optional): a list of filter interfaces. See [arango FILTER operations](https://www.arangodb.com/docs/stable/aql/operations-filter.html) for more details. All [Arango operators](https://www.arangodb.com/docs/3.6/aql/operators.html) Filters have the following shape:
212
197
213
-
• **filters** (optional): a list of filter interfaces. See [arango FILTER
> Boolean operators form the basis of mathematical sets and database logic.
277
-
They connect your search words together to either narrow or broaden your
278
-
set of results. The three basic boolean operators are: AND, OR, and NOT.
259
+
260
+
> Boolean operators form the basis of mathematical sets and database logic. They connect your search words together to either narrow or broaden your set of results. The three basic boolean operators are: AND, OR, and NOT.
261
+
262
+
from [mit's Database Search Tips](https://libguides.mit.edu/c.php?g=175963&p=1158594)
279
263
280
264
#### `+` AND
281
265
282
-
* Mandatory terms and phrases. All results MUST INCLUDE these terms and
283
-
phrases.
266
+
* Mandatory terms and phrases. All results MUST INCLUDE these terms and phrases.
284
267
285
268
#### `?` OR
286
269
287
-
* Optional terms and phrases. If there are ANDS or NOTS, these serve as match
288
-
score "boosters". If there are no ANDS or NOTS, ORS become required in
289
-
results.
270
+
* Optional terms and phrases. If there are ANDS or NOTS, these serve as match score "boosters". If there are no ANDS or NOTS, ORS become required in results.
290
271
291
272
#### `-` NOT
292
273
293
-
* Search results MUST NOT INCLUDE these terms and phrases. If a result that
294
-
would otherwise have matched, contains one or more terms or phrases, it will
295
-
not be included in the result set. If there are no required or optional
296
-
terms, all results that do NOT match these terms will be returned.
274
+
* Search results MUST NOT INCLUDE these terms and phrases. If a result that would otherwise have matched, contains one or more terms or phrases, it will not be included in the result set. If there are no required or optional terms, all results that do NOT match these terms will be returned.
297
275
298
276
### default query syntax
299
277
300
-
for more information on boolean search logic see
301
-
[above](#boolean-search-logic)
278
+
for more information on boolean search logic see [above](#boolean-search-logic)
302
279
303
-
The default syntax accepted by `buildAQL()`'s query paramter key `terms` when
304
-
passing in a string, instead of a `term` interface compatible array is as
305
-
follows:
280
+
The default syntax accepted by `buildAQL()`'s query paramter key `terms` when passing in a string, instead of a `term` interface compatible array is as follows:
306
281
307
282
1) Everything inside single or double quotes is considered a `PHRASE`
308
283
2) Everything else is considered a word to be analyzed by `TOKENS`
@@ -313,24 +288,18 @@ optional and is counted as an `OR`.
313
288
314
289
Please see [tests/parse.ts](tests/parse.ts) for more examples.
315
290
316
-
317
291
#### Example
318
292
319
-
input `one +two -"buckle my shoe"` and `parseQuery()` will interpret that
320
-
query string as follows:
293
+
input `one +two -"buckle my shoe"` and `parseQuery()` will interpret that query string as follows:
321
294
322
295
|| ANDS | ORS | NOTS |
323
296
| - | - | - | - |
324
297
| PHRASE ||| "buckle my shoe" |
325
298
| TOKENS | two | one ||
326
299
327
-
The generated AQL query, when run, will bring back only results that contain
328
-
"two", that do not contain the phrase "buckle my shoe", and that optionally
329
-
contain "one". In this case, documents that contain "one" will be likely to
330
-
score higher than those that do not.
300
+
The generated AQL query, when run, will bring back only results that contain "two", that do not contain the phrase "buckle my shoe", and that optionally contain "one". In this case, documents that contain "one" will be likely to score higher than those that do not.
331
301
332
-
When the above phrase `one +two -"buckle my shoe"` is run against the
333
-
following documents:
302
+
When the above phrase `one +two -"buckle my shoe"` is run against the following documents:
0 commit comments