Skip to content
This repository was archived by the owner on Jan 2, 2024. It is now read-only.

Commit 44f6c26

Browse files
committed
docs: add quick start example
1 parent 1c215a6 commit 44f6c26

File tree

8 files changed

+49
-2
lines changed

8 files changed

+49
-2
lines changed

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { Q } from 'solr-query-maker';
1919

2020
// Returns the value of the `q` URL parameter for searching.
2121
function makeQuery() {
22-
// '((geo:"Intersects(POINT (-122.17381 37.426002))" OR "spicy") OR title:He??o OR product:([100 TO *] AND (NOT 600)))'
22+
// (geo:"Intersects(POINT(-122.17381 37.426002))" OR "spicy" OR title:He??o OR product:([100 TO *] AND (NOT 600)))
2323
return Q.toString(
2424
Q.or(
2525
Q.term(
@@ -35,6 +35,8 @@ function makeQuery() {
3535
)
3636
);
3737
}
38+
39+
console.log(makeQuery());
3840
```
3941

4042
## License

examples/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
!node_modules/
2+

examples/node_modules/solr-query-maker

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/quickstart/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
!node_modules/
2+

examples/quickstart/index.ts

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { Q } from 'solr-query-maker';
2+
3+
// Returns the value of the `q` URL parameter for searching.
4+
function makeQuery() {
5+
// (geo:"Intersects(POINT(-122.17381 37.426002))" OR "spicy" OR title:He??o OR product:([100 TO *] AND (NOT 600)))
6+
return Q.toString(
7+
Q.or(
8+
Q.term(
9+
'geo',
10+
Q.spatial.intersects({
11+
type: 'Point',
12+
coordinates: [-122.17381, 37.426002],
13+
})
14+
),
15+
Q.defaultTerm(Q.L('spicy')),
16+
Q.term('title', Q.glob('He??o')),
17+
Q.term('product', Q.and(Q.closedRange(100, undefined), Q.not(Q.L(600))))
18+
)
19+
);
20+
}
21+
22+
console.log(makeQuery());

examples/quickstart/node_modules

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../node_modules/

examples/quickstart/package.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "quickstart",
3+
"version": "1.0.0",
4+
"main": "index.ts",
5+
"license": "Apache-2.0",
6+
"private": true,
7+
"scripts": {
8+
"start": "ts-node index.ts"
9+
},
10+
"dependencies": {
11+
"solr-query-maker": "../../"
12+
},
13+
"devDependencies": {
14+
"ts-node": "^8.3.0",
15+
"typescript": "^3.5.3"
16+
}
17+
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
"lint": "yarn fix && yarn run check",
5656
"check": "yarn run pretty.check && gts check",
5757
"fix": "yarn run pretty.fix && gts fix",
58-
"test.examples": "echo 0",
58+
"test.examples": "cd examples/quickstart && ts-node index.ts",
5959
"preversion": "yarn test && yarn test.examples",
6060
"docs": "yarn clean && yarn build && rm -rf docs && mkdir -p docs && ( mocha --grep='#private' --invert -R markdown >docs/index.md )",
6161
"test-unit": "yarn test --grep='#e2e|#int' --invert",

0 commit comments

Comments
 (0)