4
4
##### !! warning !! experimental and unstable
5
5
6
6
## overview
7
- ArangoSearch provides a high -level API for interacting with Arango Search Views
7
+ ArangoSearch provides a low -level API for interacting with Arango Search Views
8
8
through the Arango Query Language (AQL). This library aims to provide a query
9
9
parser and AQL query builder to enable full boolean search operations across
10
10
all available Arango Search View capabilities, including, ` PHRASE ` and
11
11
` TOKENS ` operations. With minimal syntax overhead the user can generate
12
- multi-lingual and language-specific, complex phrase, proximity and tokenized
12
+ multi-lingual and language-specific, complex phrase, ( proximity... TBD) and tokenized
13
13
search terms.
14
14
15
15
For example, passing a search phrase like: `+mandatory -exclude ?"optional
16
- phrase"` to ` buildAQL`, will produce the following query:
16
+ phrase"` to ` buildAQL` 's query object as the ` term` key, will produce the
17
+ following query:
18
+
17
19
``` aql
18
20
FOR doc IN search_view
19
21
@@ -26,7 +28,7 @@ FOR doc IN search_view
26
28
ANALYZER(
27
29
TOKENS(@value0, @value1)
28
30
ALL IN doc.@value2, @value1),
29
- @value3) AND @value4)
31
+ @value3) AND @value4) <--------------- @value4 here is the PHRASE search
30
32
31
33
AND
32
34
@@ -50,7 +52,7 @@ documents.
50
52
51
53
## setup
52
54
53
- 1 ) running generated AQL queries will require a working arangodb instance. in
55
+ 1 ) running generated AQL queries will require a working arangodb instance. In
54
56
the future, it is hoped that this package can be imported and used in the
55
57
` arangosh ` , as well as client and server side. Currently there is only limited
56
58
support for server-side use.
@@ -61,39 +63,42 @@ support for server-side use.
61
63
!! significantly in the short-term
62
64
1 ) clone this repository in your es6 compatible project.
63
65
2 ) run ` yarn install ` from the project directory.
66
+ 3 ) unless you are importing into a typescript project, i believe you will have
67
+ to run ` yarn tsc ` from the project directory, and possibly change the compile
68
+ target in ` tsconfig.json `
64
69
65
70
## usage
66
- for better documentation, run ` yarn doc && serve docs/ ` from the project
67
- directory root.
71
+ __ for up-to-date documentation, run ` yarn doc && serve docs/ ` from the project
72
+ directory root.__
68
73
69
- AQLqueryBuilder aims to provide collection-agnostic and language-agnostic
70
- boolean search capabilities to the library's user. Currently, this library
71
- makes a number of assumptions about the way your data is stored and indexed,
72
- but these are hopefully compatible with a wide range of setups.
74
+ AQLqueryBuilder aims to provide cross-collection and cross-language boolean
75
+ search capabilities to the library's user. Currently, this library makes a
76
+ number of assumptions about the way your data is stored and indexed, but these
77
+ are hopefully compatible with a wide range of setups.
73
78
74
79
The primary assumption this library makes is that the data you are trying to
75
80
query against is indexed by an ArangoSearch View, and that all documents index
76
- the same exact field. This field can be indexed by any number of analyzers,
77
- and the search be will run against all supplied collections simultaneously. This
78
- allows for true multi-language search provided that each collection is
79
- restricted to just one language and all documents index the same key as all
80
- other documents in the view. While there are plans to expand on this
81
- functionality to provide multi-key search, this library is primarily built for
82
- academic and textual searches, and is ideally suited for documents like books,
83
- articles, and other media where most of the data resides in a single place.
81
+ the same exact field. This field, passed to the builder as a key on the
82
+ ` query ` object passed to e.g. ` buildAQL() ` , can be indexed by any number of
83
+ analyzers, and the query will target all supplied collections simultaneously.
84
+ This allows for true multi-language search provided all documents index the
85
+ same key as all other documents in the view. While there are plans to expand
86
+ on this functionality to provide multi-key search, this library is primarily
87
+ built for academic and textual searches, and is ideally suited for documents
88
+ like books, articles, and other media where most of the data resides in a
89
+ single place, i.e. document ` key ` , or ` field ` .
84
90
85
91
This works best as a document query tool. Leveraging ArangoSearch's built-in
86
92
language stemming analyzers allows for complex search phrases to be run
87
93
against any number of language-specific collections simultaneously.
88
94
89
- For an example of a multi-lingual document ingest/parser, please see
95
+ For an example of a multi-lingual document ingest/parser/indexer , please see
90
96
[ ptolemy's curator] ( https://gitlab.com/HP4k1h5/nineveh/-/tree/master/ptolemy/dimitri/curator.js )
91
97
92
98
__ Example:__
93
99
``` javascript
94
100
import {buildAQL } from ' path/to/AQLqueryBuilder'
95
- const queryObject =
96
- {
101
+ const queryObject = {
97
102
" view" : " the_arango-search_view-name" ,
98
103
" collections" : [{
99
104
" name" : " collection_name" ,
@@ -103,6 +108,7 @@ const queryObject =
103
108
}
104
109
const aqlQuery = buildAQL (queryObject)
105
110
// ... const cursor = await db.query(aqlQuery)
111
+ // ... const cursor = await db.query(aqlQuery, {start:20, end:40})
106
112
```
107
113
` collections ` is an array of ` collection ` objects. This allows searching and
108
114
filtering across collections impacted by the search.
@@ -149,12 +155,7 @@ Example:
149
155
"op" : " >" ,
150
156
"val" : 0
151
157
}
152
- ],
153
- "limit" :
154
- {
155
- "start" : 0 ,
156
- "end" : 20 ,
157
- }
158
+ ]
158
159
}
159
160
```
160
161
@@ -166,15 +167,15 @@ Quoting [mit's Database Search Tips](https://libguides.mit.edu/c.php?g=175963&p=
166
167
167
168
#### ` + ` AND
168
169
* Mandatory terms and phrases. All results MUST INCLUDE these terms and
169
- * phrases.
170
+ phrases.
170
171
#### ` ? ` OR
171
- * Optional terms and phrases. If there are ANDS or NOTS, these serve as
172
- * match score "boosters". If there are no ANDS or NOTS, ORS become required
173
- * in results.
172
+ * Optional terms and phrases. If there are ANDS or NOTS, these serve as match
173
+ score "boosters". If there are no ANDS or NOTS, ORS become required in
174
+ results.
174
175
#### ` - ` NOT
175
176
* Search results MUST NOT INCLUDE these terms and phrases. If a result that
176
- * would otherwise have matched, contains one or more terms or phrases, it
177
- * will not be included in the result set.
177
+ would otherwise have matched, contains one or more terms or phrases, it will
178
+ not be included in the result set.
178
179
179
180
### default query syntax
180
181
for more information on boolean search logic see
@@ -199,10 +200,12 @@ follows:
199
200
| PHRASE | | | "buckle my shoe" |
200
201
| TOKENS | two | one | |
201
202
202
- The generated AQL query, when run will bring back only results that contain
203
- "two", that do not contain variations on the phrase "buckle my shoe", and that
204
- optionally contain "one". In this case, documents that contain "one" will be
205
- likely to score higher than those that do not.
203
+ The generated AQL query, when run, will bring back only results that contain
204
+ "two", that do not contain the phrase "buckle my shoe", and that optionally
205
+ contain "one". In this case, documents that contain "one" will be likely to
206
+ score higher than those that do not.
206
207
207
208
## bugs
209
+ plase see [ bugs] ( https://github.com/HP4k1h5/AQLqueryBuilder.js/issues/new?assignees=HP4k1h5&labels=bug&template=bug_report.md&title=basic )
208
210
## contributing
211
+ plase see [ ./.github/CONTRIBUTING.md]
0 commit comments