tantivy
tantivy copied to clipboard
Add a lenient mode to QueryParser
The role of the QueryParser
is to give an off-the-shelf solution to people wanting to deliver a search box to end user.
Currently QueryParser::parse
can return an error if the query does not match our query grammar.
e.g.: +(happy
: the parenthesis is not closed.
This is great, but how should somebody writing a site handle this error? Maybe for a log analysis search engine, displaying an explicit syntax error is a good idea, but for most use case, (ecommerce, document search, etc.) we want to never return an error and just do our best to handle the user query.
For this reason, we want to add a new parse_lenient
that would never fail and always return a result.
pub fn parse_query_lenient(&self, query: &str) -> Box<Query> {
// ...
}
The behavior of this lenient mode does NOT have to be very smart... For instance, it could be a second very naive parser taking over when the initial parser failed.
For instance, this naive parser could remove all special characters and run the initial parser.
Smarter attempts to interpret the faulty user query are also welcome, as long as we return Box<Query>
and we are confident the code will never panic.
Not really a bug... but well.
Requires #57
If you can give me some more specs I'd be willing to take a look at this. I like things that are about making it better for the user
Improved the description. The ticket voluntarily does not give much implementation details.
What's the status of this? I see the opened PR has recently been closed, seemingly without result?
I'm currently working on a web application, which exposes search functionality to non-technical users, and I was hoping I could let them try their hands into using advanced queries, with some sort of fallback in case they fail. This would be just what the doctor ordered.
If #382 has merely stalled, and not dropped due to fundamental problems, I can put in the hours to get it over the finish line.
Any news on this? It's problematic we still don't have a lenient mode when exposing the search feature to non-technical users...
If someone wants to pick this feature it is up for grabs.
Reassigning to @trinity-1686a