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

Handle single-word phrases enclosed in quotes as phrase queries in search parsing #2778

Closed
marevol opened this issue Nov 2, 2023 · 0 comments
Assignees
Milestone

Comments

@marevol
Copy link
Contributor

marevol commented Nov 2, 2023

We will modify the parsing process to treat single-word terms enclosed within double quotes as phrase queries. This change aims to allow users to search for exact phrases, even if the phrase is just a single word.

The planned changes will involve updating the QueryParser.java class:

  1. We will introduce a new LuceneQueryParser class that extends org.apache.lucene.queryparser.classic.QueryParser.
  2. In LuceneQueryParser, we will override the getFieldQuery method to handle the specific case where a quoted term should be processed as a PhraseQuery instead of a TermQuery.
  3. We will also add a splitField method to assist in handling default fields and field extensions.

These modifications will help refine the search functionality to meet our users' expectations for phrase searching capabilities.

The specific code changes are as follows:

  • Replace ExtendableQueryParser with LuceneQueryParser, which contains the updated logic.
  • Implement the custom getFieldQuery method to check for quoted terms and build a PhraseQuery accordingly.
@marevol marevol added this to the 14.12.0 milestone Nov 2, 2023
@marevol marevol self-assigned this Nov 2, 2023
@marevol marevol closed this as completed in 6d0530a Nov 2, 2023
marevol added a commit that referenced this issue Dec 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant