Skip to content

Commit b7c3bb4

Browse files
committed
Add notice at the top of readme
1 parent 292ee6b commit b7c3bb4

File tree

5 files changed

+201
-6
lines changed

5 files changed

+201
-6
lines changed

README.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
[![Dependency Status](https://img.shields.io/librariesio/release/npm/lucene-query-string-builder?style=flat-square)](https://libraries.io/npm/lucene-query-string-builder)
66
[![Standard Code Style](https://img.shields.io/badge/code_style-standard-brightgreen.svg?style=flat-square)](https://standardjs.com)
77

8+
## Notice
9+
10+
*Lucene Query String Builder* is looking for a developer to help with the API.
11+
I'll continue performing the maintenance tasks.
12+
813
Easily build your lucene string queries using small and pure functions.
914

1015
Imagine having an API that leverages lucene for performing queries on the
@@ -85,7 +90,7 @@ https://lucene.apache.org/core/2_9_4/queryparsersyntax.html#Terms
8590
* or/and/not
8691
*
8792
* These functions are variadic and all work the same way. This example only
88-
shows the or but ot works similar with and and not
93+
shows the or but it works similar with and and not
8994
*/
9095

9196
_.or(_.term('hello'), _.term('world')); // => '"hello" OR "world"'
@@ -149,7 +154,7 @@ npx nyc npm t
149154
```
150155
```
151156
152-
157+
153158
> tape ./test/index.js
154159
155160
TAP version 13

README.mz

+6-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
[![Dependency Status](https://img.shields.io/librariesio/release/npm/lucene-query-string-builder?style=flat-square)](https://libraries.io/npm/lucene-query-string-builder)
66
[![Standard Code Style](https://img.shields.io/badge/code_style-standard-brightgreen.svg?style=flat-square)](https://standardjs.com)
77

8+
## Notice
9+
10+
*Lucene Query String Builder* is looking for a developer to help with the API.
11+
I'll continue performing the maintenance tasks.
12+
813
Easily build your lucene string queries using small and pure functions.
914

1015
Imagine having an API that leverages lucene for performing queries on the
@@ -85,7 +90,7 @@ https://lucene.apache.org/core/2_9_4/queryparsersyntax.html#Terms
8590
* or/and/not
8691
*
8792
* These functions are variadic and all work the same way. This example only
88-
shows the or but ot works similar with and and not
93+
shows the or but it works similar with and and not
8994
*/
9095

9196
_.or(_.term('hello'), _.term('world')); // => '"hello" OR "world"'

README.mz.bak

+185
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
# Lucene Query String Builder
2+
3+
[![NPM](https://img.shields.io/npm/v/lucene-query-string-builder?color=blue&style=flat-square)](https://www.npmjs.com/package/lucene-query-string-builder)
4+
[![NPM Downloads](https://img.shields.io/npm/dm/lucene-query-string-builder?style=flat-square)](https://www.npmjs.com/package/lucene-query-string-builder)
5+
[![Dependency Status](https://img.shields.io/librariesio/release/npm/lucene-query-string-builder?style=flat-square)](https://libraries.io/npm/lucene-query-string-builder)
6+
[![Standard Code Style](https://img.shields.io/badge/code_style-standard-brightgreen.svg?style=flat-square)](https://standardjs.com)
7+
8+
## Notice
9+
10+
*Lucene Query String Builder* is looking for a developer to help with the API.
11+
I'll continue performing the maintenance tasks.
12+
13+
Easily build your lucene string queries using small and pure functions.
14+
15+
Imagine having an API that leverages lucene for performing queries on the
16+
(indexed) database. In that case you might want to generate lucene query strings on
17+
the client/front end.
18+
19+
The usage section shows how you can leverage this lib for your purposes.
20+
21+
## Setup
22+
23+
```bash
24+
npm install lucene-query-string-builder --save
25+
```
26+
27+
## Features
28+
29+
- escapes lucene special chars when creating a term string
30+
- contains all the operators lucene uses
31+
- simple lucene.builder function for defining a lucene query builder
32+
33+
## Usage
34+
35+
Let's see how you can use lucene query string builder to define lucene query
36+
strings with simple JavaScript functions.
37+
38+
Assuming that the lucene global variable contains the lucene functions. This
39+
would be the default when loaded into a browser.
40+
41+
```JavaScript
42+
43+
var findUserLuceneQueryString = lucene.builder(function(data){
44+
45+
// just to make the example more readable;
46+
var _ = lucene;
47+
48+
return _.group(_.and(
49+
_.field('eye-color', _.term(data.eye.color)),
50+
_.field('age', _.range(data.age.min, data.age.max))
51+
));
52+
53+
});
54+
55+
var luceneQueryString = findUserLuceneQueryString({
56+
eye: { color: 'brown'},
57+
age: {
58+
min: 10,
59+
max: 20
60+
}
61+
});
62+
63+
luceneQueryString === '( eye-color: "brown" AND age:{ 10 TO 20 } )' // => true
64+
65+
```
66+
The functions are based on the lucene specifications found here:
67+
https://lucene.apache.org/core/2_9_4/queryparsersyntax.html#Terms
68+
69+
```JavaScript
70+
71+
var _ = lucene;
72+
73+
/***
74+
* terms or term
75+
*/
76+
77+
_.term('hello'); // => '"hello"'
78+
79+
_.terms('hello world'); // => '"hello world"'
80+
81+
82+
/***
83+
* field
84+
*/
85+
86+
_.field('hello', _.term('world')); // => 'hello: "world"'
87+
88+
89+
/***
90+
* or/and/not
91+
*
92+
* These functions are variadic and all work the same way. This example only
93+
shows the or but ot works similar with and and not
94+
*/
95+
96+
_.or(_.term('hello'), _.term('world')); // => '"hello" OR "world"'
97+
98+
_.or(_.term('hello'), _.term('you'), _.term('world')); // => '"hello" OR "you" OR "world"'
99+
100+
101+
/***
102+
* group
103+
*
104+
* Is a variadic function too
105+
*/
106+
107+
_.group(_.term('hello'), _.term('you'), _.term('world')); // => '( "hello" "you" "world" )'
108+
109+
110+
/***
111+
* range
112+
*
113+
* Takes two strings and 2 booleans.
114+
*/
115+
116+
/* combined with the field function to query for ages between 10 and 20 */
117+
_.field('age', _.range(10, 20)); // => 'age: { 10 TO 20 }'
118+
119+
120+
/***
121+
* fuzzy
122+
*/
123+
124+
_.fuzzy(_.term('hello'), 0.2); // => '"hello"~0.2'
125+
126+
127+
/***
128+
* proximity
129+
*/
130+
131+
_.proximity("a", "c", 2); // => '"a b"'~2
132+
133+
134+
/***
135+
* required
136+
*/
137+
138+
_.required(_.term('required')); // => '+"required"'
139+
140+
```
141+
142+
## Tests
143+
144+
```bash bash
145+
set -eo pipefail
146+
147+
{
148+
npm i
149+
npm prune
150+
} > /dev/null
151+
152+
npx standard --fix
153+
npx nyc npm t
154+
```
155+
156+
## Contributing
157+
158+
I have not gotten the chance to use this lib in my own projects. Please share
159+
your thoughts, issues and improvements.
160+
161+
- Make sure your dependencies are installed by running: `npm run-script setup`
162+
- Then start editing the index.js
163+
- You should add and/or edit the tests in test/index.js
164+
- Run your tests and see what happens
165+
166+
When performing pull request make sure to not add the **dist** files. This is left
167+
to the maintainers(s) of the library. They are responsible to version and avoid
168+
code breakages.
169+
170+
You can perform your own build with `npm run-script` build to make a *lucine.js* and
171+
a *lucine.min.js*
172+
173+
**notice**
174+
175+
I am currently not using this repository in any of my projects. Therefore I am looking
176+
for people that are able to make LQSB more useful for them and others.
177+
178+
## Road map
179+
180+
- split all functions into separate files
181+
- tasks for running tests on dist/lucene.js and dist/lucene.min.js
182+
183+
## License
184+
185+
The MIT License (MIT)

package-lock.json

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

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lucene-query-string-builder",
3-
"version": "1.0.6",
3+
"version": "1.0.7",
44
"description": "Build Lucene queries by defining lucene query builders",
55
"main": "index.js",
66
"repository": {

0 commit comments

Comments
 (0)