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 Adam Allgaier <al...@yahoo.com> on 2009/09/02 22:15:42 UTC

Problem querying for a value with a "space"

Touch gently with the Solr newbie....I've searched trying to find an answer to this problem with no success.  I'm sure it's something small and easy.  

I'm using Solr 1.3 with Solrj client

<fieldType name="string" class="solr.StrField" sortMissingLast="true" omitNorms="true"/>
...
<dynamicField name="*_s"  type="string"  indexed="true"  stored="true"/>

I am indexing the "specific_LIST_s" with the value "For Sale".
The document indexes just fine.  A query returns the document with the proper value:
    <str name="specific_LIST_s">For Sale</str>

However, when I try to query on that field....
    +specific_LIST_s:For Sale
    +specific_LIST_s:For+Sale
    +specific_LIST_s:For%20Sale

....I get no results with any one of those three queries.

If I index the value "ForSale" (no space), then execute the query....
    +specific_LIST_s:ForSale

...returns the expected document.

What am I missing?

Thanks in advance, 
Adam  :-)


      

Re: Problem querying for a value with a "space"

Posted by Avlesh Singh <av...@gmail.com>.
Spaces, if there in a term query, should be escaped before searching.

myField:quick\ brown\ fox
is the correct way to search for quick brown fox in myField using TermQuery.


You can always add &debugQuery=on your search url. The response will contain
a lot of helpful information on how the incoming query was parsed into a
Lucene query, thereby giving you a good idea as to what might have gone
wrong.

Cheers
Avlesh

On Thu, Sep 3, 2009 at 5:36 AM, Adam Allgaier <al...@yahoo.com> wrote:

> I think I understand what happened.....
>
> The query "+specific_LIST_s:For Sale" is processed and broken into "For"
> and "Sale".  The specific_LIST_s field is a "string", so it is not
> tokenized, but remains indexed as "For Sale", which matches neither "For"
> nor "Sale".  Hence, no results.
>
> This query solves the problem:
>    +specific_LIST_s:"For Sale"
>
> Cheers,
> Adam  :-)
>
>
>
>
> ----- Original Message ----
> From: Dan A. Dickey <da...@savvis.net>
> To: solr-user@lucene.apache.org
> Cc: Adam Allgaier <al...@yahoo.com>
> Sent: Wednesday, September 2, 2009 6:20:13 PM
> Subject: Re: Problem querying for a value with a "space"
>
> On Wednesday 02 September 2009 15:15:42 Adam Allgaier wrote:
> > Touch gently with the Solr newbie....I've searched trying to find an
> answer to this problem with no success.  I'm sure it's something small and
> easy.
> >
> > I'm using Solr 1.3 with Solrj client
> >
> > <fieldType name="string" class="solr.StrField" sortMissingLast="true"
> omitNorms="true"/>
> > ...
> > <dynamicField name="*_s"  type="string"  indexed="true"  stored="true"/>
> >
> > I am indexing the "specific_LIST_s" with the value "For Sale".
> > The document indexes just fine.  A query returns the document with the
> proper value:
> >     <str name="specific_LIST_s">For Sale</str>
> >
> > However, when I try to query on that field....
> >     +specific_LIST_s:For Sale
> >     +specific_LIST_s:For+Sale
> >     +specific_LIST_s:For%20Sale
> >
> > ....I get no results with any one of those three queries.
>
> Your problem looks *very* much like what I just went through.
> Not sure, but...
>
> You are searching specific_LIST_s for "For".  The "Sale" part is being
> searched
> for in your defaultSearchField.  Putting "'s around the For Sale won't help
> either.
> You need to query something like:
>    specific_LIST_s:For OR specific_LIST_s:Sale
> At least, that's what I ended up doing.  In my case, I could have changed
> the
> defaultSearchField to what I wanted to search on in this situation - but I
> chose to
> explicitly set the query string.  YMMV.
>    -Dan
>
> >
> > If I index the value "ForSale" (no space), then execute the query....
> >     +specific_LIST_s:ForSale
> >
> > ...returns the expected document.
> >
> > What am I missing?
> >
> > Thanks in advance,
> > Adam  :-)
> >
> >
> >
> >
>
> --
> Dan A. Dickey | Senior Software Engineer
>
> Savvis
> 10900 Hampshire Ave. S., Bloomington, MN  55438
> Office: 952.852.4803 | Fax: 952.852.4951
> E-mail: dan.dickey@savvis.net
>
>
>
>
>

Re: Problem querying for a value with a "space"

Posted by Adam Allgaier <al...@yahoo.com>.
I think I understand what happened.....

The query "+specific_LIST_s:For Sale" is processed and broken into "For" and "Sale".  The specific_LIST_s field is a "string", so it is not tokenized, but remains indexed as "For Sale", which matches neither "For" nor "Sale".  Hence, no results.

This query solves the problem:
    +specific_LIST_s:"For Sale"

Cheers,
Adam  :-)




----- Original Message ----
From: Dan A. Dickey <da...@savvis.net>
To: solr-user@lucene.apache.org
Cc: Adam Allgaier <al...@yahoo.com>
Sent: Wednesday, September 2, 2009 6:20:13 PM
Subject: Re: Problem querying for a value with a "space"

On Wednesday 02 September 2009 15:15:42 Adam Allgaier wrote:
> Touch gently with the Solr newbie....I've searched trying to find an answer to this problem with no success.  I'm sure it's something small and easy.  
> 
> I'm using Solr 1.3 with Solrj client
> 
> <fieldType name="string" class="solr.StrField" sortMissingLast="true" omitNorms="true"/>
> ...
> <dynamicField name="*_s"  type="string"  indexed="true"  stored="true"/>
> 
> I am indexing the "specific_LIST_s" with the value "For Sale".
> The document indexes just fine.  A query returns the document with the proper value:
>     <str name="specific_LIST_s">For Sale</str>
> 
> However, when I try to query on that field....
>     +specific_LIST_s:For Sale
>     +specific_LIST_s:For+Sale
>     +specific_LIST_s:For%20Sale
> 
> ....I get no results with any one of those three queries.

Your problem looks *very* much like what I just went through.
Not sure, but...

You are searching specific_LIST_s for "For".  The "Sale" part is being searched
for in your defaultSearchField.  Putting "'s around the For Sale won't help either.
You need to query something like:
    specific_LIST_s:For OR specific_LIST_s:Sale
At least, that's what I ended up doing.  In my case, I could have changed the
defaultSearchField to what I wanted to search on in this situation - but I chose to
explicitly set the query string.  YMMV.
    -Dan

> 
> If I index the value "ForSale" (no space), then execute the query....
>     +specific_LIST_s:ForSale
> 
> ...returns the expected document.
> 
> What am I missing?
> 
> Thanks in advance, 
> Adam  :-)
> 
> 
>      
> 

-- 
Dan A. Dickey | Senior Software Engineer

Savvis
10900 Hampshire Ave. S., Bloomington, MN  55438
Office: 952.852.4803 | Fax: 952.852.4951
E-mail: dan.dickey@savvis.net



      

Re: Problem querying for a value with a "space"

Posted by "Dan A. Dickey" <da...@savvis.net>.
On Wednesday 02 September 2009 15:15:42 Adam Allgaier wrote:
> Touch gently with the Solr newbie....I've searched trying to find an answer to this problem with no success.  I'm sure it's something small and easy.  
> 
> I'm using Solr 1.3 with Solrj client
> 
> <fieldType name="string" class="solr.StrField" sortMissingLast="true" omitNorms="true"/>
> ...
> <dynamicField name="*_s"  type="string"  indexed="true"  stored="true"/>
> 
> I am indexing the "specific_LIST_s" with the value "For Sale".
> The document indexes just fine.  A query returns the document with the proper value:
>     <str name="specific_LIST_s">For Sale</str>
> 
> However, when I try to query on that field....
>     +specific_LIST_s:For Sale
>     +specific_LIST_s:For+Sale
>     +specific_LIST_s:For%20Sale
> 
> ....I get no results with any one of those three queries.

Your problem looks *very* much like what I just went through.
Not sure, but...

You are searching specific_LIST_s for "For".  The "Sale" part is being searched
for in your defaultSearchField.  Putting "'s around the For Sale won't help either.
You need to query something like:
	specific_LIST_s:For OR specific_LIST_s:Sale
At least, that's what I ended up doing.  In my case, I could have changed the
defaultSearchField to what I wanted to search on in this situation - but I chose to
explicitly set the query string.  YMMV.
	-Dan

> 
> If I index the value "ForSale" (no space), then execute the query....
>     +specific_LIST_s:ForSale
> 
> ...returns the expected document.
> 
> What am I missing?
> 
> Thanks in advance, 
> Adam  :-)
> 
> 
>       
> 

-- 
Dan A. Dickey | Senior Software Engineer

Savvis
10900 Hampshire Ave. S., Bloomington, MN  55438
Office: 952.852.4803 | Fax: 952.852.4951
E-mail: dan.dickey@savvis.net

Re: Problem querying for a value with a "space"

Posted by Shalin Shekhar Mangar <sh...@gmail.com>.
On Fri, Sep 4, 2009 at 6:40 AM, Chris Hostetter <ho...@fucit.org>wrote:

>
> : Use +specific_LIST_s:(For Sale)
> : or
> : +specific_LIST_s:"For Sale"
>
> those are *VERY* different queries.
>
> The first is just syntac sugar for...
>  +specific_LIST_s:For +specific_LIST_s:Sale
>
> ...which is not the same as the second query (especially when using
> StrField, or KeyworddTokenizer)
>
>
Ah, my bad. I learnt something new today :)

-- 
Regards,
Shalin Shekhar Mangar.

Re: Problem querying for a value with a "space"

Posted by Chris Hostetter <ho...@fucit.org>.
: Use +specific_LIST_s:(For Sale)
: or
: +specific_LIST_s:"For Sale"

those are *VERY* different queries.

The first is just syntac sugar for...
  +specific_LIST_s:For +specific_LIST_s:Sale

...which is not the same as the second query (especially when using 
StrField, or KeyworddTokenizer)



-Hoss


Re: Problem querying for a value with a "space"

Posted by Shalin Shekhar Mangar <sh...@gmail.com>.
On Thu, Sep 3, 2009 at 1:45 AM, Adam Allgaier <al...@yahoo.com> wrote:

>
> <fieldType name="string" class="solr.StrField" sortMissingLast="true"
> omitNorms="true"/>
> ...
> <dynamicField name="*_s"  type="string"  indexed="true"  stored="true"/>
>
> I am indexing the "specific_LIST_s" with the value "For Sale".
> The document indexes just fine.  A query returns the document with the
> proper value:
>    <str name="specific_LIST_s">For Sale</str>
>
> However, when I try to query on that field....
>    +specific_LIST_s:For Sale
>    +specific_LIST_s:For+Sale
>    +specific_LIST_s:For%20Sale
>
> ....I get no results with any one of those three queries.
>
>
Use +specific_LIST_s:(For Sale)
or
+specific_LIST_s:"For Sale"

-- 
Regards,
Shalin Shekhar Mangar.