You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@lucenenet.apache.org by Robert Pohl <ro...@f-i.com> on 2008/06/12 15:42:59 UTC

Searching with odd chars

Hi List!

Another question regarding the standard analyzer:

If I search for "adidas - dream big" which is the exact title of a indexed
item, it does not show up in the hits. It does if I remove the "-". Should
it not trigger on the other words it the analyzer removes the "-" ?

Thanks

//rob

ROBERT POHL
Senior Application Developer • Fi Stockholm
 
T: +46 8 402 17 40
robert.pohl@f-i.com  /  www.f-i.com
 
This communication is confidential and is only intended for
the use of the individual or entity to which it is directed.
It may contain information that is privileged and exempt from
disclosure under applicable law. If you are not the Intended
recipient, please notify us immediately. You should not copy
it or disclose its content to any other person.


-----Original Message-----
From: Sudhanya Chatterjee [mailto:sudhanya_chatterjee@persistent.co.in] 
Sent: den 30 maj 2008 10:28
To: lucene-net-user@incubator.apache.org
Subject: Query with wildcard characters

Hi,

How to create queries of the following type using query parser (for
tokenized as well as untokenized fields) - 

 

Sudhanya Chat*

 

In the result I want all fields which start with "Sudhanya Chat".

But if I create a query - Query qry = queryParse.Parse("productName:
Sudhanya Chat*");

I get fields which are just starting with "Chat".

I have tried both - keyword and standard Analyzer.

How do I achieve the above mentioned kind of behaviour?

 

Thanks,

Sudhanya

 


DISCLAIMER
==========
This e-mail may contain privileged and confidential information which is the
property of Persistent Systems Ltd. It is intended only for the use of the
individual or entity to which it is addressed. If you are not the intended
recipient, you are not authorized to read, retain, copy, print, distribute
or use this message. If you have received this communication in error,
please notify the sender and delete all copies of this message. Persistent
Systems Ltd. does not accept any liability for virus infected mails.

No virus found in this incoming message.
Checked by AVG. 
Version: 8.0.100 / Virus Database: 269.24.4/1473 - Release Date: 5/29/2008
7:53 PM


Re: Searching with odd chars

Posted by Karl Geppert <ka...@chemwatch.net>.
You should also be able to query.escape that phrase to escape all the 
command characters shouldn't you?

We use a custom escape function so that you can still pass wildcards through

private static string replaceAll(string In, string pcFrom)
{
string outstring = "";
int i;

for (i = 0; i < In.Length; i++)
{
if (pcFrom.IndexOf(In[i]) > -1)
outstring = outstring + "\\" + In[i];
else
outstring = outstring + In[i];
}

return (outstring);
} //replaceAll

public static string escape(string userInput)
{
//Note * is not on this as it is still active as a wildcard and we 
therefore do not want to escape it.
return (replaceAll(userInput, "+-!:^{}~?"));

/*// Some constants.
String LUCENE_ESCAPE_CHARS = "[\\\\+\\-\\!\\(\\)\\:\\^\\]\\{\\}\\~\\*\\?]";
Pattern LUCENE_PATTERN = Pattern.compile(LUCENE_ESCAPE_CHARS);
String REPLACEMENT_STRING = "\\\\$0";
// ... Then, in your code somewhere...
String escaped = 
LUCENE_PATTERN.matcher(userInput).replaceAll(REPLACEMENT_STRING);
Query query = QueryParser.parse(escaped);
*/
}

Robert Pohl wrote:
> Hi List!
>
> Another question regarding the standard analyzer:
>
> If I search for "adidas - dream big" which is the exact title of a indexed
> item, it does not show up in the hits. It does if I remove the "-". Should
> it not trigger on the other words it the analyzer removes the "-" ?
>
> Thanks
>
> //rob
>
> ROBERT POHL
> Senior Application Developer • Fi Stockholm
>  
> T: +46 8 402 17 40
> robert.pohl@f-i.com  /  www.f-i.com
>  
> This communication is confidential and is only intended for
> the use of the individual or entity to which it is directed.
> It may contain information that is privileged and exempt from
> disclosure under applicable law. If you are not the Intended
> recipient, please notify us immediately. You should not copy
> it or disclose its content to any other person.
>
>
> -----Original Message-----
> From: Sudhanya Chatterjee [mailto:sudhanya_chatterjee@persistent.co.in] 
> Sent: den 30 maj 2008 10:28
> To: lucene-net-user@incubator.apache.org
> Subject: Query with wildcard characters
>
> Hi,
>
> How to create queries of the following type using query parser (for
> tokenized as well as untokenized fields) - 
>
>  
>
> Sudhanya Chat*
>
>  
>
> In the result I want all fields which start with "Sudhanya Chat".
>
> But if I create a query - Query qry = queryParse.Parse("productName:
> Sudhanya Chat*");
>
> I get fields which are just starting with "Chat".
>
> I have tried both - keyword and standard Analyzer.
>
> How do I achieve the above mentioned kind of behaviour?
>
>  
>
> Thanks,
>
> Sudhanya
>
>  
>
>
> DISCLAIMER
> ==========
> This e-mail may contain privileged and confidential information which is the
> property of Persistent Systems Ltd. It is intended only for the use of the
> individual or entity to which it is addressed. If you are not the intended
> recipient, you are not authorized to read, retain, copy, print, distribute
> or use this message. If you have received this communication in error,
> please notify the sender and delete all copies of this message. Persistent
> Systems Ltd. does not accept any liability for virus infected mails.
>
> No virus found in this incoming message.
> Checked by AVG. 
> Version: 8.0.100 / Virus Database: 269.24.4/1473 - Release Date: 5/29/2008
> 7:53 PM
>
>
> _____________________________________________________________________
>
> This message has been checked for all known viruses by the 
> MessageLabs Virus Scanning Service. For further information visit
> http://www.messagelabs.com
> ________________________________________________________________________
>   


________________________________________________________________________

This email has been scanned for all viruses by the MessageLabs SkyScan
service. For more information on a proactive anti-virus service working
around the clock, around the globe, visit http://www.messagelabs.com
________________________________________________________________________