You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Matthew Runo <mr...@zappos.com> on 2007/08/09 02:18:55 UTC

Wildcard queries with spaces in them

Yes. I definitely cannot get this to work for terms that have spaces  
in them.

+--------------------------------------------------------+
  | Matthew Runo
  | Zappos Development
  | mruno@zappos.com
  | 702-943-7833
+--------------------------------------------------------+


On Aug 8, 2007, at 2:59 PM, Matthew Runo wrote:

> OK.
>
> So a followup question..
>
> ?q=department_exact:Apparel%3EMen's% 
> 20Apparel*&fq=country_code:US&fq=brand_exact:adidas&fq=hibernated:true
>
> returns 0 results. Note the %20 in there for the space character.
>
> ?q=department_exact:Apparel% 
> 3EMen's*&fq=country_code:US&fq=brand_exact:adidas&fq=hibernated:true
> returns several, and the only change is that I've truncated "Men's  
> Apparel*" to be "Men's*".
>
> (example department_exacts from this result set below..)
>
> Apparel>Men's Apparel>Sweatshirts>Hooded
> Apparel>Men's Apparel>Shirts>Tank Top>Workout
> Apparel>Men's Apparel>Sweatshirts
> Apparel>Men's Apparel>Sweatshirts
> Apparel>Men's Apparel>Jackets>Windbreaker
>
> ----
>
> Any ideas why "Apparel>Men's*" would work, but "Apparel>Men's  
> Apparel*" would not?
>
> +--------------------------------------------------------+
>  | Matthew Runo
>  | Zappos Development
>  | mruno@zappos.com
>  | 702-943-7833
> +--------------------------------------------------------+
>
>
> On Aug 8, 2007, at 2:42 PM, Yonik Seeley wrote:
>
>> On 8/8/07, Matthew Runo <mr...@zappos.com> wrote:
>>> I've been using the standard query handler to do searches like
>>>
>>> q=department_exact:"Foo>Bar>Baz>Qux"
>>>
>>> Now, lets assume I have lots of records, with various department
>>> trees...
>>> 1. Foo>Bar>Baz>Qux
>>> 2. Foo>Bar>Baz>Put
>>> 3. Foo>Bar>Something With Spaces>Elese
>>> 4. Foo>Totaly>Different>Tree
>>>
>>> I'd like to get all the products at various levels, and all the
>>> levels below.
>>>
>>> I have a tokenzied department field, and a copyField  
>>> department_exact.
>>>
>>> I've been doing searches on the department_exact feild, thinking I
>>> could do this..
>>>
>>> q=department_exact:"Foo>Bar*"
>>
>> A "*" inside quotes is literal.
>> Try
>> q=department_exact:Foo>Bar*
>> Or if ">" is a reserved character, escape it with "\"
>> q=department_exact:Foo\>Bar*
>>
>> If "Bar" is unique (only under Foo), you could use a copyfield to  
>> copy
>> it to a regex tokenizer to split on ">" and then do a simple  
>> search on
>> "Bar"
>>
>> -Yonik
>>
>


Re: Wildcard queries with spaces in them

Posted by Yonik Seeley <yo...@apache.org>.
On 8/8/07, Matthew Runo <mr...@zappos.com> wrote:
> Yes. I definitely cannot get this to work for terms that have spaces
> in them.

Did you try escaping the space with a backslash?

I think this should be made easier for future releases.
One way is something like
q=<!prefix field=foo>hey, no escaping required
http://www.nabble.com/Using-HTTP-Post-for-Queries-tf3039973.html#a8483387

-Yonik