Skip to content

Commit cf390f9

Browse files
committed
edit: all tests passing
1 parent 1e270bf commit cf390f9

File tree

4 files changed

+53
-7
lines changed

4 files changed

+53
-7
lines changed

CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# CHANGELOG
2+
3+
- v0.1.1
4+
- ❌ Breaking change! `buildAQL()`'s `limit` parameter no longer accepts key
5+
`end`, which has been renamed, per Arango spec, to `count`. The functionality
6+
remains the same, which is why the patch bump. Please accept my apologies
7+
for the un-semver approach. I have a personal philosophy that v0.X.X is
8+
not really subject to the standard rules of semver, but I will do my best
9+
to not present further breaking changes without upping at least the minor
10+
version.
11+
- multi-key search 🔑🗝
12+
`query.key` now accepts in addition to a string value, an array of
13+
strings over which the query is to be run. this can be useful if you
14+
have multiple fields with textual information. Theoretically, each
15+
chapter of a book could be stored on its own key. Or a document could
16+
have be translated into several languages, each stored on its own key.
17+
ArangoSearch will handle the indexed fields by itself, provided the
18+
collection and analyzer pair that indexes the key are provided to
19+
`query.collections`
20+
21+

README.md

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,46 @@
11
# AQLqueryBuilder.js
22
> a typescript query builder for [arangodb](https://www.arangodb.com)'s [ArangoSearch](https://www.arangodb.com/docs/stable/arangosearch.html)
33
4-
See working demo at [hp4k1h5.github.io](https://hp4k1h5.github.io/#search-box). **!Note** AQLqueryBuilder.js does NOT contain any code for the search bar, only the
4+
See working demo at [hp4k1h5.github.io](https://hp4k1h5.github.io/#search-box).
5+
6+
**!Note** AQLqueryBuilder.js does NOT contain any code for the search bar, only the
57
query string parser and AQL builder. Unabstracted code for the searchbar is
68
located [here](https://github.com/HP4k1h5/hp4k1h5.github.io/tree/main/demos/src/components/search).
79

810
![search bar demonstration with schematic query
911
interface](./img/searchbar_demo.png)
1012

13+
* [Patch Notes](#patch-notes)
1114
* [overview](#overview)
1215
* [setup](#setup)
1316
* [installation](#installation)
1417
* [usage](#usage)
1518
* [`buildAQL()`](#buildaql())
16-
* [query](#query)
17-
* [`query` Example](#query-example)
1819
* [boolean search logic](#boolean-search-logic)
1920
* [default query syntax](#default-query-syntax)
2021
* [Example](#example)
2122
* [bugs](#bugs)
2223
* [contributing](#contributing)
2324

25+
## Patch Notes
26+
- v0.1.1
27+
- ❌ Breaking change! `buildAQL()`'s `limit` parameter no longer accepts key
28+
`end`, which has been renamed, per Arango spec, to `count`. The functionality
29+
remains the same, which is why the patch bump. Please accept my apologies
30+
for the un-semver approach. I have a personal philosophy that v0.X.X is
31+
not really subject to the standard rules of semver, but I will do my best
32+
to not present further breaking changes without upping at least the minor
33+
version.
34+
- multi-key search 🔑🗝
35+
`query.key` now accepts in addition to a string value, an array of
36+
strings over which the query is to be run. this can be useful if you
37+
have multiple fields with textual information. Theoretically, each
38+
chapter of a book could be stored on its own key. Or a document could
39+
have be translated into several languages, each stored on its own key.
40+
ArangoSearch will handle the indexed fields by itself, provided the
41+
collection and analyzer pair that indexes the key are provided to
42+
`query.collections`
43+
2444
## overview
2545

2646
ArangoSearch provides a low-level API for interacting with Arango Search Views

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export function buildAQL(
3030
FOR doc IN ${aql.literal(query.view)}
3131
${SEARCH}
3232
${FILTER}
33-
LIMIT ${limit.start}, ${limit.end}
33+
LIMIT ${limit.start}, ${limit.count}
3434
RETURN doc`
3535
}
3636

tests/ws.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ describe('whitespaces', () => {
99
with whitespace`, () => {
1010
const query = {
1111
view: 'search_view',
12-
collections: [ { name: 'coll', analyzer: 'text_en' } ],
12+
collections: [{ name: 'coll', analyzer: 'text_en' }],
1313
terms: ' " complex phrase " ',
14+
key: ['text'],
1415
}
1516
const builtSearch = buildSearch(query)
1617

@@ -29,8 +30,9 @@ describe('whitespaces', () => {
2930
with whitespaces`, () => {
3031
const query = {
3132
view: 'search_view',
32-
collections: [ { name: 'coll', analyzer: 'text_en' } ],
33+
collections: [{ name: 'coll', analyzer: 'text_en' }],
3334
terms: ' -a +"query string " ?token ',
35+
key: ['text'],
3436
}
3537
const builtSearch = buildSearch(query)
3638

@@ -41,7 +43,7 @@ describe('whitespaces', () => {
4143
expect(builtSearch.bindVars.value4).to.deep.equal(1)
4244
expect(builtSearch.bindVars.value5).to.deep.equal('a')
4345
expect(builtSearch.bindVars.value6).to.deep.equal({
44-
collections: [ query.collections[ 0 ].name ],
46+
collections: [query.collections[0].name],
4547
})
4648
expect(builtSearch.query).to.equal(`
4749
SEARCH
@@ -74,6 +76,7 @@ describe('whitespaces', () => {
7476
},
7577
],
7678
terms: ' +mandatory -exclude ?" optional phrase "',
79+
key: ['text'],
7780
}
7881
const builtSearch = buildSearch(query)
7982
expect(builtSearch.query).to.equal(`
@@ -111,6 +114,7 @@ describe('whitespaces', () => {
111114
},
112115
],
113116
terms: ' -" exclude "',
117+
key: ['text'],
114118
}
115119
const builtSearch = buildSearch(query)
116120
expect(builtSearch.query).to.equal(`
@@ -136,6 +140,7 @@ describe('whitespaces', () => {
136140
},
137141
],
138142
terms: ' -exclude ',
143+
key: ['text'],
139144
}
140145
const builtSearch = buildSearch(query)
141146
expect(builtSearch.bindVars.value0).to.equal('exclude')

0 commit comments

Comments
 (0)