-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
Description
The guest model currently uses a text column that contains a copy of attributes used in search.
Lines 21 to 32 in f54980c
| # Save searchable information | |
| before(:save) do |m| | |
| guest_model = m.as(Guest) | |
| guest_model.email = guest_model.email.downcase | |
| searchable_string = guest_model.email | |
| searchable_string += " #{guest_model.name}" if guest_model.name_column.defined? | |
| searchable_string += " #{guest_model.preferred_name}" if guest_model.preferred_name_column.defined? | |
| searchable_string += " #{guest_model.organisation}" if guest_model.organisation_column.defined? | |
| searchable_string += " #{guest_model.phone}" if guest_model.phone_column.defined? | |
| searchable_string += " #{guest_model.id}" if guest_model.id_column.defined? | |
| guest_model.searchable = searchable_string.downcase | |
| end |
Queries are then performed with a LIKE operator, with growing complexity (#104).
To improve control over search behaviour, it may be worthwhile switching to using a tsvector and tsquery. This can then be managed with an update trigger (and possibly a GIN index, depending on perf requirements).
Alternatively, moving this to elasticsearch may also be an option worth considering (at the expense of another service dependency, but providing conformity with other platform services).
caspianocaspiano