开发者

How to find similar/related text with Zend Lucene?

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 Lucen开发者_如何转开发e. There are setSlop method for queries, but as I understand, it doesn't help.

Is there any way to do this kind of searches?


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 


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜