Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search on field with AND #344

Closed
miraks31 opened this issue May 17, 2018 · 8 comments
Closed

Search on field with AND #344

miraks31 opened this issue May 17, 2018 · 8 comments

Comments

@miraks31
Copy link

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

  • we must use something like 'tags:foo' if we want to search on field 'tags'.
  • we must use '+foo +bar' if we want to search 'foo' AND 'bar'

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

  • 'tags:foo +bar' ==> WRONG result (Applied as a OR)
  • 'tags:+foo +bar' ==> WRONG result (no result, may be because +foo is not a tag)
  • '+tags:foo +bar' ==> SYNTAX ERROR (unrecognised field '+tags', possible fields: 'text', 'title', 'tags')

How should I do?
Is it a bug.

@olivernn
Copy link
Owner

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
Copy link
Author

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

@olivernn
Copy link
Owner

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
Copy link
Author

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
Copy link
Owner

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
Copy link
Author

I successfully installed Lunr 2.2.0.

@olivernn
Copy link
Owner

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
Copy link
Author

Hi,

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants