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

Wildcard search support #59

Open
szakitibi opened this issue Jul 8, 2019 · 0 comments
Open

Wildcard search support #59

szakitibi opened this issue Jul 8, 2019 · 0 comments

Comments

@szakitibi
Copy link

Current version of EZCTextIndex does not support wildcard search.

To be exact it strips * wildcard from the end of the search value:

        # ES doesn't care about * like zope catalog does
        clean_value = value.strip('*') if value else ""

The * wildcard is added by Plone global search, thus current version changes how global search works!

ElasticSearch supports wildcard query since version 0.90.

Suggestion:

At the end of the EZCTextIndex.get_query method:

    if clean_value != value:
        # ES docs says:
        #     "to prevent extremely slow wildcard queries, a wildcard
        #      term should not start with one of the wildcards * or ?"
        # strip all wildcards from left and remove excess spaces
        stripped_value = ' '.join([i.lstrip('*?') for i in value.split()]).strip()
        # if we still have a valid value, append as wildcard query
        if stripped_value:
            queries.append({"wildcard": {name: stripped_value}})

Note: It would still change Plone global search. It supports both ? and * wildcard characters, but in my opinion adding extra functionality to global search is still better then stripping it away.

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

1 participant