Skip to content

WIP/BUG: fix handling of numeric queries in search_regex#363

Draft
tangkong wants to merge 2 commits intopcdshub:masterfrom
tangkong:mnt_regex_numerics
Draft

WIP/BUG: fix handling of numeric queries in search_regex#363
tangkong wants to merge 2 commits intopcdshub:masterfrom
tangkong:mnt_regex_numerics

Conversation

@tangkong
Copy link
Contributor

@tangkong tangkong commented Jun 3, 2025

Description

Handle numeric queries in search_regex in an intuitive way, rather than by forcing normal text searches

Motivation and Context

#256

There's a few edge cases I still need to iron out here, but I wanted to throw this up for visibility. The approach I took here was to check if the provided search could be converted to a number, and if so try to perform numeric comparison.

This approach works if we have the entire document, but I don't have an analog for the mongodb backend. In the mongo case, we construct a query to pass to mongo itself, not knowing a-priori what fields are numeric and which aren't. This is a result of our very flexible schema.

Even after all this, we still fail to catch:

  • client.search_regex(some_field="2.0") into {... "some_field": "model 2.0 something"} should probably match

We could maybe get around this on the json database, since we can check that both the incoming document and the query are valid numbers, but there's no such strategy in mongo-land

How Has This Been Tested?

Some tests have been added, but also interactively

Where Has This Been Documented?

This PR

Pre-merge checklist

  • Code works interactively
  • Code contains descriptive docstrings, including context and API
  • New/changed functions and methods are covered in the test suite where possible
  • Test suite passes locally
  • Test suite passes on GitHub Actions
  • Ran docs/pre-release-notes.sh and created a pre-release documentation page
  • Pre-release docs include context, functional descriptions, and contributors as appropriate

@tangkong
Copy link
Contributor Author

tangkong commented Jun 3, 2025

test failures related to click, addressed in #362

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.

1 participant