Mailing List Archive

Can QueryParser parse regexp query?
Hi folks,
I'm currently trying to benchmark some regexp queries and found that the
default QueryParser (o.a.l.queryparser.classic.QueryParser) that luceneutil
is using is not able to parse regexps such as: "[abcde]+" or "a{1,5}".

The current workaround is to add another "if" logic in the TaskParser so
that when it sees "regexp" tag it will created a RegexpQuery without going
through QueryParser, but I still wonder whether that QueryParser is only
able to parse WildcardQuery but not RegexpQuery and do we have another
QueryParser that could parse the RegexpQuery?

Best,
Patrick
Re: Can QueryParser parse regexp query? [ In reply to ]
did you encode the query as a regexp: e.g. "/[abcde+/" or "/a{1,5}/" ?

https://lucene.apache.org/core/4_9_1/queryparser/org/apache/lucene/queryparser/classic/package-summary.html#Regexp_Searches

On Mon, Sep 13, 2021 at 1:22 PM Patrick Zhai <zhai7631@gmail.com> wrote:
>
> Hi folks,
> I'm currently trying to benchmark some regexp queries and found that the default QueryParser (o.a.l.queryparser.classic.QueryParser) that luceneutil is using is not able to parse regexps such as: "[abcde]+" or "a{1,5}".
>
> The current workaround is to add another "if" logic in the TaskParser so that when it sees "regexp" tag it will created a RegexpQuery without going through QueryParser, but I still wonder whether that QueryParser is only able to parse WildcardQuery but not RegexpQuery and do we have another QueryParser that could parse the RegexpQuery?
>
> Best,
> Patrick

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org
Re: Can QueryParser parse regexp query? [ In reply to ]
Ah thank you, I didn't know that before, I just tested and it parsed!

Robert Muir <rcmuir@gmail.com> ?2021?9?13??? ??10:30???

> did you encode the query as a regexp: e.g. "/[abcde+/" or "/a{1,5}/" ?
>
>
> https://lucene.apache.org/core/4_9_1/queryparser/org/apache/lucene/queryparser/classic/package-summary.html#Regexp_Searches
>
> On Mon, Sep 13, 2021 at 1:22 PM Patrick Zhai <zhai7631@gmail.com> wrote:
> >
> > Hi folks,
> > I'm currently trying to benchmark some regexp queries and found that the
> default QueryParser (o.a.l.queryparser.classic.QueryParser) that luceneutil
> is using is not able to parse regexps such as: "[abcde]+" or "a{1,5}".
> >
> > The current workaround is to add another "if" logic in the TaskParser so
> that when it sees "regexp" tag it will created a RegexpQuery without going
> through QueryParser, but I still wonder whether that QueryParser is only
> able to parse WildcardQuery but not RegexpQuery and do we have another
> QueryParser that could parse the RegexpQuery?
> >
> > Best,
> > Patrick
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
> For additional commands, e-mail: dev-help@lucene.apache.org
>
>