Commit 827bb536 authored by Robin Bron's avatar Robin Bron

Example working again; <implicit> operator not required

parent 14e4534b
Pipeline #65656799 failed with stages
in 1 minute and 53 seconds
......@@ -21,7 +21,11 @@ For a better overview of what's possible, take a look at [lucene-query-parser][l
### Node.JS
```javascript
const lucene = require('lucene-filter');
// Either of these is supported
const lucene = require('lucene-filter')(require('lucene'));
const lucene = require('lucene-filter')(require('lucene-queryparser'));
const lucene = require('lucene-filter')(require('lucene-query-parser'));
```
### Browser
......@@ -38,7 +42,7 @@ const lucene = require('lucene-filter');
'boost' set by the query. Returning the data when matching is also possible using `.passthrough`.
```js
const lucene = require('lucene-filter');
const lucene = require('lucene-filter')(require('lucene'));
let result;
const data = [
......
const lucene = require('./src/index');
const lucene = require('./src/index')(require('lucene'));
let result;
const data = [
......
This diff is collapsed.
......@@ -35,10 +35,5 @@
"query",
"search",
"engine"
],
"optionalDependencies": {
"lucene": "^2.0.2",
"lucene-query-parser": "^1.2.0",
"lucene-queryparser": "^3.0.0"
}
]
}
......@@ -13,14 +13,14 @@ const lucene = module.exports = function factory( parser ) {
// Returns Function(Object):Number
function compile(query) {
if ('string' !== typeof query) return ()=>0;
if (!query) return ()=>0;
// Actually compile what was given
try {
query = parser.parse(query);
} catch(e) {
return ()=>0;
if ('string' === typeof query) {
try {
query = parser.parse(query);
} catch(e) {
return ()=>0;
}
}
// Compile multi-query
......@@ -36,6 +36,7 @@ const lucene = module.exports = function factory( parser ) {
return compile(query.left);
}
// Ensure default boost
query.boost = query.boost || 1;
......
......@@ -3,4 +3,3 @@ operators['OR'] = require('./or');
operators['AND'] = require('./and');
operators['OR NOT'] = require('./or-not')(operators);
operators['AND NOT'] = require('./and-not')(operators);
operators['<implicit>'] = require('./and')(operators);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment