Skip to content

Commit 5851449

Browse files
committed
edit: docs and exports
1 parent 792988d commit 5851449

File tree

5 files changed

+50
-34
lines changed

5 files changed

+50
-34
lines changed

README.md

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,13 @@ all available Arango Search View capabilities, including, `PHRASE` and
2323
multi-lingual and language-specific, complex phrase, (proximity... TBD) and
2424
tokenized search terms.
2525

26-
For example, passing a search phrase like: `some +words -not +"phrase search"
27-
-"not these" ?"could have"` to `buildAQL()`, will produce a query like the
28-
following (see [this example](#query-example) and those found in `tests/`:
26+
For example, passing a search phrase like:
27+
```txt
28+
some +words -not +"phrase search" -"not these" ?"could have"`
29+
```
30+
to `buildAQL()`'s `query` parameter, will
31+
produce a query like the following (see [this example](#query-example) and
32+
those found in `tests/`:
2933

3034
```c
3135
FOR doc IN view
@@ -56,10 +60,9 @@ SEARCH
5660
OPTIONS {"collections": ["col"]}
5761
SORT TFIDF(doc) DESC
5862

59-
LIMIT "phrase search"0, "phrase search"1
63+
LIMIT 0, 1
6064
RETURN doc`
6165
```
62-
n.b. the above code block is styled with c but is .aql compatible.
6366
6467
This query will retrieve all documents that __include__ the term "mandatory"
6568
AND __do not include__ the term "exclude", AND whose ranking will be boosted
@@ -70,24 +73,24 @@ retrieve all documents.
7073
See [default query syntax](#default-query-syntax) and this schematic
7174
[example](#example) for more details.
7275
73-
If multiple collections are passed, the above query is essentially replicated
74-
across all collections, see examples in 'tests/cols.ts'. In the future this
75-
will also accommodate multiple key searches.
76-
76+
If multiple collections are passed, the above query is replicated across all
77+
passed collections, see examples in 'tests/cols.ts'. In the future this will
78+
also accommodate multiple key searches.
7779
7880
___
7981
## setup
8082
81-
1) running generated AQL queries will require a working arangodb instance.
83+
1) running generated AQL queries will require a running arangodb instance.
8284
8385
## installation
8486
currently there is only support for server-side use.
8587
86-
1) clone this repository in your node compatible project.
87-
__or__
88-
run `yarn add @hp4klh5/AQLqueryBuilder.js`
88+
1) run `yarn add @hp4klh5/AQLqueryBuilder.js`
8989
or `npm install --save @hp4klh5/AQLqueryBuilder.js`
90-
in a directory containing a `package.json` file.
90+
in a directory containing a `package.json` file.
91+
__or__
92+
clone this repository in your node compatible project.
93+
9194
2) import/require the exported functions
9295
```js
9396
// use either
@@ -124,9 +127,6 @@ AQLqueryBuilder works best as a document query tool. Leveraging ArangoSearch's
124127
built-in language stemming analyzers allows for complex search phrases to be
125128
run against any number of language-specific collections simultaneously.
126129

127-
For an example of a multi-lingual document ingest/parser/indexer, please see
128-
[ptolemy's
129-
curator](https://gitlab.com/HP4k1h5/nineveh/-/tree/master/ptolemy/dimitri/curator.js)
130130

131131
__Example:__
132132
```javascript
@@ -144,7 +144,7 @@ const queryObject = {
144144
const aqlQuery = buildAQL(queryObject)
145145

146146
// ... const cursor = await db.query(aqlQuery)
147-
// ... const cursor = await db.query(buildAQL(queryObject, {start:20, end:40})
147+
// ... const cursor = await db.query(buildAQL(queryObject, {start:21, end:40})
148148
```
149149

150150
Generate documenation with `yarn doc && serve docs/` or see more examples in
@@ -159,8 +159,8 @@ will be run against
159159

160160
**collections** (required): the names of the collections indexed by @view to query
161161

162-
**terms** (required): either an array of @term interfaces or a string to be
163-
parsed by @parseQuery
162+
**terms** (required): either an array of `term` interfaces or a string to be
163+
parsed by `parseQuery`
164164

165165
**key** (optional | default: "text"): the name of the Arango document key to search
166166
within.
@@ -183,7 +183,7 @@ ___
183183
"key": "text",
184184
"query": "either a +query ?\"string for parseQuery to parse\"",
185185
"query": [
186-
{"type": "phr", "op": "?", "val": "\"or a list of query objects\""},
186+
{"type": "phr", "op": "?", "val": "\"!!! OR a list of query objects\""},
187187
{"type": "tok", "op": "-", "val": "tokens"}
188188
],
189189
"filters": [
@@ -276,10 +276,11 @@ only Document B is returned;
276276
Document A is excluded by the phrase "buckle my shoe"
277277
Document C does not contain the mandatory word "two"
278278

279-
280279
___
280+
281281
## bugs
282-
plase see [bugs](https://github.com/HP4k1h5/AQLqueryBuilder.js/issues/new?assignees=HP4k1h5&labels=bug&template=bug_report.md&title=basic)
282+
please see [bugs](https://github.com/HP4k1h5/AQLqueryBuilder.js/issues/new?assignees=HP4k1h5&labels=bug&template=bug_report.md&title=basic)
283+
283284
## contributing
284-
plase see [./.github/CONTRIBUTING.md]
285+
please see [./.github/CONTRIBUTING.md]
285286

built/index.d.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { query } from './lib/structs';
2-
/** @returns an AQL query object. See @param query for details on required
3-
* values. @parm query .terms accepts either a string to be parsed or an array
4-
* of @param term
2+
export { buildFilters } from './filter';
3+
export { parseQuery } from './parse';
4+
/** @returns an AQL query object. See @param query for
5+
* details on required values. @param query.terms accepts
6+
* either a string to be parsed or an array of terms. @param limit is an object with keys `start` default 0, and `end` default 20.
57
* */
68
export declare function buildAQL(query: query, limit?: any): any;

built/index.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,25 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
33
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
44
return cooked;
55
};
6+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7+
if (k2 === undefined) k2 = k;
8+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
9+
}) : (function(o, m, k, k2) {
10+
if (k2 === undefined) k2 = k;
11+
o[k2] = m[k];
12+
}));
613
exports.__esModule = true;
714
exports.buildAQL = void 0;
815
var arangojs_1 = require("arangojs");
916
var search_1 = require("./search");
1017
var filter_1 = require("./filter");
11-
/** @returns an AQL query object. See @param query for details on required
12-
* values. @parm query .terms accepts either a string to be parsed or an array
13-
* of @param term
18+
var filter_2 = require("./filter");
19+
__createBinding(exports, filter_2, "buildFilters");
20+
var parse_1 = require("./parse");
21+
__createBinding(exports, parse_1, "parseQuery");
22+
/** @returns an AQL query object. See @param query for
23+
* details on required values. @param query.terms accepts
24+
* either a string to be parsed or an array of terms. @param limit is an object with keys `start` default 0, and `end` default 20.
1425
* */
1526
function buildAQL(query, limit) {
1627
if (limit === void 0) { limit = { start: 0, end: 20 }; }

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@hp4k1h5/aqlquerybuilder.js",
3-
"version": "0.0.7",
3+
"version": "0.0.8",
44
"license": "MIT",
55
"main": "built/index.js",
66
"types": "built/index.d.ts",

src/index.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ import { aql } from 'arangojs'
22
import { query } from './lib/structs'
33
import { buildSearch } from './search'
44
import { buildFilters } from './filter'
5+
export { buildFilters } from './filter'
6+
export { parseQuery } from './parse'
57

6-
/** @returns an AQL query object. See @param query for details on required
7-
* values. @parm query .terms accepts either a string to be parsed or an array
8-
* of @param term
8+
/** @returns an AQL query object. See @param query for
9+
* details on required values. @param query.terms accepts
10+
* either a string to be parsed or an array of terms. @param limit is an object with keys `start` default 0, and `end` default 20.
911
* */
1012
export function buildAQL(
1113
query: query,

0 commit comments

Comments
 (0)