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

Inflexible configurations #2

Open
2 tasks done
netchampfaris opened this issue Feb 19, 2024 · 1 comment
Open
2 tasks done

Inflexible configurations #2

netchampfaris opened this issue Feb 19, 2024 · 1 comment

Comments

@netchampfaris
Copy link

netchampfaris commented Feb 19, 2024

The index path is hardcoded, must have been an oversight. I think index should be specific to a site and should go inside the site folder.

INDEX_PATH = "/Users/safwan/frappe-bench/apps/frappe_search/index"

This is the error I got when I ran the command bench --site gameplan.frappe.test execute frappe_search.api.build_index

Traceback (most recent call last):
  File "/Users/netchampfaris/Projects/frappe-bench/apps/frappe/frappe/commands/utils.py", line 276, in execute
    ret = frappe.get_attr(method)(*args, **kwargs)
  File "/Users/netchampfaris/Projects/frappe-bench/apps/frappe/frappe/utils/typing_validations.py", line 31, in wrapper
    return func(*args, **kwargs)
  File "/Users/netchampfaris/Projects/frappe-bench/apps/frappe_search/frappe_search/api.py", line 19, in build_index
    return build_complete_index(auto_index)
  File "/Users/netchampfaris/Projects/frappe-bench/apps/frappe_search/frappe_search/frappe_search/doctype/search/search.py", line 244, in build_complete_index
    index = Index(schema, path=INDEX_PATH)
ValueError: Directory does not exist: '/Users/safwan/frappe-bench/apps/frappe_search/index'.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/homebrew/Cellar/python@3.10/3.10.13_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/opt/homebrew/Cellar/python@3.10/3.10.13_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/Users/netchampfaris/Projects/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 114, in <module>
    main()
  File "/Users/netchampfaris/Projects/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 20, in main
    click.Group(commands=commands)(prog_name="bench")
  File "/Users/netchampfaris/Projects/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/Users/netchampfaris/Projects/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/Users/netchampfaris/Projects/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/netchampfaris/Projects/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/netchampfaris/Projects/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/netchampfaris/Projects/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/Users/netchampfaris/Projects/frappe-bench/env/lib/python3.10/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/Users/netchampfaris/Projects/frappe-bench/apps/frappe/frappe/commands/__init__.py", line 29, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/Users/netchampfaris/Projects/frappe-bench/apps/frappe/frappe/commands/utils.py", line 279, in execute
    ret = eval(method + "(*args, **kwargs)", globals(), locals())  # nosemgrep
  File "<string>", line 1, in <module>
NameError: name 'frappe_search' is not defined

if groupby == "true":
groupby = True
elif isinstance(groupby, str):
groupby = False

There shouldn't be a case where boolean value is sent as string. Also group_by > groupby.


Finally the search API call also breaks with the following error:

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 110, in application
    response = frappe.api.handle(request)
  File "apps/frappe/frappe/api/__init__.py", line 49, in handle
    data = endpoint(**arguments)
  File "apps/frappe/frappe/api/v1.py", line 36, in handle_rpc_call
    return frappe.handler.handle()
  File "apps/frappe/frappe/handler.py", line 49, in handle
    data = execute_cmd(cmd)
  File "apps/frappe/frappe/handler.py", line 85, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "apps/frappe/frappe/__init__.py", line 1779, in call
    return fn(*args, **newargs)
  File "apps/frappe/frappe/utils/typing_validations.py", line 31, in wrapper
    return func(*args, **kwargs)
  File "apps/frappe_search/frappe_search/api.py", line 14, in search
    return tantivy_search(query, target_number, groupby)
  File "apps/frappe_search/frappe_search/frappe_search/doctype/search/search.py", line 43, in tantivy_search
    query = index.parse_query(
TypeError: Index.parse_query() got an unexpected keyword argument 'fuzzy_fields'

Other:

  • Auto create index folder inside site folder (sites/sitename/frappe_search_index)
  • Should show some progress bar when build_index command is run
@safwansamsudeen
Copy link
Owner

safwansamsudeen commented Feb 21, 2024

@netchampfaris I remember some API call with frappe.call sent it over as a string.

That is weird - search works for me. Are you sure you have the latest version? Fuzzy fields is only supported after tantivy-py#202 was merged.

You can now test this by creating the directory frappe-search-index in your site.

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