vlado / earthquake-croatia

Code for app hosted on https://www.potres-petrinja.hr/ used for helping people in need during the earthquake crisis in Croatia
15 stars 13 forks source link

Search field #94

Open vlado opened 3 years ago

vlado commented 3 years ago

Let's collect ideas for a simplest search we could build.

vfonic commented 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.

vlado commented 3 years ago

@vfonic will take care of this

vfonic commented 3 years ago

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. đŸ€”

vlado commented 3 years ago

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 of belongs_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.