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 Aditi Goyal <ad...@gmail.com> on 2008/10/29 12:15:42 UTC
Querying wildcard
Hi All,
I have been wanting to do a wildcard search with * as a first letter on an
index.
Is there a way out except for setAllowLeadingWildcard() of QueryParser to
true? Because, i have heard it is an expensive operation.
Thanks
Aditi
Re: Querying wildcard
Posted by Anshum <an...@gmail.com>.
Hi Aditi,
In that case I could suggest you to just index the domain name seperately as
well i.e. index the following fields : email adddess, domain name; instead
of just email address.
When I said reverse the tokens, you could reverse the tokens while
indexing(just flipping the text string while indexing) and search for
reverse string while searching.
Eric might have a better solution though ! :)
Let me know if that solves the issue.
--
Anshum Gupta
Naukri Labs!
http://ai-cafe.blogspot.com
The facts expressed here belong to everybody, the opinions to me. The
distinction is yours to draw............
On Thu, Oct 30, 2008 at 12:13 PM, Aditi Goyal <ad...@gmail.com>wrote:
> Thanks Anshum and Eric.
>
> Well, I was looking for something like searching by domain name in the
> email
> address etc.
> How can I reverse the tokens? Can you please explain in little detail?
>
> Thanks,
> Aditi
>
> On Thu, Oct 30, 2008 at 10:58 AM, Anshum <an...@gmail.com> wrote:
>
> > Hi Aditi,
> > As Eric mentioned, we'd need to know more to provide a rather apt
> solution.
> > At the same time, a prefix wildcard is a highly unoptimized thing for
> > lucene
> > because of the way the index is stored/read. Ideally you'd atleast want
> to
> > reverse the tokens as already mentioned.
> > This is because the index terms are lexically sorted while storing and so
> > the seem/fetch is efficient under normal cases(and not under the case of
> a
> > prefix wildcard).
> >
> > --
> > Anshum Gupta
> > Naukri Labs!
> > http://ai-cafe.blogspot.com
> >
> > The facts expressed here belong to everybody, the opinions to me. The
> > distinction is yours to draw............
> >
> >
> > On Wed, Oct 29, 2008 at 6:04 PM, Erick Erickson <erickerickson@gmail.com
> > >wrote:
> >
> > > Sure, there are many tricks. If you search the mail archives you'll
> > > find a bunch of them.
> > >
> > > One would be to reverse the tokens and make your leading
> > > wildcard queries into trailing ones on the reversed field.
> > >
> > > But without more details about what you're trying to accomplish,
> > > there's not much really useful advice we can offer.
> > >
> > > Best
> > > Erick
> > >
> > > On Wed, Oct 29, 2008 at 7:15 AM, Aditi Goyal <ad...@gmail.com>
> > > wrote:
> > >
> > > > Hi All,
> > > >
> > > > I have been wanting to do a wildcard search with * as a first letter
> on
> > > an
> > > > index.
> > > > Is there a way out except for setAllowLeadingWildcard() of
> QueryParser
> > to
> > > > true? Because, i have heard it is an expensive operation.
> > > >
> > > > Thanks
> > > > Aditi
> > > >
> > >
> >
>
Re: Querying wildcard
Posted by Aditi Goyal <ad...@gmail.com>.
Thanks Anshum and Eric.
Well, I was looking for something like searching by domain name in the email
address etc.
How can I reverse the tokens? Can you please explain in little detail?
Thanks,
Aditi
On Thu, Oct 30, 2008 at 10:58 AM, Anshum <an...@gmail.com> wrote:
> Hi Aditi,
> As Eric mentioned, we'd need to know more to provide a rather apt solution.
> At the same time, a prefix wildcard is a highly unoptimized thing for
> lucene
> because of the way the index is stored/read. Ideally you'd atleast want to
> reverse the tokens as already mentioned.
> This is because the index terms are lexically sorted while storing and so
> the seem/fetch is efficient under normal cases(and not under the case of a
> prefix wildcard).
>
> --
> Anshum Gupta
> Naukri Labs!
> http://ai-cafe.blogspot.com
>
> The facts expressed here belong to everybody, the opinions to me. The
> distinction is yours to draw............
>
>
> On Wed, Oct 29, 2008 at 6:04 PM, Erick Erickson <erickerickson@gmail.com
> >wrote:
>
> > Sure, there are many tricks. If you search the mail archives you'll
> > find a bunch of them.
> >
> > One would be to reverse the tokens and make your leading
> > wildcard queries into trailing ones on the reversed field.
> >
> > But without more details about what you're trying to accomplish,
> > there's not much really useful advice we can offer.
> >
> > Best
> > Erick
> >
> > On Wed, Oct 29, 2008 at 7:15 AM, Aditi Goyal <ad...@gmail.com>
> > wrote:
> >
> > > Hi All,
> > >
> > > I have been wanting to do a wildcard search with * as a first letter on
> > an
> > > index.
> > > Is there a way out except for setAllowLeadingWildcard() of QueryParser
> to
> > > true? Because, i have heard it is an expensive operation.
> > >
> > > Thanks
> > > Aditi
> > >
> >
>
Re: Querying wildcard
Posted by Anshum <an...@gmail.com>.
Hi Aditi,
As Eric mentioned, we'd need to know more to provide a rather apt solution.
At the same time, a prefix wildcard is a highly unoptimized thing for lucene
because of the way the index is stored/read. Ideally you'd atleast want to
reverse the tokens as already mentioned.
This is because the index terms are lexically sorted while storing and so
the seem/fetch is efficient under normal cases(and not under the case of a
prefix wildcard).
--
Anshum Gupta
Naukri Labs!
http://ai-cafe.blogspot.com
The facts expressed here belong to everybody, the opinions to me. The
distinction is yours to draw............
On Wed, Oct 29, 2008 at 6:04 PM, Erick Erickson <er...@gmail.com>wrote:
> Sure, there are many tricks. If you search the mail archives you'll
> find a bunch of them.
>
> One would be to reverse the tokens and make your leading
> wildcard queries into trailing ones on the reversed field.
>
> But without more details about what you're trying to accomplish,
> there's not much really useful advice we can offer.
>
> Best
> Erick
>
> On Wed, Oct 29, 2008 at 7:15 AM, Aditi Goyal <ad...@gmail.com>
> wrote:
>
> > Hi All,
> >
> > I have been wanting to do a wildcard search with * as a first letter on
> an
> > index.
> > Is there a way out except for setAllowLeadingWildcard() of QueryParser to
> > true? Because, i have heard it is an expensive operation.
> >
> > Thanks
> > Aditi
> >
>
Re: Querying wildcard
Posted by Erick Erickson <er...@gmail.com>.
Sure, there are many tricks. If you search the mail archives you'll
find a bunch of them.
One would be to reverse the tokens and make your leading
wildcard queries into trailing ones on the reversed field.
But without more details about what you're trying to accomplish,
there's not much really useful advice we can offer.
Best
Erick
On Wed, Oct 29, 2008 at 7:15 AM, Aditi Goyal <ad...@gmail.com> wrote:
> Hi All,
>
> I have been wanting to do a wildcard search with * as a first letter on an
> index.
> Is there a way out except for setAllowLeadingWildcard() of QueryParser to
> true? Because, i have heard it is an expensive operation.
>
> Thanks
> Aditi
>