Open vlado opened 3 years ago
I've used pg_search gem and it does magic. It uses its own db table (AR model) to manage the metadata that even allows for storing additional info and multiple records metadata so you can search across multiple models (think: Products, Events, Real-estate, what-have-you)
It's easy enough to setup and no additional services needed.
@vfonic will take care of this
Which db fields should the search cover? Everything? description, city, zip, address, category, kind, email and phone?
I think we could narrow this down to: description, city, address, category and kind
I'd say that when building search index, we probably shouldn't include kind, but will only filter by kind (Ad.where(kind: params[:kind]).search(params[:query])
), right?
Another issue is: what will happen when we lose city
column? It looks like we'll remove it in favor of belongs_to :city
relationship. đ€
Which db fields should the search cover? Everything? description, city, zip, address, category, kind, email and phone?
I think we could narrow this down to: description, city, address, category and kind
Email definitely not (we do not show it anyway). Not sure about phone, only valid reason to index it would be if someone wants to find his ad by phone (probably unlikely).
I'd say that when building search index, we probably shouldn't include kind, but will only filter by kind (
Ad.where(kind: params[:kind]).search(params[:query])
), right?
Maybe someone will enter smjeĆĄtaj osijek
without selecting kind. Is it a problem to have it in index?
Another issue is: what will happen when we lose
city
column? It looks like we'll remove it in favor ofbelongs_to :city
relationship. đ€
Maybe we can ask @mmorava to keep it in ads table then. We use City.all
to build select box but we save both city_id and city_name in the ads table. Maybe it also makes sense to save and index county also. Searching for smjeĆĄtaj virovitiÄko podravska
seems highly likely.
Let's collect ideas for a simplest search we could build.