Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search documents with blank content #484

Open
vanboom opened this issue May 12, 2022 · 1 comment
Open

Search documents with blank content #484

vanboom opened this issue May 12, 2022 · 1 comment

Comments

@vanboom
Copy link

vanboom commented May 12, 2022

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.

def create_or_update_pg_search_document
if !pg_search_document
create_pg_search_document(pg_search_document_attrs)
elsif should_update_pg_search_document?
pg_search_document.update(pg_search_document_attrs)
end
end

@vanboom
Copy link
Author

vanboom commented May 12, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant