Update:
Just by chance I've found that the following thing works. I mean that
it doesn't raise any errors and find some objects....but I don't
understand how it works at all:
with_display = "*, IF(available_online = 1 OR geodist(3,3,3,3) = 20,
1, 0) AS display"
@books = Book.search("ordenador", :geo =>
[@latitude,@longitude], :sphinx_select => with_display, :with =>
{'display' => 1})
So, I don't understand what are those four parameters that I pass
geodist() and I don't understand either what is the meaning of the
value that it returns, where I put "20". I've changed those values and
the number of Books found changes, so it's actually doing "something",
although I don't understand what. Any clues?
Thanks!
On Jun 15, 9:25 pm, Yomismo <[email protected]> wrote:
> Hello!
>
> I asked this same question some time ago. Pat Allan gave me a hint to
> solve the problem, but I didn't manage to make it work.
>
> So I used a different solution, but now the website is working and I
> have realized that the other solution would be much better.
>
> So, the problem is simple, I have
>
> class Book < ActiveRecord::Base
>
> define_index do
> indexes title
> has latitude
> has longitude
> has available_online
> end
>
> I need to search books that are within certain distance range OR are
> available online.
>
> I read this:
>
> http://freelancing-god.github.com/ts/en/common_issues.html#or_attributes
>
> and I've been trying to do something like:
>
> with_display = "*, IF(available_online = 1 OR (geodist BETWEEN 0 AND
> 100), 1, 0) AS display"
>
> @books = Book.search("The title", :geo =>
> [@latitude,@longitude], :sphinx_select => with_display, :with =>
> {'display' => 1})
>
> But I get an error:
>
> Riddle::ResponseError: searchd error (status: 1): select: syntax
> error, unexpected SEL_TOKEN near 'BETWEEN 0 AND 3), 1, 0) AS display'
>
> So, the thing is... Is it possible to filter the "geodist" attribute
> that way?? I don't even know if I should use "geodist" or the column
> has some other name or if the syntax is correct. Any ideas??
>
> Thank you very much for your help!
--
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.