pg_search icon indicating copy to clipboard operation
pg_search copied to clipboard

Search documents with blank content

Open vanboom opened this issue 3 years ago • 1 comments

It is possible for the user to reference an attribute or attributes for multisearchable that contains no data. If there is no data for the content of the pg_search_document, a record is created anyway.

Suggestion - it may be more efficient to not create a pg_search_document record when there is no searchable data to be stored.

https://github.com/Casecommons/pg_search/blob/d6064dc7a6b63c82ff8cd8d5d3b2860925f1b8cd/lib/pg_search/multisearchable.rb#L57-L63

vanboom avatar May 12 '22 18:05 vanboom

A work around exists using the if feature...

  multisearchable :against=>[:serial_number, :model_number], if: :has_multisearchable?

  def has_multisearchable?
      serial_number.present? or model_number.present?
  end

vanboom avatar May 12 '22 18:05 vanboom