-
Notifications
You must be signed in to change notification settings - Fork 96
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
DatabaseException on select query with extended characters as first symbols in a match value #131
Comments
I get this as well, weirdest part is when input is nothing but a space it throws the same error.. Edit: looks like it might have something to do with the MATCH part of the query builder, usually the query looks something like this:
But when given only a space it just looks like this
Which is a syntax error in SphinxQL afaik. With just a parenthesis it correctly escapes it but it's still a syntax error:
My suggestion is to just enclose the search-term part with double quotes, like this:
This has fixed all of the failed queries I've tested, but I'm no expert so I'm not sure if it's the most ideal solution. |
This fell off my radar a few times already and it's a bit of a difficult solve. @sergeypayu could you try the following as part of your query? I wonder if we have some odd escaping issue with our current list of characters/mapping.
@Necklaces could you also try the same? Also, let me try to address some of the errors you are having...
This does seem to be the correct behavior.
From what I can tell, this one actually works because it's performing an exact match and assumes everything in the double quotes to be what it should be searching in your documents/index. |
Also, I don't have |
Well, I tried doing this:
But I still get the same error when putting ')' into search term:
Same goes for space, and seemingly all of these characters when alone in the searchterm. |
The same problem here. If the term starts with What I did as a dirty workaround, is just to remove all special characters from the beginning of string: $search_term = ltrim($search_term, '\()-!@%~"&/^$=');
if(!$search_term) {
return [];
} Any better ideas? |
Hello. |
Having this issue too. Only when it's the only char. Can search for /whatever but not for / or a space etc. It also seems you cannot exclude words anymore with the - char. |
I just did this and it seems to work. Searching for / or a space as the only char doesn't crash anymore, plus Boolean search now works: $query->match($column, $searchString, true);
try {
return $query->execute()->fetchAllAssoc() ?? [];
} catch (\Foolz\SphinxQL\Exception\DatabaseException $e) {
return [];
} Added the true param to the match() method and then wrapped the execution in a try/catch just outputting an empty array on error. |
I get
Foolz\SphinxQL\Exception\DatabaseException: [1064] index kbindex: syntax error, unexpected ')' near '\()' [ SELECT * FROM kbindex WHERE MATCH('(\\()')]
error when trying to make a select query if I use special symbols as first character in match value. Example:I didn't find any way to gracefully escape such values. I can bypass the problem by manually constructing a match query like this:
But I hope you can fix it inside your code.
The text was updated successfully, but these errors were encountered: