Re: searching for terms containing embedded spaces

2011-09-11 Thread Erick Erickson
Try escaping it for a start.

But why do you want to? If it's a phrase query, enclose it in double quotes.
You really have to provide more details, because there are too many
possibilities
to answer. For instance:

If you're entering field:a b then 'b' will be searched against your
default text field
and you should enter field:(a b) or field:a field:b

If you've tokenized the field, you shouldn't care.

If you're using keywordanalyzer, escaping should work.

Etc.


Best
Erick

On Fri, Sep 9, 2011 at 8:11 PM, Mark juszczec mark.juszc...@gmail.com wrote:
 Hi folks

 I've got a field that contains 2 words separated by a single blank.

 What's the trick to creating a search string that contains the single blank?

 Mark



Re: searching for terms containing embedded spaces

2011-09-11 Thread Mark juszczec
Erick

My field contains a b (without )

We are trying to assemble the query as a String by appending the various
values.  I think that is a large part of the problem and our lives would be
easier if we let the Solr api do this work.

We've experimented with our query assembler producing

field:a+b

We've also tried making it create

field:a\ b

The first case just does not work and I'm unsure why.

The second case ends up url encoding the \ and I'm unsure if that will cause
it to be used in the query or not.

Mark



On Sun, Sep 11, 2011 at 12:10 PM, Erick Erickson erickerick...@gmail.comwrote:

 Try escaping it for a start.

 But why do you want to? If it's a phrase query, enclose it in double
 quotes.
 You really have to provide more details, because there are too many
 possibilities
 to answer. For instance:

 If you're entering field:a b then 'b' will be searched against your
 default text field
 and you should enter field:(a b) or field:a field:b

 If you've tokenized the field, you shouldn't care.

 If you're using keywordanalyzer, escaping should work.

 Etc.
 

 Best
 Erick

 On Fri, Sep 9, 2011 at 8:11 PM, Mark juszczec mark.juszc...@gmail.com
 wrote:
  Hi folks
 
  I've got a field that contains 2 words separated by a single blank.
 
  What's the trick to creating a search string that contains the single
 blank?
 
  Mark
 



Re: searching for terms containing embedded spaces

2011-09-11 Thread Yonik Seeley
On Sun, Sep 11, 2011 at 12:56 PM, Mark juszczec mark.juszc...@gmail.com wrote:
 We've also tried making it create

 field:a\ b

 The first case just does not work and I'm unsure why.

 The second case ends up url encoding the \ and I'm unsure if that will cause
 it to be used in the query or not.

URL encoding is just part of the transfer syntax for an HTTP GET/POST
- by the time the query makes it to the lucene/solr query parser, that
escaping will have been removed.

You can also use
http://lucene.apache.org/solr/api/org/apache/solr/search/TermQParserPlugin.html
and not worry about any escaping.

But as Erick says, it's not clear that's really what you want (to
search on a single term with a space in it).  If it's a normal text
field, each word will be indexed separately, so you really want a
phrase query or a boolean query:

field:a b
or
field:(a b)

-Yonik
http://www.lucene-eurocon.com - The Lucene/Solr User Conference


Re: searching for terms containing embedded spaces

2011-09-11 Thread Mark juszczec

 But as Erick says, it's not clear that's really what you want (to
 search on a single term with a space in it).  If it's a normal text
 field, each word will be indexed separately, so you really want a
 phrase query or a boolean query:

 field:a b
 or
 field:(a b)


I am looking for a text string with a single, embedded space.  For the
purposes of this example, it is a b and its stored in the index in a field
called field.

Am I incorrect in assuming the query field:a b will match the the string a
followed by a single embedded space followed by a b?

I'm also wondering if this is already handled by the Solr/SolrJ API and if
we are making our lives more difficult by assembling the query strings
ourselves.

Mark


 -Yonik
 http://www.lucene-eurocon.com - The Lucene/Solr User Conference



Re: searching for terms containing embedded spaces

2011-09-11 Thread Yonik Seeley
On Sun, Sep 11, 2011 at 1:15 PM, Mark juszczec mark.juszc...@gmail.com wrote:
 I am looking for a text string with a single, embedded space.  For the
 purposes of this example, it is a b and its stored in the index in a field
 called field.

 Am I incorrect in assuming the query field:a b will match the the string a
 followed by a single embedded space followed by a b?

Yes, that should work regardless of how the field is indexed (as a big
single token, or as a normal text field that doesn't preserve spaces).

-Yonik
http://www.lucene-eurocon.com - The Lucene/Solr User Conference


Re: searching for terms containing embedded spaces

2011-09-11 Thread Mark juszczec
That's what I thought.  The problem is, its not and I am unsure what is
wrong.



On Sun, Sep 11, 2011 at 1:35 PM, Yonik Seeley yo...@lucidimagination.comwrote:

 On Sun, Sep 11, 2011 at 1:15 PM, Mark juszczec mark.juszc...@gmail.com
 wrote:
  I am looking for a text string with a single, embedded space.  For the
  purposes of this example, it is a b and its stored in the index in a
 field
  called field.
 
  Am I incorrect in assuming the query field:a b will match the the
 string a
  followed by a single embedded space followed by a b?

 Yes, that should work regardless of how the field is indexed (as a big
 single token, or as a normal text field that doesn't preserve spaces).

 -Yonik
 http://www.lucene-eurocon.com - The Lucene/Solr User Conference



Re: searching for terms containing embedded spaces

2011-09-11 Thread Yonik Seeley
On Sun, Sep 11, 2011 at 1:39 PM, Mark juszczec mark.juszc...@gmail.com wrote:
 That's what I thought.  The problem is, its not and I am unsure what is
 wrong.

What is the fieldType definition for that field?  Did you change it
without re-indexing?

-Yonik
http://www.lucene-eurocon.com - The Lucene/Solr User Conference


Re: searching for terms containing embedded spaces

2011-09-11 Thread Mark juszczec
The field's properties are:

field name=CUSTOMER_TYPE_NM type=string indexed=true stored=true
required=true default=CUSTOMER_TYPE_NM_MISSING

There have been no changes since I last completely rebuilt the index.

Is re-indexing done when an index is completely rebuilt with a a
dataimport=full?   How about if we've done dataimport=delta?

If it helps, this is what I get when I print out the ModifiableSolrParams
object I'm sending to the query method:

q=+*%3A*++AND+CUSTOMER_TYPE_NM%3ANetwork+Advertiser+AND+ACTIVE_IND%3A1defType=edismaxrows=500sort=ACCOUNT_CUSTOMER_ID+ascstart=0

Mark

On Sun, Sep 11, 2011 at 2:05 PM, Yonik Seeley yo...@lucidimagination.comwrote:

 On Sun, Sep 11, 2011 at 1:39 PM, Mark juszczec mark.juszc...@gmail.com
 wrote:
  That's what I thought.  The problem is, its not and I am unsure what is
  wrong.

 What is the fieldType definition for that field?  Did you change it
 without re-indexing?

 -Yonik
 http://www.lucene-eurocon.com - The Lucene/Solr User Conference



Re: searching for terms containing embedded spaces

2011-09-11 Thread Erick Erickson
OK, there are several issues here:
q= *:*  AND CUSTOMER_TYPE_NM:Network Advertiser AND
ACTIVE_IND:1defType=edismaxrows=500sort=ACCOUNT_CUSTOMER_ID
ascstart=0

the *:* is doing you no good, I'd just remove it.

defType=edismax probably isn't doing what you expect, you're not
specifying any fields
(no qf parameter).

This is going to your request handler that has ' default=true '
defined. If you're using a
stock example, you're probably searching against the default search
field defined in
schema.xml, probably a field named text.

If you have a request handler named edismax, you can use the qt=edismax
parameter. If your request handler is named /edismax, then use either
qt=/edismax or solr/edismax?q=

Attach the debugQuery=on and look at the parsed form of the
query.

But edismax plays nicer than dismax used to, it's probably searching
against your default
search field. Which is probably NOT CUSTOMER_TYPE_NM.

String types are completely unanalyzed, so they're case sensitive. If
you want a case-insensitive
version, use something like KeywordTokenizer followed by
LowerCaseFilter. The admin/analysis
page will help you a lot here.

I think you'll get a lot of insight into this if you attach
debugQuery=on and look at the
parsedquery and parsedquery_tostring sections (after the results list).

Best
Erick


On Sun, Sep 11, 2011 at 2:25 PM, Mark juszczec mark.juszc...@gmail.com wrote:
 The field's properties are:

 field name=CUSTOMER_TYPE_NM type=string indexed=true stored=true
 required=true default=CUSTOMER_TYPE_NM_MISSING

 There have been no changes since I last completely rebuilt the index.

 Is re-indexing done when an index is completely rebuilt with a a
 dataimport=full?   How about if we've done dataimport=delta?

 If it helps, this is what I get when I print out the ModifiableSolrParams
 object I'm sending to the query method:

 q=+*%3A*++AND+CUSTOMER_TYPE_NM%3ANetwork+Advertiser+AND+ACTIVE_IND%3A1defType=edismaxrows=500sort=ACCOUNT_CUSTOMER_ID+ascstart=0

 Mark

 On Sun, Sep 11, 2011 at 2:05 PM, Yonik Seeley 
 yo...@lucidimagination.comwrote:

 On Sun, Sep 11, 2011 at 1:39 PM, Mark juszczec mark.juszc...@gmail.com
 wrote:
  That's what I thought.  The problem is, its not and I am unsure what is
  wrong.

 What is the fieldType definition for that field?  Did you change it
 without re-indexing?

 -Yonik
 http://www.lucene-eurocon.com - The Lucene/Solr User Conference




searching for terms containing embedded spaces

2011-09-09 Thread Mark juszczec
Hi folks

I've got a field that contains 2 words separated by a single blank.

What's the trick to creating a search string that contains the single blank?

Mark