frappe / wiki

Free and Open Source Wiki built on top of Frappe
https://frappe.io/wiki
MIT License
242 stars 200 forks source link

Search doesn't work #157

Closed Mishman7 closed 1 year ago

Mishman7 commented 1 year ago

Version 2.0.0 Local install on same site as ERPnext Search gives only "Not results found" In bench debugger there is '"POST / HTTP/1.1" 200' - request on search field typing. It should contain "/wiki" in URL, i think. Cannot find any settings for wiki search.

BreadGenie commented 1 year ago

Hey, I'm assuming you're using Frappe Framework v14. This error happened because the v2.0.0 tag's target was master (which doesn't support Frappe Framework v14). I've changed it to the version-14 branch and now the search will work fine.

Mishman7 commented 1 year ago

@BreadGenie what should I do in my bench? bench switch-to-branch version-14 wiki

BreadGenie commented 1 year ago

@BreadGenie what should I do in my bench? bench switch-to-branch version-14 wiki

Yes, that will work fine too

Mishman7 commented 1 year ago

@BreadGenie what should I do in my bench? bench switch-to-branch version-14 wiki

Yes, that will work fine too

Got error after switch-to branch and bench update --patch admin@testerp:~/frappe$ bench update --patch remote: Total 0 (delta 0), reused 0 (delta 0), pack-reused 0 From https://github.com/frappe/frappe

Consider the consequences of git reset --hard on your apps before you run that.
To avoid seeing this warning, set shallow_clone to false in your common_site_config.json

Backing up sites...
Backup Summary for erpnext.voks-it.local at 2023-05-31 19:16:04.972626 Config : ./erpnext.voks-it.local/private/backups/20230531_191603-erpnext_voks-it_local-site_config_backup.json 271.0B Database: ./erpnext.voks-it.local/private/backups/20230531_191603-erpnext_voks-it_local-database.sql.gz 1.8MiB Backup for Site erpnext.voks-it.local has been successfully completed Patching sites... Migrating erpnext.voks-it.local Updating DocTypes for frappe : [========================================] 100% Updating DocTypes for erpnext : [========================================] 100% Updating DocTypes for hrms : [========================================] 100% Updating DocTypes for chat : [========================================] 100% Updating DocTypes for vitapp : [========================================] 100% Updating DocTypes for wiki : [========================================] 100% wiki.wiki.doctype.wiki_page.search.rebuild_index_if_not_exists is not a valid method: No module named 'redisearch' Updating Dashboard for frappe Updating Dashboard for erpnext Updating Dashboard for hrms Updating Dashboard for chat Updating Dashboard for vitapp Updating Dashboard for wiki Updating customizations for Address Updating customizations for Contact Queued rebuilding of search index for erpnext.voks-it.local

Traceback with variables (most recent call last): File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, mod_name = 'frappe.utils.bench_helper' alter_argv = True mod_spec = ModuleSpec(name='frappe.utils.bench_helper', loader=<_frozen_importlib_external.SourceFileLoader object at 0x7f3371b3ee90>, origin='/home/admin/frappe/apps/frappe/frappe/utils/bench_helper.py') code = <code object at 0x7f336ef7f7e0, file "/home/admin/frappe/apps/frappe/frappe/utils/bench_helper.py", line 1> main_globals = {'name': 'main', 'doc': None, 'package': 'frappe.utils', 'loader': <_frozen_importlib_external.SourceFileLoader object at 0x7f3371b3ee90>, 'spec': ModuleSpec(name='frappe.utils.bench_helper', loader=<_frozen_importlib_external.SourceFileLoader object at 0x7f3371b3ee90>, origin='/home/admin/frappe/apps/frappe/frappe/utils/bench_helper.py'), 'annotations': {}, 'builtins': <module 'builtins' (built-in)>, 'file': '/home/admin/frappe/apps/frappe/frappe/utils/bench_helper.py', 'cached': '/home/admin/frappe/apps/frappe/frappe/utils/pycache/bench_helper.cpython-310.pyc', 'importlib': <module 'importlib' from '/usr/lib/python3.10/importlib/init.py'>, 'json': <module 'json' from '/usr/lib/python3.10/json/init.py'>, 'os': <module 'os' from '/usr/lib/python3.10/os.py'>, 'traceback': <module 'traceback' from '/usr/lib/python3.10/traceback.py'>, 'warnings': <module 'warnings' from '/usr/lib/python3.10/warnings.py'>, 'Path': <class 'pathlib.Path'>, ... File "/usr/lib/python3.10/runpy.py", line 86, in _run_code exec(code, run_globals) code = <code object at 0x7f336ef7f7e0, file "/home/admin/frappe/apps/frappe/frappe/utils/bench_helper.py", line 1> run_globals = {'name': 'main', 'doc': None, 'package': 'frappe.utils', 'loader': <_frozen_importlib_external.SourceFileLoader object at 0x7f3371b3ee90>, 'spec': ModuleSpec(name='frappe.utils.bench_helper', loader=<_frozen_importlib_external.SourceFileLoader object at 0x7f3371b3ee90>, origin='/home/admin/frappe/apps/frappe/frappe/utils/bench_helper.py'), 'annotations': {}, 'builtins': <module 'builtins' (built-in)>, 'file': '/home/admin/frappe/apps/frappe/frappe/utils/bench_helper.py', 'cached': '/home/admin/frappe/apps/frappe/frappe/utils/pycache/bench_helper.cpython-310.pyc', 'importlib': <module 'importlib' from '/usr/lib/python3.10/importlib/init.py'>, 'json': <module 'json' from '/usr/lib/python3.10/json/init.py'>, 'os': <module 'os' from '/usr/lib/python3.10/os.py'>, 'traceback': <module 'traceback' from '/usr/lib/python3.10/traceback.py'>, 'warnings': <module 'warnings' from '/usr/lib/python3.10/warnings.py'>, 'Path': <class 'pathlib.Path'>, ... init_globals = None mod_name = 'main' mod_spec = ModuleSpec(name='frappe.utils.bench_helper', loader=<_frozen_importlib_external.SourceFileLoader object at 0x7f3371b3ee90>, origin='/home/admin/frappe/apps/frappe/frappe/utils/bench_helper.py') pkg_name = 'frappe.utils' script_name = None loader = <_frozen_importlib_external.SourceFileLoader object at 0x7f3371b3ee90> fname = '/home/admin/frappe/apps/frappe/frappe/utils/bench_helper.py' cached = '/home/admin/frappe/apps/frappe/frappe/utils/pycache/bench_helper.cpython-310.pyc' File "/home/admin/frappe/apps/frappe/frappe/utils/bench_helper.py", line 104, in main() ...skipped... 26 vars File "/home/admin/frappe/apps/frappe/frappe/utils/bench_helper.py", line 19, in main click.Group(commands=commands)(prog_name="bench") commands = {'frappe': , 'get-frappe-commands': , 'get-frappe-help': } File "/home/admin/frappe/env/lib/python3.10/site-packages/click/core.py", line 1130, in call return self.main(args, kwargs) self = args = () kwargs = {'prog_name': 'bench'} File "/home/admin/frappe/env/lib/python3.10/site-packages/click/core.py", line 1055, in main rv = self.invoke(ctx) self = args = ['frappe', '--site', 'erpnext.voks-it.local', 'migrate'] prog_name = 'bench' complete_var = None standalone_mode = True windows_expand_args = True extra = {} ctx = <click.core.Context object at 0x7f3370570190> File "/home/admin/frappe/env/lib/python3.10/site-packages/click/core.py", line 1657, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) _process_result = <function MultiCommand.invoke.._process_result at 0x7f336ef88820> args = ['migrate'] cmd_name = 'frappe' cmd = sub_ctx = <click.core.Context object at 0x7f336ee4c1c0> ctx = <click.core.Context object at 0x7f3370570190> self = class = <class 'click.core.MultiCommand'> File "/home/admin/frappe/env/lib/python3.10/site-packages/click/core.py", line 1657, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) _process_result = <function MultiCommand.invoke.._process_result at 0x7f336ee2fac0> args = [] cmd_name = 'migrate' cmd = sub_ctx = <click.core.Context object at 0x7f336ee4c520> ctx = <click.core.Context object at 0x7f336ee4c1c0> self = class = <class 'click.core.MultiCommand'> File "/home/admin/frappe/env/lib/python3.10/site-packages/click/core.py", line 1404, in invoke return ctx.invoke(self.callback, ctx.params) self = ctx = <click.core.Context object at 0x7f336ee4c520> File "/home/admin/frappe/env/lib/python3.10/site-packages/click/core.py", line 760, in invoke return __callback(args, kwargs) _Contextself = <click.core.Context object at 0x7f336ee4c520> _Context__callback = <function migrate at 0x7f336effc670> args = () kwargs = {'skip_failing': False, 'skip_search_index': False} ctx = <click.core.Context object at 0x7f336ee4c520> File "/home/admin/frappe/env/lib/python3.10/site-packages/click/decorators.py", line 26, in new_func return f(get_current_context(), *args, **kwargs) args = () kwargs = {'skip_failing': False, 'skip_search_index': False} f = <function migrate at 0x7f336effc430> File "/home/admin/frappe/apps/frappe/frappe/commands/init__.py", line 29, in _func ret = f(frappe._dict(ctx.obj), *args, kwargs) ctx = <click.core.Context object at 0x7f336ee4c520> args = () kwargs = {'skip_failing': False, 'skip_search_index': False} profile = False f = <function migrate at 0x7f336effc3a0> File "/home/admin/frappe/apps/frappe/frappe/commands/site.py", line 605, in migrate SiteMigration( context = {'sites': ['erpnext.voks-it.local'], 'force': False, 'verbose': False, 'profile': False} skip_failing = False skip_search_index = False activate_by_import = <module 'traceback_with_variables.activate_by_import' from '/home/admin/frappe/env/lib/python3.10/site-packages/traceback_with_variables/activate_by_import.py'> SiteMigration = <class 'frappe.migrate.SiteMigration'> site = 'erpnext.voks-it.local' File "/home/admin/frappe/apps/frappe/frappe/migrate.py", line 179, in run self.post_schema_updates() self = <frappe.migrate.SiteMigration object at 0x7f336ee4c490> site = 'erpnext.voks-it.local' filelock = <function filelock at 0x7f336efa9cf0> File "/home/admin/frappe/apps/frappe/frappe/migrate.py", line 41, in wrapper ret = method(*args, **kwargs) args = (<frappe.migrate.SiteMigration object at 0x7f336ee4c490>,) kwargs = {} method = <function SiteMigration.post_schema_updates at 0x7f336cb8e3b0> File "/home/admin/frappe/apps/frappe/frappe/migrate.py", line 144, in post_schema_updates frappe.get_attr(fn)() self = <frappe.migrate.SiteMigration object at 0x7f336ee4c490> app = 'wiki' fn = 'wiki.wiki.doctype.wiki_page.search.rebuild_index_in_background' File "/home/admin/frappe/apps/frappe/frappe/init.py", line 1619, in get_attr return getattr(get_module(modulename), methodname) method_string = 'wiki.wiki.doctype.wiki_page.search.rebuild_index_in_background' app_name = 'wiki' modulename = 'wiki.wiki.doctype.wiki_page.search' methodname = 'rebuild_index_in_background' File "/home/admin/frappe/apps/frappe/frappe/init.py", line 1349, in get_module return importlib.import_module(modulename) modulename = 'wiki.wiki.doctype.wiki_page.search' File "/usr/lib/python3.10/importlib/init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) name = 'wiki.wiki.doctype.wiki_page.search' package = None level = 0 File "", line 1050, in _gcd_import name = 'wiki.wiki.doctype.wiki_page.search' package = None level = 0 File "", line 1027, in _find_and_load name = 'wiki.wiki.doctype.wikipage.search' import = <function _gcd_import at 0x7f3371dbf400> module = <object object at 0x7f3371de4060> File "", line 1006, in _find_and_load_unlocked name = 'wiki.wiki.doctype.wikipage.search' import = <function _gcd_import at 0x7f3371dbf400> path = ['/home/admin/frappe/apps/wiki/wiki/wiki/doctype/wiki_page'] parent = 'wiki.wiki.doctype.wiki_page' parent_module = <module 'wiki.wiki.doctype.wiki_page' from '/home/admin/frappe/apps/wiki/wiki/wiki/doctype/wiki_page/init.py'> spec = ModuleSpec(name='wiki.wiki.doctype.wiki_page.search', loader=<_frozen_importlib_external.SourceFileLoader object at 0x7f336a0b82b0>, origin='/home/admin/frappe/apps/wiki/wiki/wiki/doctype/wiki_page/search.py') File "", line 688, in _load_unlocked spec = ModuleSpec(name='wiki.wiki.doctype.wiki_page.search', loader=<_frozen_importlib_external.SourceFileLoader object at 0x7f336a0b82b0>, origin='/home/admin/frappe/apps/wiki/wiki/wiki/doctype/wiki_page/search.py') module = <module 'wiki.wiki.doctype.wiki_page.search' from '/home/admin/frappe/apps/wiki/wiki/wiki/doctype/wiki_page/search.py'> File "", line 883, in exec_module self = <_frozen_importlib_external.SourceFileLoader object at 0x7f336a0b82b0> module = <module 'wiki.wiki.doctype.wiki_page.search' from '/home/admin/frappe/apps/wiki/wiki/wiki/doctype/wiki_page/search.py'> code = <code object at 0x7f3369f09dc0, file "/home/admin/frappe/apps/wiki/wiki/wiki/doctype/wiki_page/search.py", line 1> File "", line 241, in _call_with_frames_removed f = args = (<code object at 0x7f3369f09dc0, file "/home/admin/frappe/apps/wiki/wiki/wiki/doctype/wiki_page/search.py", line 1>, {'name': 'wiki.wiki.doctype.wiki_page.search', 'doc': None, 'package': 'wiki.wiki.doctype.wiki_page', 'loader': <_frozen_importlib_external.SourceFileLoader object at 0x7f336a0b82b0>, 'spec': ModuleSpec(name='wiki.wiki.doctype.wiki_page.search', loader=<_frozen_importlib_external.SourceFileLoader object at 0x7f336a0b82b0>, origin='/home/admin/frappe/apps/wiki/wiki/wiki/doctype/wiki_page/search.py'), 'file': '/home/admin/frappe/apps/wiki/wiki/wiki/doctype/wiki_page/search.py', 'cached': '/home/admin/frappe/apps/wiki/wiki/wiki/doctype/wiki_page/pycache/search.cpython-310.pyc', 'builtins': {'name': 'builtins', 'doc': "Built-in functions, exceptions, and other objects.\n\nNoteworthy: None is the nil' object; Ellipsis represents...' in slices.", 'package': '', 'loader': <class '_frozen_importlib.BuiltinImporter'>... kwds = {} File "/home/admin/frappe/apps/wiki/wiki/wiki/doctype/wiki_page/search.py", line 9, in from redisearch import Client, IndexDefinition, Query, TextField ...skipped... 13 vars builtins.ModuleNotFoundError: No module named 'redisearch'

BreadGenie commented 1 year ago

What version of Frappe Framework are you using? If you're using v14 then this might be happening due to the conflict of redisearch with redis-py you can remove redis and install redisearch using pip and that will solve the dependency issue.

Mishman7 commented 1 year ago

@BreadGenie frappe 15.x.x-develop

BreadGenie commented 1 year ago

Then you should be using master branch instead of version-14.

Mishman7 commented 1 year ago

Then you should be using master branch instead of version-14.

So, what steps should I take in general? Or there is no way to install wiki with current frappe version and apps?

BreadGenie commented 1 year ago

Currently v15.x.x or develop branch of Frappe Framework supports only Wiki master branch. And for v14.x.x or version-14 branch of Frappe Framework supports only Wiki version-14 branch.

You can switch branch to master in Wiki now.

Mishman7 commented 1 year ago

Ok, it is functioning now without errors. But search, obviously, not. Can I expect the search to work in the near future on master? And it would be great if there was some kind of guide on versions. Anyway thanks for the help and quick response!

BreadGenie commented 1 year ago

Search does work on master (take a look at https://frappeframework.com/docs/v14)

Can you try creating a temporary Wiki Space and see if search works? This can happen due to the index not being built properly.

Mishman7 commented 1 year ago

No, creation of new wiki space didn't help. Tried clear-cache and to restart bench. Maybe I missing some packages or modules?

admin@testerp:~/frappe$ pip show redisearch Name: redisearch Version: 2.1.1 Summary: RedisSearch Python Client Home-page: Author: RedisLabs Author-email: oss@redislabs.com License: BSD-3-Clause Location: /usr/local/lib/python3.10/dist-packages Requires: hiredis, redis, rejson, six Required-by:

BreadGenie commented 1 year ago

Maybe the reason for "No results found" now might be due to the existence of redisearch. redisearch package is deprecated and doesn't support from frappe v15 onwards (this is also why frappe version-14 branch doesn't support master branch of wiki).

What you can do is uninstall redisearch and redis packages through pip and then install redis-py (which will also install redis as it's dependency)

Mishman7 commented 1 year ago

Uninstalled redisearch, redis. I only found redispy (not redis-py) package, installed. Installed redis again. Restart bench. Behaviour is the same - "no results found".

BreadGenie commented 1 year ago

Oops, sorry redis-py was recently renamed to just redis.

Don't forget to uninstall redispy package meanwhile.

Mishman7 commented 1 year ago

Done. No effect.

BreadGenie commented 1 year ago

Can you try running bench --site <sitename> execute wiki.wiki.doctype.wiki_page.search.rebuild_index? This will rebuild index manually

Mishman7 commented 1 year ago

Can you try running bench --site <sitename> execute wiki.wiki.doctype.wiki_page.search.rebuild_index? This will rebuild index manually

Console showed next info: unknown command 'FT.CREATE', with args beginning with: '_d7ea0fa0c3240419|wiki/test' 'PREFIX' '1' '_d7ea0fa0c3240419|wiki_page_search_docwiki/test:' 'SCORE_FIELD' 'doc_score' 'SCORE' unknown command 'FT.CREATE', with args beginning with: '_d7ea0fa0c3240419|wiki' 'PREFIX' '1' '_d7ea0fa0c3240419|wiki_page_search_docwiki:' 'SCORE_FIELD' 'doc_score' 'SCORE' '0.5' 'SCHE'

BreadGenie commented 1 year ago

On a quick glance it looks like you don't have redis installed in your system (https://redis.io/docs/stack/get-started/install/). If you do have it installed can you share the installed version?

Mishman7 commented 1 year ago

I have two packages, Debian 12 : redis-server/testing 5:7.0.11-1 amd64 [upgradable from: 5:7.0.7-1] Persistent key-value database with network interface

redis-tools/testing 5:7.0.11-1 amd64 [upgradable from: 5:7.0.7-1] Persistent key-value database with network interface (client)

Package 'redis' not installed. So... maybe I need to install linux packages from apt not pip? There is redis/testing 5:7.0.11-1 package and python3-redis/testing 4.3.4-3 in repo.

BreadGenie commented 1 year ago

You need both redis packages (python package is just a wrapper over the actual redis package afaik)

Mishman7 commented 1 year ago

You need both redis packages (python package is just a wrapper over the actual redis package afaik)

Done. All the same.

BreadGenie commented 1 year ago

What's the output of bench --site <sitename> execute wiki.wiki.doctype.wiki_page.search.rebuild_index?

If it's nothing then it should work.

Mishman7 commented 1 year ago

What's the output of bench --site <sitename> execute wiki.wiki.doctype.wiki_page.search.rebuild_index?

If it's nothing then it should work.

I meant that error is persist and is same: unknown command 'FT.CREATE', with args beginning with: '_d7ea0fa0c3240419|wiki/test' 'PREFIX' '1' '_d7ea0fa0c3240419|wiki_page_search_docwiki/test:' 'SCORE_FIELD' 'doc_score' 'SCORE' unknown command 'FT.CREATE', with args beginning with: '_d7ea0fa0c3240419|wiki' 'PREFIX' '1' '_d7ea0fa0c3240419|wiki_page_search_docwiki:' 'SCORE_FIELD' 'doc_score' 'SCORE' '0.5' 'SCHE'

BreadGenie commented 1 year ago

Can you try loading redisearch.so file similar to how it's specified at https://github.com/frappe/wiki/blob/c6738f58aed25f6123ecb2858c1044e4f369dfff/.github/helper/install.sh#L36-L39

Mishman7 commented 1 year ago

Yes, now it works. My bench directory is /home/admin/frappe, so i specified in /home/admin/frappe/config/redis_cache.conf line loadmodule /home/admin/frappe/apps/wiki/.github/helper/redisearch.so , because there is no GITHUB_WORKSPACE variable outside of install script. Now rebuild_index goes without errors and search working on wiki. But it seems, that search are unlocalized - searching only English words... But works now!

BreadGenie commented 1 year ago

Can you create an issue for the other search issue (unlocalized search) with more info?

Mishman7 commented 1 year ago

Can you create an issue for the other search issue (unlocalized search) with more info?

Hmm... Is it your issue? Not redis?

BreadGenie commented 1 year ago

Not sure. You can create one so that I won't forget to take a look at it later.