11175
(-- --)
September 16, 2008, 8:52pm
1
I am having trouble getting the Ultrasphinx plug-in to filter search
results using the :filters parameter; searches that use the :query
parameter, however, work just fine. Every time I run a search using the
:filters parameter I receive the following error:
Ultrasphinx::UsageError:field "xxx" is invalid
Here is how my model is configured:
class Product
is_indexed :fields => [ "code" ]
end
And here is an example search that fails with the above exception:
search = Ultrasphinx::Search.new(:filters => {:code => "test"})
search.run
And an example of a search that works just fine:
search = Ultrasphinx::Search.new(:query => "code:test")
search.run
I must be missing something simple. Any help would be greatly
appreciated. Thanks in advance.
Regards,
Jason
11175
(-- --)
January 14, 2009, 4:56pm
2
It's been a while, but, I believe I discovered that :filters are only
applicable to association FK columns.
11175
(-- --)
January 22, 2009, 8:51am
3
I had an advice from the Ultrasphinx official forum to try with aliasing
the topic_id as an unique id name. So I tried this configuration:
is_indexed :fields => ['title','description','created_at',
{:field => 'topic_id', :as => 'video_topic_id'}],
:delta => {:field => 'created_at'}
(topic_id is an integer column that is part of Video model)
After that running: rake ulrasphinx:configure; rake ultrasphinx:index;
However the same error occurs:
Mrknife
(Mrknife)
February 10, 2009, 9:14pm
4
I was able to get a 'filter' to work...
basically I used the :concatenate option
is_indexed :fields => ['title','description','created_at'],
:concatenate => [ {:fields => ['topic_id'], :as
=> 'video_topic_id'} ],
:delta => {:field => 'created_at'}
Then I was able to run this.
Ultrasphinx::Search.new(:query => "london video_topic_id:
17", :class_names => "Video")
This is in no way ideal...
But I did manage to return the result set I wanted.