So, if you add a normal character in with all of these special characters, and
run it all through Riddle.escape, it behaves correctly?
On 28/12/2012, at 12:18 AM, Alexander Sologub wrote:
> def conditions_as_query
> return '' if @options[:conditions].blank?
> ' ' + @options[:conditions].keys.collect { |key| "@#{key}
> #{Riddle.escape(options[:conditions][key]})"}.join(' ')
> end
>
> It's in search.rb file (lib/thinking_sphinx/search.rb) in ThinkingSphinx
> source files (I forked this gem and made these modifications).
> However, it's the way I tried to fix problem described above. I get errors in
> both clean and modified implementations.
>
> четверг, 27 декабря 2012 г., 16:11:18 UTC+3 пользователь Pat Allan написал:
> Wait, so where is Riddle.escape being used?
> On 27/12/2012, at 8:14 PM, Alexander Sologub wrote:
>
> > Here's the code:
> > def get_location_filter
> > cookies[:event_location_near_filter]
> > end
> >
> > I mean, it returns simple string from user input. It's not Sphinx query.
> > Examples:
> > 1) 'Moscow', 'London' - they don't cause exceptions at all.
> > 2) '\\Moscow!@$'' (or any combination of unknown symbols + at least one
> > symbol from charset_table) - still no exceptions.
> > 3) ' #$%^' - input contains unknown symbols only - ThinkingShpinxError =>
> > (Sphinx itself returns 'unexpected $end near' first symbol of this field).
> >
> > I used "binding.pry" inside of ThinkingSphinx source code to determine
> > conditions of exception firing.
> > Query itself looks like this: (for user input @@$%!%!)
> > "@near \\@\\@\\$%\\!%\\!"
> >
> > As i said before, I've used Riddle.escape to escape Sphinx-specific symbols.
> > I tried to enter some scary letters from UTF-8 table - they give the same
> > result:
> > If query consists from unknown characters only (not listed in
> > charset_table) then exception fires.
> >
> > четверг, 27 декабря 2012 г., 4:17:51 UTC+3 пользователь Pat Allan написал:
> > I think the get_location_filter is the important part, as that's providing
> > the query text, which is what Sphinx is complaining about.
> >
> > --
> > Pat
> >
> >
> > On 27/12/2012, at 2:37, Alexander Sologub <[email protected]> wrote:
> >
> >> Sure, here's the code:
> >>
> >> search_params = get_location_filter.present? ? { conditions: { near:
> >> get_location_filter } } : {}
> >> search_params[:with] = { category_ids: get_category_filter } if
> >> get_category_filter.present?
> >>
> >> @events = Event.search(search_params).sx_limit(7)
> >> render
> >>
> >> Also, here's declaration of sx_limit scope:
> >>
> >> sphinx_scope(:sx_limit) { |limit| { limit: limit } }
> >>
> >> get_location_filter helper just returns unescaped query from user input.
> >>
> >> Also, here's declaration of :near field:
> >> indexes [location.country, location.city, location.country_full_name], as:
> >> :near
> >>
> >> среда, 26 декабря 2012 г., 16:13:18 UTC+3 пользователь Pat Allan написал:
> >> Hi Alexander
> >> Can you share the controller action that's making this search call? I'd
> >> like to get the full context, which may provide some clues as to why
> >> you're getting this error.
> >>
> >> Cheers
> >>
> >> --
> >> Pat
> >>
> >> On 27/12/2012, at 12:08 AM, Alexander Sologub wrote:
> >>
> >> > Forgot to mention - Sphinx returns errors (and Thinking Sphinx firing
> >> > exceptions) when search term consists of separators ONLY.
> >> > Example:
> >> > @some_field ![]''
> >> >
> >> >
> >> > вторник, 25 декабря 2012 г., 16:56:07 UTC+3 пользователь Alexander
> >> > Sologub написал:
> >> > Hi there!
> >> > We are using Thinking Sphinx for fulltext search in our project, but now
> >> > we face that nifty problem.
> >> > As I red in Sphinx documentation, characters missing in charset_table
> >> > should be treated like separators.
> >> > Also, I call Riddle.escape('my_gorgeous_request') before calling
> >> > ::search method on my models.
> >> > But I don't get expected result (at least empty one). I end up with
> >> > ThinkingSphinx::SphinxError.
> >> >
> >> > So, the question is - How can I solve this?
> >> > Should I add all undesired symbols to charset_table? But it's kind of
> >> > stupid to copy all UTF-8 table there...
> >> > Maybe there's some kind of configuration option I don't know about (for
> >> > Sphinx itself?)
> >> > Or maybe, I'm doing something wrong?
> >> >
> >> > --
> >> > You received this message because you are subscribed to the Google
> >> > Groups "Thinking Sphinx" group.
> >> > To view this discussion on the web visit
> >> > https://groups.google.com/d/msg/thinking-sphinx/-/HdceEdphtfIJ.
> >> > To post to this group, send email to [email protected].
> >> > To unsubscribe from this group, send email to
> >> > [email protected].
> >> > For more options, visit this group at
> >> > http://groups.google.com/group/thinking-sphinx?hl=en.
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >> --
> >> You received this message because you are subscribed to the Google Groups
> >> "Thinking Sphinx" group.
> >> To view this discussion on the web visit
> >> https://groups.google.com/d/msg/thinking-sphinx/-/Umh7IOqKangJ.
> >> To post to this group, send email to [email protected].
> >> To unsubscribe from this group, send email to
> >> [email protected].
> >> For more options, visit this group at
> >> http://groups.google.com/group/thinking-sphinx?hl=en.
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Thinking Sphinx" group.
> > To view this discussion on the web visit
> > https://groups.google.com/d/msg/thinking-sphinx/-/uimBqDRXVBEJ.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected].
> > For more options, visit this group at
> > http://groups.google.com/group/thinking-sphinx?hl=en.
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Thinking Sphinx" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/thinking-sphinx/-/-7OqpwNOO2sJ.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/thinking-sphinx?hl=en.
--
You received this message because you are subscribed to the Google Groups
"Thinking Sphinx" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/thinking-sphinx?hl=en.