Backslash is the escape character for colon, hyphen, parentheses,
brackets, curly braces, tilde, caret. (Did I miss any?)

On Thu, Dec 3, 2009 at 7:59 AM, Peter 4U <pete...@hotmail.com> wrote:
>
> Hello Solr Forum,
>
>
>
> I believe I have found a solution (workaround?) for performing an explicit 
> (non-wildcarded) field query with values that contain special (escaped) 
> characters.
>
>
>
> Instead of:
>
>  field:"value-with-escape-chars"
>
> change this to:
>
>  field:["value-with-escape-chars" TO "value-with-escape-chars"]
>
>
>
> (Note that for SolrJ, use QueryParser.escape(), to ultimately turn this into: 
>  field:[\"value\-with\-escape\-chars\" TO \"value\-with\-escape\-chars\"])
>
>
>
> If the value being queried has no special characters (e.g. host:localhost), 
> the above is not necessary, which leads me to believe this more of a 
> workaround than the 'supported way'. Please do correct me/clarify if you know 
> differently, or know of a better/more efficient method.
>
>
>
> In early tests with 200,000+ hits, there appears no performance hit for using 
> the range form. Not sure if this affects performance for millions+ hits.
>
>
>
> Thanks,
>
> Peter
>
>
>
>
>
>> From: pete...@hotmail.com
>> To: solr-user@lucene.apache.org
>> Subject: Facet query with special characters
>> Date: Thu, 3 Dec 2009 13:29:45 +0000
>>
>>
>> Hello,
>>
>> I've encountered some strange behaviour in Solr facet querying, and I've not 
>> been able to find anything on this on the web.
>> Perhaps someone can shed some light on this?
>>
>> The problem:
>> When performing a facet query where part of the value portion has a special 
>> character (a minus sign in this case), the query returns zero results unless 
>> I put a wildcard (*) at the end.
>>
>>
>>
>> Here is my query:
>>
>> This produces zero 'numFound':
>> http://localhost:8983/solr/select/?wt=xml&indent=on&rows=20&q=((signature:3083
>>  AND host:pds-comp.domain)) AND _time:[091119124039 TO 
>> 091203124039]&facet=true&facet.field=host&facet.field=sourcetype&facet.field=user&facet.field=signature
>>
>> This produces 28 'numFound':
>> http://localhost:8983/solr/select/?wt=xml&indent=on&rows=20&q=((signature:3083
>>  AND host:pds-comp.domain*)) AND _time:[091119124039 TO 
>> 091203124039]&facet=true&facet.field=host&facet.field=sourcetype&facet.field=user&facet.field=signature
>>
>>
>> (Note: all hit results are for <host>pds-comp.domain</host> - there are no 
>> other characters in the resulting field values)
>>
>>
>> I've tried escaping the minus sign in various ways, encoding etc., but 
>> nothing seems to work.
>> Can anyone help?
>>
>> Many thanks,
>> Peter
>>
>>
>> _________________________________________________________________
>> Add your Gmail and Yahoo! Mail email accounts into Hotmail - it's easy
>> http://clk.atdmt.com/UKM/go/186394592/direct/01/
>
> _________________________________________________________________
> Add your Gmail and Yahoo! Mail email accounts into Hotmail - it's easy
> http://clk.atdmt.com/UKM/go/186394592/direct/01/



-- 
Lance Norskog
goks...@gmail.com

Reply via email to