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

Xapian queryparser fails when the querystring contains ampersand or other non words #536

Closed
maneeshpm opened this issue Apr 15, 2021 · 1 comment · Fixed by #534
Closed
Assignees
Milestone

Comments

@maneeshpm
Copy link
Collaborator

Refer f667d38
We get a xapian exception while trying to parse "Alice & Bob". The error arises because Xapian operators OP_PHRASE and OP_NEAR only support leaf subqueries.

@maneeshpm maneeshpm self-assigned this Apr 15, 2021
@maneeshpm maneeshpm changed the title Xapian queryparser fails when the querystring contains ampersand Xapian queryparser fails when the querystring contains ampersand or other non words Apr 15, 2021
@maneeshpm
Copy link
Collaborator Author

@veloman-yunkan Documenting the following issues about using Xapian Query Parser with OP_PHRASE/OP_NEAR as default operator for future reference:

  • Standalone ampersand works fine. "&" gets parsed to "", it gets escaped.
  • For some reason, ampersand with exactly two words works fine as well. "Alice & bob" gets parsed to "alice bob".
  • As the number of words increases xapian throws an error. "0posanchor Alice & Bob" fails. This also fails at any combination of 3+ words with an ampersand anywhere in between terms or at the beginning. For some reason, it works when the ampersand is at the end.

This was the reason for the failure of the unit test. "Alice & Bob" got parsed till subquery_phrase but failed on subqery_anchored due to the additional anchor term.

As far as fixing this issue is concerned, as you suggested we should use OP_OR as default operator and bind the terms using a query constructor with OP_PHRASE.

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

Successfully merging a pull request may close this issue.

2 participants