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 ra...@barclays.com on 2013/11/18 04:14:17 UTC

How to perform Wildcard search when using WhitespaceAnalyzer?

Hi All,



Sorry to repeat this question from my previous mail chain, but I am hoping the modified subject will catch someone's attention - in case they are familiar with this situation.



Could any one please suggest if it is possible to perform Leading and / or trailing wildcard searches using WhitespaceAnalyzer? I was able to do such searches using StandardAnalyzer but Lucene Search simply seems to ignore the wildcards with WhitespaceAnalyzer. The issue is also not with the case as I have ensured that the case both in index and search terms are the same.



WhitespaceAnalyzer works well for my cause, hence I don't want to switch back to StandardAnalyzer.



////////////// Code //////////////



strBufSearchString.append("\"" + QueryParser.escape(strTxtSearchString.trim().toUpperCase()) + "*" + "\"");



Analyzer analyzer = new WhitespaceAnalyzer(Version.LUCENE_43);

QueryParser parser = new QueryParser(Version.LUCENE_43, "CONTENTS", analyzer);



query = parser.parse(strBufSearchString.toString());



//////////////////////////////////////////



Please suggest. It is real urgent.. Appreciate any possible help!



Regards,

Raghu



_______________________________________________

This message is for information purposes only, it is not a recommendation, advice, offer or solicitation to buy or sell a product or service nor an official confirmation of any transaction. It is directed at persons who are professionals and is not intended for retail customer use. Intended for recipient only. This message is subject to the terms at: www.barclays.com/emaildisclaimer.

For important disclosures, please see: www.barclays.com/salesandtradingdisclaimer regarding market commentary from Barclays Sales and/or Trading, who are active market participants; and in respect of Barclays Research, including disclosures relating to specific issuers, please see http://publicresearch.barclays.com.

_______________________________________________

Re: How to perform Wildcard search when using WhitespaceAnalyzer?

Posted by Jack Krupansky <ja...@basetechnology.com>.
As I indicated in my previous message, we need actual queries and the actual 
indexed data where matches are failing.

Note that *NALYZE will not match ANALYZER. So, it might be that you have 
composed queries in which some of the terms match properly and only some 
fail.

-- Jack Krupansky

-----Original Message----- 
From: raghavendra.k.rao@barclays.com
Sent: Monday, November 18, 2013 9:32 AM
To: java-user@lucene.apache.org
Subject: RE: How to perform Wildcard search when using WhitespaceAnalyzer?

Jack,

I am using WhitespaceAnalyzer while both indexing and searching the data. To 
avoid the case-sensitive dependency, I ensure that both of them are 
upper-cased.

I generally search against the space separated CONTENTS field for the search 
terms. Hence while searching, I can imagine WhitespaceAnalyzer breaking my 
string based on white spaces.

For eg. there are values in index such as ANALYZER. I am trying to make 
searches such as ANALYZ* and *NALYZE find these kinds of values. In other 
words, both leading and trailing wild card searches.

Will provide detailed code if necessary. Please let me know what you think.

Regards,
Raghu


-----Original Message-----
From: Jack Krupansky [mailto:jack@basetechnology.com]
Sent: Monday, November 18, 2013 12:00 AM
To: java-user@lucene.apache.org
Subject: Re: How to perform Wildcard search when using WhitespaceAnalyzer?

The presence of a wildcard character causes the query parser to completely 
skip analysis for that term.

You, the writer of the query terms, need to manually simulate all the the 
work that the analyzer does when a wildcard is present in a term.

What does your query actually look like, and what does the indexed data look 
like?

The simple answer to your question is that wildcards don't behave any 
differently between the two analyzers - simply because they are not used at 
all for the wildcard terms.

-- Jack Krupansky

-----Original Message-----
From: raghavendra.k.rao@barclays.com
Sent: Sunday, November 17, 2013 10:14 PM
To: java-user@lucene.apache.org
Subject: How to perform Wildcard search when using WhitespaceAnalyzer?

Hi All,



Sorry to repeat this question from my previous mail chain, but I am hoping 
the modified subject will catch someone's attention - in case they are 
familiar with this situation.



Could any one please suggest if it is possible to perform Leading and / or 
trailing wildcard searches using WhitespaceAnalyzer? I was able to do such 
searches using StandardAnalyzer but Lucene Search simply seems to ignore the 
wildcards with WhitespaceAnalyzer. The issue is also not with the case as I 
have ensured that the case both in index and search terms are the same.



WhitespaceAnalyzer works well for my cause, hence I don't want to switch 
back to StandardAnalyzer.



////////////// Code //////////////



strBufSearchString.append("\"" +
QueryParser.escape(strTxtSearchString.trim().toUpperCase()) + "*" + "\"");



Analyzer analyzer = new WhitespaceAnalyzer(Version.LUCENE_43);

QueryParser parser = new QueryParser(Version.LUCENE_43, "CONTENTS",
analyzer);



query = parser.parse(strBufSearchString.toString());



//////////////////////////////////////////



Please suggest. It is real urgent.. Appreciate any possible help!



Regards,

Raghu



_______________________________________________

This message is for information purposes only, it is not a recommendation,
advice, offer or solicitation to buy or sell a product or service nor an
official confirmation of any transaction. It is directed at persons who are
professionals and is not intended for retail customer use. Intended for
recipient only. This message is subject to the terms at:
www.barclays.com/emaildisclaimer.

For important disclosures, please see:
www.barclays.com/salesandtradingdisclaimer regarding market commentary from
Barclays Sales and/or Trading, who are active market participants; and in
respect of Barclays Research, including disclosures relating to specific
issuers, please see http://publicresearch.barclays.com.

_______________________________________________


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

_______________________________________________

This message is for information purposes only, it is not a recommendation, 
advice, offer or solicitation to buy or sell a product or service nor an 
official confirmation of any transaction. It is directed at persons who are 
professionals and is not intended for retail customer use. Intended for 
recipient only. This message is subject to the terms at: 
www.barclays.com/emaildisclaimer.

For important disclosures, please see: 
www.barclays.com/salesandtradingdisclaimer regarding market commentary from 
Barclays Sales and/or Trading, who are active market participants; and in 
respect of Barclays Research, including disclosures relating to specific 
issuers, please see http://publicresearch.barclays.com.

_______________________________________________

---------------------------------------------------------------------
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: How to perform Wildcard search when using WhitespaceAnalyzer?

Posted by ra...@barclays.com.
Jack,

I am using WhitespaceAnalyzer while both indexing and searching the data. To avoid the case-sensitive dependency, I ensure that both of them are upper-cased.

I generally search against the space separated CONTENTS field for the search terms. Hence while searching, I can imagine WhitespaceAnalyzer breaking my string based on white spaces.

For eg. there are values in index such as ANALYZER. I am trying to make searches such as ANALYZ* and *NALYZE find these kinds of values. In other words, both leading and trailing wild card searches.

Will provide detailed code if necessary. Please let me know what you think.

Regards,
Raghu


-----Original Message-----
From: Jack Krupansky [mailto:jack@basetechnology.com] 
Sent: Monday, November 18, 2013 12:00 AM
To: java-user@lucene.apache.org
Subject: Re: How to perform Wildcard search when using WhitespaceAnalyzer?

The presence of a wildcard character causes the query parser to completely skip analysis for that term.

You, the writer of the query terms, need to manually simulate all the the work that the analyzer does when a wildcard is present in a term.

What does your query actually look like, and what does the indexed data look like?

The simple answer to your question is that wildcards don't behave any differently between the two analyzers - simply because they are not used at all for the wildcard terms.

-- Jack Krupansky

-----Original Message-----
From: raghavendra.k.rao@barclays.com
Sent: Sunday, November 17, 2013 10:14 PM
To: java-user@lucene.apache.org
Subject: How to perform Wildcard search when using WhitespaceAnalyzer?

Hi All,



Sorry to repeat this question from my previous mail chain, but I am hoping the modified subject will catch someone's attention - in case they are familiar with this situation.



Could any one please suggest if it is possible to perform Leading and / or trailing wildcard searches using WhitespaceAnalyzer? I was able to do such searches using StandardAnalyzer but Lucene Search simply seems to ignore the wildcards with WhitespaceAnalyzer. The issue is also not with the case as I have ensured that the case both in index and search terms are the same.



WhitespaceAnalyzer works well for my cause, hence I don't want to switch back to StandardAnalyzer.



////////////// Code //////////////



strBufSearchString.append("\"" + 
QueryParser.escape(strTxtSearchString.trim().toUpperCase()) + "*" + "\"");



Analyzer analyzer = new WhitespaceAnalyzer(Version.LUCENE_43);

QueryParser parser = new QueryParser(Version.LUCENE_43, "CONTENTS", 
analyzer);



query = parser.parse(strBufSearchString.toString());



//////////////////////////////////////////



Please suggest. It is real urgent.. Appreciate any possible help!



Regards,

Raghu



_______________________________________________

This message is for information purposes only, it is not a recommendation, 
advice, offer or solicitation to buy or sell a product or service nor an 
official confirmation of any transaction. It is directed at persons who are 
professionals and is not intended for retail customer use. Intended for 
recipient only. This message is subject to the terms at: 
www.barclays.com/emaildisclaimer.

For important disclosures, please see: 
www.barclays.com/salesandtradingdisclaimer regarding market commentary from 
Barclays Sales and/or Trading, who are active market participants; and in 
respect of Barclays Research, including disclosures relating to specific 
issuers, please see http://publicresearch.barclays.com.

_______________________________________________ 


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

_______________________________________________

This message is for information purposes only, it is not a recommendation, advice, offer or solicitation to buy or sell a product or service nor an official confirmation of any transaction. It is directed at persons who are professionals and is not intended for retail customer use. Intended for recipient only. This message is subject to the terms at: www.barclays.com/emaildisclaimer.

For important disclosures, please see: www.barclays.com/salesandtradingdisclaimer regarding market commentary from Barclays Sales and/or Trading, who are active market participants; and in respect of Barclays Research, including disclosures relating to specific issuers, please see http://publicresearch.barclays.com.

_______________________________________________

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


Re: How to perform Wildcard search when using WhitespaceAnalyzer?

Posted by Jack Krupansky <ja...@basetechnology.com>.
The presence of a wildcard character causes the query parser to completely 
skip analysis for that term.

You, the writer of the query terms, need to manually simulate all the the 
work that the analyzer does when a wildcard is present in a term.

What does your query actually look like, and what does the indexed data look 
like?

The simple answer to your question is that wildcards don't behave any 
differently between the two analyzers - simply because they are not used at 
all for the wildcard terms.

-- Jack Krupansky

-----Original Message----- 
From: raghavendra.k.rao@barclays.com
Sent: Sunday, November 17, 2013 10:14 PM
To: java-user@lucene.apache.org
Subject: How to perform Wildcard search when using WhitespaceAnalyzer?

Hi All,



Sorry to repeat this question from my previous mail chain, but I am hoping 
the modified subject will catch someone's attention - in case they are 
familiar with this situation.



Could any one please suggest if it is possible to perform Leading and / or 
trailing wildcard searches using WhitespaceAnalyzer? I was able to do such 
searches using StandardAnalyzer but Lucene Search simply seems to ignore the 
wildcards with WhitespaceAnalyzer. The issue is also not with the case as I 
have ensured that the case both in index and search terms are the same.



WhitespaceAnalyzer works well for my cause, hence I don't want to switch 
back to StandardAnalyzer.



////////////// Code //////////////



strBufSearchString.append("\"" + 
QueryParser.escape(strTxtSearchString.trim().toUpperCase()) + "*" + "\"");



Analyzer analyzer = new WhitespaceAnalyzer(Version.LUCENE_43);

QueryParser parser = new QueryParser(Version.LUCENE_43, "CONTENTS", 
analyzer);



query = parser.parse(strBufSearchString.toString());



//////////////////////////////////////////



Please suggest. It is real urgent.. Appreciate any possible help!



Regards,

Raghu



_______________________________________________

This message is for information purposes only, it is not a recommendation, 
advice, offer or solicitation to buy or sell a product or service nor an 
official confirmation of any transaction. It is directed at persons who are 
professionals and is not intended for retail customer use. Intended for 
recipient only. This message is subject to the terms at: 
www.barclays.com/emaildisclaimer.

For important disclosures, please see: 
www.barclays.com/salesandtradingdisclaimer regarding market commentary from 
Barclays Sales and/or Trading, who are active market participants; and in 
respect of Barclays Research, including disclosures relating to specific 
issuers, please see http://publicresearch.barclays.com.

_______________________________________________ 


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