0

My requirement is simple.

I need to search with the keyword similar to SQL LIKE.

Now the search shows results for "words" rather than checking partial characters.

Ex:-

  • Search query: "test"
  • Expected results: "test%" - Which gives "test", "tested", "testing", etc...
  • Actual result: "test"

I found many query suggestions for SOLR. But I need to find the exact mechanism to put that on conf xml files.

Thanks in advance.

IvenMS
  • 525
  • 5
  • 19
  • For the record: To pass the problem, and due to the restriction of time, I managed to solve the problem by handling it on client side - By putting wild character at the end of search keyword. "test*". But I am looking for the best option available. – IvenMS May 02 '12 at 05:04
  • 2
    Wouldnt a stemmed field satisfy your example? Its much easier and more powerful than an SQL LIKE, that you can stop thinking in terms in terms of LIKE. http://stackoverflow.com/a/10362591/604511 – Jesvin Jose May 02 '12 at 05:51

2 Answers2

1

The quick and dirty solution is to use wildcard in your search query using an asterisk (*). For example: test*

The more proper solution would be to use stemming to remove common word endings when you index and query the data. In the default schema, the text_en_splitting field type would do this for you. Just define your field as text_en_splitting.

Nick Clark
  • 4,439
  • 4
  • 23
  • 25
0

Are you building auto-complete?

If so, use Suggester. It's part of Solr, and it does what you're talking about extremely efficiently using either a dictionary file, or a field in your index you've designated.

http://wiki.apache.org/solr/Suggester

Peter Dixon-Moses
  • 3,169
  • 14
  • 18