Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search function not work #304

Closed
catmemo opened this issue Dec 25, 2021 · 17 comments
Closed

Search function not work #304

catmemo opened this issue Dec 25, 2021 · 17 comments

Comments

@catmemo
Copy link

catmemo commented Dec 25, 2021

Followed below steps:

pip install django-spirit
spirit startproject mysite
cd mysite
python manage.py spiritinstall
python manage.py createsuperuser
python manage.py runserver

But return nothing when searching. Could you please help to check? Thks~
@nitely

@nitely
Copy link
Owner

nitely commented Dec 25, 2021

Read this: https://spirit.readthedocs.io/en/latest/task_manager.html

Functionality that requires a task manager includes: search indexation.

also email notfications. However, for very small sites you may use the real time indexation (it'll increase the time it takes to post/comment/create topics), see https://django-haystack.readthedocs.io/en/master/signal_processors.html#realtime-realtimesignalprocessor

@catmemo
Copy link
Author

catmemo commented Dec 27, 2021

Thank you very much!

@nitely nitely closed this as completed Dec 27, 2021
@catmemo
Copy link
Author

catmemo commented Jan 5, 2022 via email

@nitely
Copy link
Owner

nitely commented Jan 5, 2022

try running python manage.py rebuild_index that should index existing/old topics, then search. If it works, then set up a task manager https://spirit.readthedocs.io/en/latest/task_manager.html , not sure why the realtime search does not work.

If that command does not work, then there is something wrong with your setup.

@nitely
Copy link
Owner

nitely commented Jan 5, 2022

btw, are you trying things in a local machine or what?

@catmemo
Copy link
Author

catmemo commented Jan 5, 2022

Local windows 10 pc

@nitely
Copy link
Owner

nitely commented Jan 5, 2022

ok, the whoosh search engine that comes configured by default should probably work (I'm a Linux user, not sure)

@catmemo
Copy link
Author

catmemo commented Jan 5, 2022

ok, the whoosh search engine that comes configured by default should probably work (I'm a Linux user, not sure)

The command works and indexing 2 topics, but when I tried to search something response with nothing again.
Actually, I also deploy it to Ubuntu Apache2 and got the same results.

And it still does not work after I set up the huey task manager.

@nitely
Copy link
Owner

nitely commented Jan 5, 2022

The command works and indexing 2 topics, but when I tried to search something response with nothing again.

since the topics got indexed, the search should work. Not sure why it does not. Are you searching full words contained in the comments/topic title?

not sure why the realtime search does not work

it does not work, because it requires a task manager. If you remove this check, it should work:

if settings.ST_TASK_MANAGER is None:

And it still does not work after I set up the huey task manager.

if python manage.py rebuild_index says it indexed some topics, and they do not show in the search result, then the search just won't work any other way. There is something wrong with your setup, I don't know what it is.

I use the prod.py setting without any significant change and it works for me.

@nitely
Copy link
Owner

nitely commented Jan 5, 2022

one thing you can check is if you have multiple st_search folders, that's where the whoosh index is stored, if you have more than one it could mean you are indexing the topics in one place, but the server is reading the index from another place.

@catmemo
Copy link
Author

catmemo commented Jan 5, 2022

The command works and indexing 2 topics, but when I tried to search something response with nothing again.

since the topics got indexed, the search should work. Not sure why it does not. Are you searching full words contained in the comments/topic title?

not sure why the realtime search does not work

it does not work, because it requires a task manager. If you remove this check, it should work:

if settings.ST_TASK_MANAGER is None:

And it still does not work after I set up the huey task manager.

if python manage.py rebuild_index says it indexed some topics, and they do not show in the search result, then the search just won't work any other way. There is something wrong with your setup, I don't know what it is.

I use the prod.py setting without any significant change and it works for me.

As you see, I have 3 topics now and when I searched "test" it works well. But failed when searching "LOG".
image

However, if I searched "如何抓取LOG" and it works.

@nitely
Copy link
Owner

nitely commented Jan 9, 2022

Search won't find partial words. IIRC, I was working on searching partial words, but the generated index was huge, it went from a few MBs to many GBs. I thought there was a setting to turn this on, but there is not. Anyway, the reason you cannot find LOG is because it's not separated by spaces (ie: it's not considered a whole word).

I made a library to split unicode words a while ago, but in Nim https://github.com/nitely/nim-segmentation
it would separate that string as ["如", "何", "抓", "取", "LOG"], not sure if that's correct, or we need something like the NLKT, or just an option to enable partial words matching.

@catmemo
Copy link
Author

catmemo commented Jan 10, 2022

Yes, it's correct.

@nitely
Copy link
Owner

nitely commented Jan 10, 2022

Reopening so I'll fix it

@nitely nitely reopened this Jan 10, 2022
@catmemo
Copy link
Author

catmemo commented Jan 10, 2022

Reopening so I'll fix it

Thanks for your working!

@nitely
Copy link
Owner

nitely commented Jan 28, 2022

I've added support for Ngram index (search on Asian languages).

The changes is unreleased, so you'll need to install with:

pip install git+https://github.com/nitely/Spirit.git

then add this to your settings:

ST_NGRAM_SEARCH = True

you'll need to rebuild the search index:

python manage.py rebuild_index

and restart the server.

Last time I tried this it generated a huge index, but it works.

@nitely
Copy link
Owner

nitely commented Feb 23, 2022

I released v0.12.3 with the ST_NGRAM_SEARCH setting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants