Related contents ?

4 views
Skip to first unread message

thomas.g

unread,
Jul 20, 2010, 12:35:26 PM7/20/10
to Whoosh
Hi,

I'm discovering Whoosh which seems to be a great tool !

I'm looking for a search engine that is able in addition to search
queries to propose "related content".
Indeed, I'm developing a forum and I would like to propose "related
topics" on each topic.

Do Whoosh is an option for this ?

Thanks a lot

Adam Blinkinsop

unread,
Jul 20, 2010, 2:18:10 PM7/20/10
to who...@googlegroups.com
http://packages.python.org/Whoosh/keywords.html might be what you want.


--
You received this message because you are subscribed to the Google Groups "Whoosh" group.
To post to this group, send email to who...@googlegroups.com.
To unsubscribe from this group, send email to whoosh+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/whoosh?hl=en.




--
Adam Blinkinsop <bli...@acm.org>

Matt Chaput

unread,
Jul 20, 2010, 2:43:40 PM7/20/10
to who...@googlegroups.com
On 20/07/2010 2:18 PM, Adam Blinkinsop wrote:
> http://packages.python.org/Whoosh/keywords.html might be what you want.

Yes, this page has the basic information you want. I need to go back and
expand the documentation though! Let me know if you have any questions. :)

The basic usage is:


searcher = myindex.searcher()

# Get the document number for the forum topic
topic_docnum = searcher.document_number(id=topic_id)

# Get the iterator of key terms from the "content" field, or
# whatever you called the field containing the main text.
keyterms = searcher.key_terms([topic_docnum], "content", numterms=5)

# Create a query from the key terms
from whoosh import query
q = query.Or([query.Term("content", kt) for kt in keyterms])

# Get the results of the query
results = searcher.search(q, limit=10)

# Display the documents in the results, but skip the original topic
for i, fields in enumerate(results):
if results.docnum(i) != topic_docnum:
print fields


Cheers,

Matt

Reply all
Reply to author
Forward
0 new messages