lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Irving, Dave" <dave.irv...@logicacmg.com>
Subject RE: Building queries
Date Wed, 17 May 2006 13:13:46 GMT
Hi, 

...

>> So, I just need to run the terms entered by the user in each field 
>> against the appropriate analyser, and build up the query that way. 
>> Does that sound like a sensible approach? Are there any 
>> code samples 
>> around showing how to run search phrases through analysers 
>> and build 
>> up a query?
>>

> Warning! I'm relatively new to Lucene to, so you are 
> warned.. What I 
> did
> was add in the underlying index terms to the string, and use 
> a PerFieldAnalyzerWrapper to "do the right thing" with 
> QueryParser. Kinda like this...
> 
> Let's say you have two fields, F1 and F2 that are indexed as 
> IDX1 and IDX2.
> The user enters "clause1" and "clause2" in the fields, respectively.
> Construct something like
> IDX1:(clause1) IDX2:(clause2) as a string.
> Construct a PerFieldAnalyzerWrapper for fields IDX1 and IDX2, 
> call it pFAW
> 
> Construct a QueryParser (qp) with the default field and 
> analyzer wrapper (pFAW), and then you can call 
> qp.parse(constructed string);
> 

If I understand that correctly, you're saying I supply QueryParser with
a per field analyser wrapper which delegates to the correct analyser for
each field - allowing Query Parser to build up the correct query - yeah?

This kinda leads me back to my "best practises" question: If Im building
up the query dynamically based off of several fields (rather than the
user entering a Lucene Query), Im kind of wondering If I should be using
query parser at all...?! I keep feeling that maybe I should just be
building up the Query programatically (although dynamically) based off
the fields.

But all the examples I can find seem to transform already split UI
fields back in to a single lucene query string and then put them through
a parser. 
However, if I don't use the QueryParser, I guess I've got to manually
run each field through the appropriate analyser as Im building up the
query terms. 



> Additional warning: watch out for TooManyClausesException if 
> you intend to allow wildcards. See the thread in this list "I 
> just don't get wildcards at all" for an exposition "the guys" 
> gave me on this issue.

Thanks for the tip - I don't think I'll be using wildcards though - so
hopefully I'll escape this problem :o)

> Best
> Erick
> 


This e-mail and any attachment is for authorised use by the intended recipient(s) only. It
may contain proprietary material, confidential information and/or be subject to legal privilege.
It should not be copied, disclosed to, retained or used by, any other party. If you are not
an intended recipient then please promptly delete this e-mail and any attachment and all copies
and inform the sender. Thank you.

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message