pat / thinking-sphinx

Sphinx/Manticore plugin for ActiveRecord/Rails
http://freelancing-gods.com/thinking-sphinx
MIT License
1.63k stars 470 forks source link

TS3 searching. Encoding::CompatibilityError & sphinxql: syntax error #430

Closed mcmegavolt closed 11 years ago

mcmegavolt commented 11 years ago

In production, when I make request with Latin characters I get this error:

ActionView::Template::Error (sphinxql: syntax error, unexpected IDENT, expecting ')' 
near 's Magazine 2012', 'event_core', '*toefl* *provider* *tutor* *posting* *event* *tag*',
'<span class="match">' AS before_match, '</span>' AS after_match, ' &#8230; '
AS chunk_separator)'):

And when make request with Cyrillic characters I get this:

Encoding::CompatibilityError
(incompatible encoding regexp match (US-ASCII regexp with UTF-8 string)): 
app/controllers/search_controller.rb:7:in `index'

Production: Sphinx 2.0.4-release (r3135) thinking-sphinx-3.0.0

But in development I have problem only with Cyrillic with the same error. Searching with Latin queries in development is working fine.

mcmegavolt commented 11 years ago

I updated my bundle (I guess riddle gem was updated) Now, In production, when I make request with Latin characters (query is "TOEFL" in this case) I get results like this:

ts Unreadable symbols is Cyrillic that's showing incorrectly.

When I make request with Cyrillic characters I get the same Encoding::CompatibilityError as in the previous message.

I still can't find the answer ho to fix it :(

pat commented 11 years ago

Hi Aleksandr

Sorry I've not responded yet to this issue... I'm not yet sure what the cause is. I'll try to look into it soon, but if you're able to create a test application that reproduces the issue, that'd be fantastic.

Cheers

Pat

pat commented 11 years ago

Hi Aleksandr

Can you provide the full stacktrace of the error you're seeing when you search for Cycillic characters?

che-shr-cat commented 11 years ago

Hi Pat,

First of all thanks for the module.

I encountered somehow similar problem, when on my development with utf-8 searches the app crashed with the error "incompatible encoding regexp match (US-ASCII regexp with UTF-8 string)" leading to the line 28 of lib/thinking_sphinx/search/query.rb. I tried many things, nothing helped me. Then finally I've added at the head of this file the encoding line:

# encoding: utf-8

and the problem disappear.

I didn't find any mentions of the same problem in other places, and I'm not sure this was the best fix.

pat commented 11 years ago

@che-shr-cat thanks for that - I just pushed a commit with that line, so future releases will have it sorted :)