Casecommons / pg_search

pg_search builds ActiveRecord named scopes that take advantage of PostgreSQL’s full text search
http://www.casebook.net
MIT License
1.3k stars 368 forks source link

Complex , faceted search best practice/ guidelines? #320

Open Rubytastic2 opened 8 years ago

Rubytastic2 commented 8 years ago

What would be the best way to approach a search with multiple associated tables and multiple values?

@employees = Employee.with_career_level(1).with_degree(2)

This works flawless, but I need to pass multiple params towards .with_career_level and .with_degree Is there a way to pass multiple values?

Rubytastic2 commented 8 years ago

What would be the correct syntax for something like:

      @employees = Employee.with_career_level(1)
                           .with_degree([1,2])

Passing multiple values somehow?

Also this fails ( logical)

      @employees = Employee.with_career_level(1)
                           .with_degree(1)
                           .with_degree(2)
Rubytastic2 commented 8 years ago

Nobody knows? Passing single var works fine but no way to add multiple values ?

An rails array would have been logic but this fails.

Rubytastic2 commented 8 years ago

Would i need name Matching? In Passing mosty arrays of ids bit some text also Seems the onmy reference in the docs on how to search against multiple values? Would this support ids also in array like 1,3,4,5,8 ?

class Animal < ActiveRecord::Base include PgSearch pg_search_scope :with_name_matching, :against => :name, :using => { :tsearch => {:negation => true} } end

one_fish = Animal.create(:name => "one fish") two_fish = Animal.create(:name => "two fish") red_fish = Animal.create(:name => "red fish") blue_fish = Animal.create(:name => "blue fish")

Animal.with_name_matching("fish !red !blue") # => [one_fish, t

Rubytastic2 commented 8 years ago

Is there also a with_id_matching?