You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Rajnish Kamboj <ra...@gmail.com> on 2016/10/14 14:21:50 UTC
Performance of Prefix, Wildcard and Regex queries?
Hi
Performance of Prefix, Wildcard and Regex queries?
Does Lucene internally optimizes this (using rewrite or something else) or
I have to manually create specific queries depending on input pattern.
Example
if input is 78* create Prefix query
if input is 87?98* create Wildcard query
if input is 87[7-5]* create Regex query.
--
Rajnish
Re: Performance of Prefix, Wildcard and Regex queries?
Posted by Michael McCandless <lu...@mikemccandless.com>.
It doesn't matter at all if you try to e.g. optimize a WildcardQuery
like foo* into a PrefixQuery, because Lucene turns all of these
queries into an AutomatonQuery anyway, which efficiently intersects a
term automaton with the terms dictionary.
Mike McCandless
http://blog.mikemccandless.com
On Sun, Oct 16, 2016 at 8:54 PM, Trejkaz <tr...@trypticon.org> wrote:
> On Sat, Oct 15, 2016 at 1:21 AM, Rajnish Kamboj <ra...@gmail.com> wrote:
>> Hi
>>
>> Performance of Prefix, Wildcard and Regex queries?
>> Does Lucene internally optimizes this (using rewrite or something else) or
>> I have to manually create specific queries depending on input pattern.
>>
>> Example
>> if input is 78* create Prefix query
>> if input is 87?98* create Wildcard query
>> if input is 87[7-5]* create Regex query.
>
> I think QueryParser already takes care of converting to PrefixQuery
> when possible.
>
> Regexes aren't really possible, though. Consider this:
>
> abc* (wildcard query, matching abc followed by anything)
>
> Versus this:
>
> abc* (regex query, matching ab followed by 0 or more c)
>
> I think for that, you're going to want additional syntax in your query parser.
>
> TX
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: Performance of Prefix, Wildcard and Regex queries?
Posted by Trejkaz <tr...@trypticon.org>.
On Sat, Oct 15, 2016 at 1:21 AM, Rajnish Kamboj <ra...@gmail.com> wrote:
> Hi
>
> Performance of Prefix, Wildcard and Regex queries?
> Does Lucene internally optimizes this (using rewrite or something else) or
> I have to manually create specific queries depending on input pattern.
>
> Example
> if input is 78* create Prefix query
> if input is 87?98* create Wildcard query
> if input is 87[7-5]* create Regex query.
I think QueryParser already takes care of converting to PrefixQuery
when possible.
Regexes aren't really possible, though. Consider this:
abc* (wildcard query, matching abc followed by anything)
Versus this:
abc* (regex query, matching ab followed by 0 or more c)
I think for that, you're going to want additional syntax in your query parser.
TX
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org