nitely / Spirit

Spirit is a modern Python based forum built on top of Django framework
http://spirit.readthedocs.io
MIT License
1.16k stars 332 forks source link

Would it be better to index Comment rather than Topic? #326

Closed sureshvv closed 3 weeks ago

sureshvv commented 9 months ago

Currently Search returns the Topic but the search item is buried deep inside it - so one has to do a Find in page using the browser.

nitely commented 9 months ago

If you want to find all topics talking about X then the current search is fine.

Returning comments and searching on a single post is missing functionality.

On Sun., Oct. 8, 2023, 3:48 a.m. sureshvv, @.***> wrote:

Currently Search returns the Topic but the search item is buried deep inside it - so one has to do a Find in page using the browser.

— Reply to this email directly, view it on GitHub https://github.com/nitely/Spirit/issues/326, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAM6L42QA5ILC7HUYBDTTB3X6JED5AVCNFSM6AAAAAA5XPGCDSVHI2DSMVQWIX3LMV43ASLTON2WKOZRHEZTCNRXGM2DGMI . You are receiving this because you are subscribed to this thread.Message ID: @.***>

sureshvv commented 1 month ago

Can you guide me on how to implement this missing functionality? I would like to retrieve individual comments matching the search.

nitely commented 1 month ago

It's a lot of work. I think most search functionality lives in https://github.com/nitely/Spirit/tree/master/spirit/search . You'll need to add the comment version of it. Things like a search index, views, forms, urls, templates, etc.

For a comment you'll have fields like text (this field must contain the comment text, the search index will use it for searching on it, and it's generated by a template like this , see the haystack docs), comment_id, comment_html, and is_removed at least.

nitely commented 1 month ago

Also, there is a task for indexing topics every time one is created here. You'll need to do the same for comments.

sureshvv commented 3 weeks ago

For an initial implementation, I was able to modify spirit.search.views to extract comments from the search results and find only the matching comments and display them. May not scale well for large sites.