olivernn / lunr.js

A bit like Solr, but much smaller and not as bright
http://lunrjs.com
MIT License
8.89k stars 545 forks source link

Search on field with AND #344

Closed miraks31 closed 6 years ago

miraks31 commented 6 years ago

As documented (https://lunrjs.com/guides/searching.html):

I would like to search all documents having 'tags:foo' AND containing 'bar'. I tried:

How should I do? Is it a bug.

olivernn commented 6 years ago

First, check what version of Lunr you are using, term presence queries are only supported in version 2.2 and up.

Second, I think there might be a bug, you can try this out on the demo site:

Searching for documents with alan AND skylab: +alan +skylab returns just one result, this is correct. Restricting the term "alan" to the name field does not seem to work, the presence modifier seems to get ignored: +name:alan +skylab returns three results.

I'll take a closer look at this, thanks for reporting.

miraks31 commented 6 years ago

Thank you for this quick answer. For your information, I'm using lunr 2.1.5 (the version installed by npm install). Regards.

olivernn commented 6 years ago

Yeah, 2.1.5 does not have term presence support, you will need to upgrade to 2.2.0 to get term presence support.

miraks31 commented 6 years ago

Hi, When I launch a "npm install" with a package.json file containing this: "dependencies": { "lunr": "latest" }

Then, the version 2.1.5 is installed. If I try to force the version to 2.2.0, I get an error.

How can I install lunr 2.2.0 for node.js? Thank you in advance for your help. And thank you for lunr (I like it).

olivernn commented 6 years ago

Lunr 2.2.0 is definitely on npm and tagged as latest, perhaps you have some kind of npm proxy/mirror that hasn't been updated?

miraks31 commented 6 years ago

I successfully installed Lunr 2.2.0.

olivernn commented 6 years ago

I've just pushed 2.2.1 with a fix for the bug that caused the issues mentioned here, please take a look and let me know if you run into problems.

miraks31 commented 6 years ago

Hi,

This works well. Thank you for this VERY VERY fast correction !