[LRUG] [Off Topic] Sphinx Filter
Steve Butterworth
steve at humbletechnologies.com
Thu Apr 24 13:32:07 PDT 2008
I did the same kind of thing but used UltraSphinx. In UltraSphinx he
important thing to note is that numeric conditions have to be declared
as filters rather than in the query itself.
e.g.
s = Ultrasphinx::Search.new(:query=>keywords, :filters=>{:published=>1})
Not sure if this helps as you are using sphincter but there's clearly
some distinction between numeric and textual data
Good luck
Steve
http://www.humbletechnologies.com
Andrew Stewart wrote:
> Hello El Rug,
>
> I'm using a Ruby library that uses Sphinx to search my database, and
> can't seem to get conditions working in my application's search
> code. To try to isolate the problem, I stopped debugging from the
> application down and started working from the database up. However I
> got stuck that way too!
>
> If anyone can help with either stuckage, that would be great.
>
>
> * Lower-level Problem
>
> The articles table I'm searching has a boolean published column.
> (Being MySQL, this is a tinyint(1).) I want to search the published
> articles. I have configured Sphinx to index the published and title
> columns.
>
> MySQL:
> mysql> select * from articles where published = 1 and title like '%
> portim%';
> => correctly returns the published articles with portim in the title.
>
> Sphinx via the command line:
> $ search -c sphinx/development/sphinx.conf -i articles portim
> => correctly returns the articles with portim in the title
>
> But how to get Sphinx to stick to published articles? None of these
> works:
>
> search -c sphinx/development/sphinx.conf -i articles -f published 1
> portim
> search -c sphinx/development/sphinx.conf -i articles -f published [1]
> portim
> search -c sphinx/development/sphinx.conf -i articles -f 'published' 1
> portim
> search -c sphinx/development/sphinx.conf -i articles -f 'published 1'
> portim
> search -c sphinx/development/sphinx.conf -i articles -f 'published'
> '1' portim
>
>
> * Higher-level Problem
>
> My app uses Sphincter to perform the searches. You can pass a hash
> to the search method, with a key for any conditions.
>
> If I specify the conditions like this:
>
> :conditions => {:published => 1}
>
> -- then it fails to retrieve published articles.
>
> If I specify the conditions like this:
>
> :conditions => ['published = 1']
>
> -- then it fails to ignore unpublished articles.
>
> Why?!
>
>
> Thanks and regards,
> Andy
>
> -------
> AirBlade Software
> http://airbladesoftware.com
>
>
>
>
> _______________________________________________
> Chat mailing list
> Chat at lists.lrug.org
> http://lists.lrug.org/listinfo.cgi/chat-lrug.org
>
>
More information about the Chat
mailing list