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

Searchkick: Fix Sample metadata indexing part 2 #871

Merged
merged 1 commit into from
Dec 17, 2024

Conversation

ericenns
Copy link
Member

@ericenns ericenns commented Dec 17, 2024

What does this PR do and why?

Describe in detail what your merge request does and why.

Update string_template template to exclude metadata.
Update metadata_non_dates template to use keyword instead of text so that string comparison where conditions can be used.
Update db/seeds.rb to disable Searchkick callbacks when adding data.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other pull requests.

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. Reset the database.
  2. Open a rails console and verify that the following searches produce results.
Sample.search("*", where: { "metadata.earliest_date": { lte: 1.day.ago } }).first
Sample.search("*", where: { "metadata.food": { like: "%Tofu%" } }).first
Sample.search("*", where: { "metadata.food": "Pierogi" }).first
Sample.search("*", where: { "metadata.age.numeric": { "gte": 10, "lte": 11 } }).pluck("metadata").map{|x| x["age"]}

PR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

…and fix dynamic templates for metadata so that text is searchable
@ericenns ericenns self-assigned this Dec 17, 2024
Copy link

Code Metrics Report

Coverage Test Execution Time
92.6% 10m16s

Code coverage of files in pull request scope (94.3%)

Files Coverage
app/models/sample.rb 94.3%

Reported by octocov

Copy link
Contributor

@ksierks ksierks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Queries work as expected.
I was just wondering if we need to handle case insensitivity? I remember the metadata needed to be all lower case. I can find "Tofu" and "Perogi", but not "tofu" and "perogi". Will we lower case the user inputs in a future PR?
Thanks!

Copy link
Collaborator

@ChrisHuynh333 ChrisHuynh333 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me!

@ChrisHuynh333 ChrisHuynh333 merged commit f5fba11 into main Dec 17, 2024
4 checks passed
@ChrisHuynh333 ChrisHuynh333 deleted the searchkick/metadata-field-mappings branch December 17, 2024 18:37
@ksierks ksierks mentioned this pull request Jan 9, 2025
1 task
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

Successfully merging this pull request may close these issues.

3 participants