-
Notifications
You must be signed in to change notification settings - Fork 3
Add support for filtering to queryNearest #23
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
base: main
Are you sure you want to change the base?
Add support for filtering to queryNearest #23
Conversation
…rting options. Update README to reflect new options for maxDistance and filtering logic. Modify API definitions and implementations to support must/should filter conditions and sorting intervals. Add tests for new filtering functionality in closest point queries.
package.json
Outdated
| "build:go": "cd src/s2-bindings && python build.py", | ||
| "build:esm": "tsc --project ./esm.json && echo '{\\n \"type\": \"module\"\\n}' > dist/esm/package.json", | ||
| "build:cjs": "tsc --project ./commonjs.json && echo '{\\n \"type\": \"commonjs\"\\n}' > dist/commonjs/package.json", | ||
| "build:esm": "tsc --project ./esm.json && echo -e '{\n \"type\": \"module\"\n}' > dist/esm/package.json", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is something weird I had to do to get Vercel to build my fork without erroring out.
The error message I was getting was:
✘ [ERROR] Syntax error "n"
../../node_modules/.pnpm/@convex-dev+geospatial@https+++codeload.github.com+mackinleysmith+geospatial+tar.gz+071ac5f5d_veafjjmfdyevjqqmh7gvbjmbv4/node_modules/@convex-dev/geospatial/dist/esm/package.json:1:2:
1 │ {\n "type": "module"\n}
╵ ^
✖ esbuild failed: Error: Build failed with 1 error:
../../node_modules/.pnpm/@convex-dev+geospatial@https+++codeload.github.com+mackinleysmith+geospatial+tar.gz+071ac5f5d_veafjjmfdyevjqqmh7gvbjmbv4/node_modules/@convex-dev/geospatial/dist/esm/package.json:1:2: ERROR: Syntax error "n"
Error: Command "cd ../../packages/backend && pnpm dlx convex deploy --cmd 'cd ../.. && turbo run build' --cmd-url-env-var-name NEXT_PUBLIC_CONVEX_URL --check-build-environment disable" exited with 1
I'm definitely open to reverting this before merging if it presents some unforeseen consequence -- I am by no means attached to it.
@ianmacartney what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oof... turns out that echo -e is not supported on macOS, so I'm updating this to use a node script for full cross platform support. Another option is to use printf, but that might lose compatibility with Windows.
I sure am shaving yaks today.
|
I’m planning to drop the cjs path and that statement entirely soon. Sorry
it bit you!
…On Thu, Nov 6, 2025 at 8:54 AM MacKinley Smith ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In package.json
<#23 (comment)>:
> @@ -23,8 +23,8 @@
"scripts": {
"build": "npm run build:esm && npm run build:cjs",
"build:go": "cd src/s2-bindings && python build.py",
- "build:esm": "tsc --project ./esm.json && echo '{\\n \"type\": \"module\"\\n}' > dist/esm/package.json",
- "build:cjs": "tsc --project ./commonjs.json && echo '{\\n \"type\": \"commonjs\"\\n}' > dist/commonjs/package.json",
+ "build:esm": "tsc --project ./esm.json && echo -e '{\n \"type\": \"module\"\n}' > dist/esm/package.json",
Oof... turns out that echo -e is not supported on macOS, so I'm updating
this to use a node script for full cross platform support. Another option
is to use printf, but that might lose compatibility with Windows.
I sure am shaving yaks today.
—
Reply to this email directly, view it on GitHub
<#23 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACZQW64KT5JNGJV4M4EOOL33N4NZAVCNFSM6AAAAACLHWDVKSVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZTIMRZGM3DANRTGU>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
This PR adds filtering support to the
queryNearestmethod, allowing users to filter results using the same filter builder API available inquery. This addresses the feature request in #17 and the discussion in the Discord thread.Changes
queryNearestsignature: The method now accepts an options object that can include bothmaxDistanceandfilterparameters, while maintaining backwards compatibility with the existing numericmaxDistanceparameter.query:eq()- equality filtersin()- value in a set filtersgte()/lt()- sort key range filtersnearestPointsquery to accept filtering conditions and sorting intervals, passing them through toClosestPointQuery.Example Usage
Benefits
querymethodmaxDistancecontinues to workTesting
mustandshouldfilter conditions inpointQuery.test.tsBy submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.