lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adriano Crestani <adrianocrest...@gmail.com>
Subject Re: How to combine QueryParser and Wildcard search
Date Fri, 19 Nov 2010 19:08:38 GMT
Hi Pulkit,

In case you are using the standard contrib query parser (equivalent to
lucence QP), you may want to create a QueryNodeProcessor, that will convert
TermQueryNodes to WildcardQueryNodes, and attach it to the processor
pipeline:

StandardQueryParser qp = new StandardQueryParser();
((QueryNodeProcessorPipeline) qp.getQueryNodeProcessor()).add(new
MyQueryNodeProcessor());

// qp is ready for use


Please, let me know if you have any question about how to implement your own
QueryNodeProcessor.

Regards,
Adriano Crestani

On Fri, Nov 19, 2010 at 9:40 AM, Israel Tsadok <itsadok@gmail.com> wrote:

> I'm not sure what you're trying to do, but it seems to me that your best
> bet
> is to rewrite the query returned from the QueryParser. Just traverse the
> BooleanQuery clauses, converting any TermQuery to a WildcardQuery. You can
> then have control over what transformation exactly you want to perform.
>
> Israel
>
>
> On Thu, Nov 18, 2010 at 5:36 PM, Pulkit Singhal <pulkitsinghal@gmail.com
> >wrote:
>
> > Hello,
> >
> > I was wondering if there is any API call in Lucene that allows
> > something like the following:
> >
> > Step 1: Take the user input
> > "hello world" you are beautiful
> >
> > Step 2: QueryParser does its thing
> > defaultField:hello world defaultField:you defaultField:are
> > defaultField:beautiful
> >
> > Step 3: And somehow a desired transformation like the following one is
> > the next thing to happen:
> > defaultField:hello world defaultField:you* defaultField:are*
> > defaultField:beautiful*
> >
> > How can I tell QueryParser to throw in the wildcard "*" expression
> > where applicable?
> >
> > You can see that I'm not expecting it to use "*" with something that
> > will turn into a phrase query:
> > "hello world" becomes defaultField:hello world
> > Just the rest of the tokens:
> > defaultField:you* defaultField:are* defaultField:beautiful*
> >
> > Thanks!
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> > For additional commands, e-mail: java-user-help@lucene.apache.org
> >
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message