3
votes

We upgraded from Solr 3.6 to Solr 4.0. Unfortunately the behaviour of how to retrieve a document from the index by a unique key has apparently changed.

In Solr 3.6 the following query retrieves a single document:

key:conf/socc/AscottS09

But when using Solr 4.0 with the same document collection (re-indexed) an empty result list is returned. It seems that Solr 4.0 is processing/analyzing the term conf/socc/AscottS09 even though it is of type solr.StrField. The query works as expected in Solr 4.0 when the term in enclosed in quotation marks:

key:"conf/socc/AscottS09"                

schema.xml:

...
<fieldType name="string"  class="solr.StrField" sortMissingLast="true" mitNorms="true"/>
...
<field name="key" type="string" indexed="true" stored="true" multiValued="false" required="true"/>
...

Is this a bug or have there been any changes on how Solr processes the string field?

EDIT: I haven't found any related information in the migration infos of Solr 4.0

1
did you check that field with analyzer on the admin ui too? - denizdurmus
To my experience solr4 behaves as you expected, so the reason should be found in your code/configuration. - heinob
The analyzer in the admin does it right. But when using the query field in the admin ui with enabled debug mode it shows that the term gets analyzed and tokenized:<str name="rawquerystring">key:conf/socc/AscottS09</str><str name="querystring">key:conf/socc/AscottS09</str><str name="parsedquery">+key:conf +RegexpQuery(text:/socc/) +(+text:ascotts09 +text:ascott +text:s +text:09)</str><str name="parsedquery_toString">+key:conf +text:/socc/ +(+text:ascotts09 +text:ascott +text:s +text:09)</str - problemzebra
I got a similar problem with a String field. My search field contains \. When I use the analyser it matches. But when I query, it doesn't. - DavidVdd

1 Answers

0
votes

https://issues.apache.org/jira/browse/SOLR-4276?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13545425#comment-13545425

The tokens in the query needs to be escaped since Solr 4 supports regex in queries:

QueryParser.escape("XXXX")

We are using this method but this was done in another component using Solr/Lucene 3.6.