Thanks for the comments, and for the idea for the term query parser.
This seems to work well (except I still can't get '&' in a category name to 
work - I can get the (one and only) customer to change the category names).

I'll look into fixing the indexing side of things - could be an idea to strip 
out the "special characters".
I'm working on the search side of things.

/Peter


-----Original Message-----
From: Erick Erickson [mailto:erickerick...@gmail.com] 
Sent: 8. april 2014 16:15
To: solr-user@lucene.apache.org; Ahmet Arslan
Subject: Re: Solr special characters like '(' and '&'?

I'd seriously consider filtering these characters out when you index and 
search, this is quite likely very brittle. The same item, say from two 
different vendors, might have D (E & F) or D E & F. If you just stripped all of 
the non alpha-num characters you'd likely get less brittle results.

You know your problem domain better than I do though, so whatever makes most 
sense.

Best,
Erick

On Tue, Apr 8, 2014 at 6:55 AM, Ahmet Arslan <iori...@yahoo.com> wrote:
> Hi Peter,
>
> TermQueryParser is useful in your case.
> q={!term f=categories_string}A|B|D (E & F)
>
>
>
> On Tuesday, April 8, 2014 4:37 PM, Peter Kirk <p...@alpha-solutions.dk> wrote:
> Hi
>
> How to search for Solr special characters like '(' and '&'?
>
> I am trying to execute searches for "products" in my Solr (3.6.1) index, 
> based on the "categories" to which these products belong.
> The categories are stored in a multistring field for the products, and are 
> hierarchical, and are fed to the index like:
> A
> A|B
> A|B|C
>
> So this product would actually belong to category named "C", which is a child 
> of "B", which is a child of !"A".
>
> I am able to execute queries for simple category names like this (eg. 
> fq=categories_string:A|B|C).
>
> But some categories have Solr special characters in their names, like: "D (E 
> & F)"
> (Real example: "Power supplies (Battery and Solar)").
>
> A query like fq=categories_string:A|B|D (E & F) simply fails.
> But even if I try
> fq=categories_string:A|B|D%20\(E%20%26amp%3B%20F\)
> (where I try to escape the special characters) does not find the products in 
> this category, and actually finds other unrelated categories.
>
> What am I doing wrong?
>
> Thanks,
> Peter
>

Reply via email to