How do I perform a partial search while preserving order using solr?

91 Views Asked by At

Using Solr 4.0, I have a field Title_t(to store titles of books) which is of type TextField. Assuming that these are the following titles stored in my db:

  • Physics Guide
  • Tutorial on Theoretical Physics
  • The General Physics Book

If one wants to search for a title "Physics Guide", then one could use Title_t:physics G* this shows up all results

  • Physics Guide
  • Tutorial on Theoretical Physics
  • The General Physics Book

Now, to my question:

Why isnt the filter not showing only the "Physics Guide" result? Since the search criteria is "physics G*" and not "*physics G *", only one result should be displayed .Is there a way to preserve order in the search key word?

1

There are 1 best solutions below

1
On BEST ANSWER

After parsing you query Title_t:physics G* will become like

Title_t:physics df:G*

df here is default field(usually it will be text, check your config files). and default operator will OR. so it returns documents with Title_t having term 'physics' and documents with any fields copied default field with words starting with G.

Try with ComplexPhraseQueryParser

q={!complexphrase inOrder=true}Title_t:"physics G*"