Copy Source | Copy HTML is_indexed :fields => [ 'title' ,"body"], : include => UltrasphinxHelpers::include_tags_configuration(self)
Copy Source | Copy HTML
- class Article
- belongs_to: user
- is_indexed: fields => ["name", "body", "user_id"],: include => UltrasphinxHelpers :: include_tags_configuration (self)
- end
- Ultrasphinx :: Search . new (: query => "ruby") # all entries that have the word "ruby" in the "name" or "body" field or the "ruby" tag will be found
Copy Source | Copy HTML
- Ultrasphinx :: Search . new (: query => "tag: ruby") # Displays only objects that are tagged with "ruby"
- Ultrasphinx :: Search . new (: query => "name: * sphinx") # We will search only by name, there is everything that contains in the name words with the suffix sphinx
Copy Source | Copy HTML
- friends_ids = current_user.friends.map (&: id) # [ 1 , 2 , 5 , 6 , 9 , 12 ]
- Ultrasphinx :: Search. new (: query => "* sphinx" ,: filters => {: user_id => friends_ids})
Source: https://habr.com/ru/post/54636/
All Articles