1

Say I need to make searching for related titles just like stackoverflow does before you add your question or digg.com before submitting news.

I didn't find a way how to do this with Zend Lucene. There are setSlop method for queries, but as I understand, it doesn't help.

Is there any way to do this kind of searches?

Charles
  • 50,943
  • 13
  • 104
  • 142
Arty
  • 5,923
  • 9
  • 39
  • 44

2 Answers2

1

I figured that to do related search you should just pass the query string to the $index->find method. It will find not only the exact matches but also similar ones:

$index->find('top 10 cars');

result:

Top 10 Funniest Cars
Top 11 Celebrities Cars
Top 6 Barbeque Cars
Top 10 Futuristic Concept Cars
Top 5 Classic Oldest Cars Ever 
Arty
  • 5,923
  • 9
  • 39
  • 44
0

The easiest way to do this is to submit the document's text as a query. Take the document's text, tokenize it, put an OR term in between each token, and submit it as a Lucene query. I've done this before and it works reasonably well.

bajafresh4life
  • 12,491
  • 5
  • 37
  • 46
  • Yeah, but OR logic wouldn't help. Because it will find all documents that consist of any of these words whereas I need to find relevant documents. – Arty Apr 27 '10 at 21:43