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 strings with spaces not being handled properly #21

Open
upman opened this issue Sep 19, 2015 · 2 comments
Open

Wildcard strings with spaces not being handled properly #21

upman opened this issue Sep 19, 2015 · 2 comments

Comments

@upman
Copy link

upman commented Sep 19, 2015

 q = scorched.strings.WildcardString('abc abc*')
 si.query(q)

raises scorched.exc.SolrError: <Response [400]>

@upman
Copy link
Author

upman commented Sep 19, 2015

I was able to fix this with a little change to strings.py

def get_wildcards(self, s):
        backslash = False
        i = 0
        chars = []
        for c in s:
            if backslash:
                backslash = False
                chars.append(c)
                continue
            i += 1
            if c == u'\\':
                backslash = True
            elif c == u'*':
                chars.append(self.Asterisk())
            elif c == u'?':
                chars.append(self.QuestionMark())
            elif c == ' ':
                ###
                ### Escape the spaces explicitly
                ###
                chars.append('\\ ')
            else:
                chars.append(c)
        if backslash:
            chars.append(u'\\')
        return chars

Don't think this is a good fix though.
I think the other special characters '+-&|!(){}[]^"~: \t\v/' have to be escaped as well?

@bdew70
Copy link

bdew70 commented Dec 14, 2015

+1

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