2
votes

I have a slight problem when searching with SOLR 4.0 and attempting a phrase query.

I have a field called "idx_text_general_ci" which is a case insensitive (all lowercased) field made up of all fields.

When I try and search for a phrase (marine fitter) my SOLR refuses to search for the phrase instead splitting the phrase into 2 words -

/select?defType=edismax&q=idx_text_general_ci:marine%20fitter&debugQuery=true

debugQuery=true output below:

<lst name="debug">
<str name="rawquerystring">idx_text_general_ci:marine fitter</str>
<str name="querystring">idx_text_general_ci:marine fitter</str>
<str name="parsedquery">
(+(idx_text_general_ci:marine DisjunctionMaxQuery((id:fitter))))/no_coord
</str>
<str name="parsedquery_toString">+(idx_text_general_ci:marine (id:fitter))</str>

As you can see above it splits the query into 2 parts (idx_text_general_ci:marine then id:fitter).

THe problem I have is that I have an exact match for "marine fitter" that appears twice in the idx_text_general_ci field yet it's ranked with a lesser score than a document with the word "marine" appearing 3 times. I know this will not be the case if my SOLR was to search the field with the phrase as expected.

If I wrap the phrase in quotes I get zero results.

Any help or a nudge in the right direction would be much appreciated.

Thanks in advance

Alex

1

1 Answers

2
votes

What's happening here is that your default query field appears to be id, and because you're specifying your query as

idx_text_general_ci:marine fitter

it gets translated in Solr as a DisjunctionMaxQuery for idx_text_general_ci:marine and id:fitter. Presumably, you want idx_text_general_ci:marine and idx_text_general_ci:fitter. You have two options: 1) you can prefix each word with the correct field followed by a colon, or you can change the defaultSearchField in schema.xml to be idx_text_general_ci.

I'm baffled as to why you get zero results when you wrap it in double quotes though. But doing the above should help you.