earthquake-croatia icon indicating copy to clipboard operation
earthquake-croatia copied to clipboard

Search field

Open vlado opened this issue 4 years ago • 4 comments

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

  • PG full text search
  • Elasticsearch
  • Simple AND and/or OR in SQL :)
  • ...

vlado avatar Jan 03 '21 10:01 vlado

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 avatar Jan 03 '21 23:01 vfonic

@vfonic will take care of this

vlado avatar Jan 03 '21 23:01 vlado

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. 🤔

vfonic avatar Jan 03 '21 23:01 vfonic

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.

vlado avatar Jan 04 '21 00:01 vlado