Yep - that's a good one. Only it may be a very heavy query, and throw TooManyClausesException, if the number of terms that start with the prefix is too much. But that certainly would work. BTW - MultiPhraseQuery's documentation specifically explains how to use it for exactly the same purpose.
On Nov 22, 2007 6:19 PM, mark harwood <[EMAIL PROTECTED]> wrote: > >>Re: help required urgent!!!!!!!!!!! > > Yikes!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! > > I'm guessing that the question was more about how to support this in the > standard query syntax where there are multiple words. > > i.e. http://www.google.com/search?q=lucene+wildcard+in+phrase > > This post seems close to a solution to that problem: > > http://mail-archives.apache.org/mod_mbox/lucene-java-user/200607.mbox/[EMAIL > PROTECTED] > > > Cheers, > Mark > > > ----- Original Message ---- > From: Shai Erera <[EMAIL PROTECTED]> > To: [email protected] > Sent: Thursday, 22 November, 2007 3:54:51 PM > Subject: Re: help required urgent!!!!!!!!!!! > > Hi > > You can simply create a PrefixQuery. However, if you're using > StandardAnalyzer, and the word is added as Index.TOKENIZED, > sotf-wa<something> will be broken to 'soft' and 'wa<something>'. > Therefore > you'll need to add the word as Index.UN_TOKENIZED, or use a different > Analyzer when you index the data (for this field at least). > > Here's a sample code: > > // Indexing. > Document doc = new Document(); > doc.add(new Field("field", "soft-wash", Store.NO, > Index.UN_TOKENIZED > )); > > // Search > Query q = new PrefixQuery(new Term("field", "soft-wa")); > > Does that help? > > On Nov 22, 2007 5:46 PM, Shakti_Sareen <[EMAIL PROTECTED]> > wrote: > > > Hi > > I am using StandardAnalyser() to index the data. > > But I want to do a like search on a word containing Hyphen > > For example it want to search a word "soft-wa*" > > > > I am getting no hits for that. It is said that if the hyphen is there > in > > the word, then we should include that word in the double quotes ("). > But > > enclosing the word in a double quotes (") means the exact word > search. > > > > How can I perform the like search on a word containing hyphen??????? > > > > Please help. > > > > Regards, > > Shakti Sareen > > > > > > > > > > > > DISCLAIMER: > > This email (including any attachments) is intended for the sole use > of the > > intended recipient/s and may contain material that is CONFIDENTIAL > AND > > PRIVATE COMPANY INFORMATION. Any review or reliance by others or > copying or > > distribution or forwarding of any or all of the contents in this > message is > > STRICTLY PROHIBITED. If you are not the intended recipient, please > contact > > the sender by email and delete all copies; your cooperation in this > regard > > is appreciated. > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > -- > Regards, > > Shai Erera > > > > > > ___________________________________________________________ > Want ideas for reducing your carbon footprint? Visit Yahoo! For Good > http://uk.promotions.yahoo.com/forgood/environment.html > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- Regards, Shai Erera
