Skip to content

feat: support geohash prefix matching for #g filters#586

Open
kanishka0411 wants to merge 1 commit intocameri:mainfrom
kanishka0411:feat/geohash-prefix-filters
Open

feat: support geohash prefix matching for #g filters#586
kanishka0411 wants to merge 1 commit intocameri:mainfrom
kanishka0411:feat/geohash-prefix-filters

Conversation

@kanishka0411
Copy link
Copy Markdown
Contributor

Description

Adds support for geohash prefix matching for #g filters.
A query like { "#g": ["u4pruyd*"] } now matches events with geohash tags starting with u4pruyd, for example ["g", "u4pruydqqvj"].
Exact #g filters without * still behave the same as before, so u4pruyd does not match u4pruydqqvj.

Related Issue

Fixes #265

Motivation and Context

Geohash searches usually work with prefixes, especially when a client is looking for events inside a map area.
Before this, Nostream treated #g like any other generic tag filter and only did exact matching. That meant the wildcard form requested in #265, like u4pruyd*, did not match longer geohash values.
This updates both paths that need the behavior:

  • stored event queries use LIKE 'prefix%'
  • live/in-memory subscription matching uses startsWith

So historical results and live events stay consistent.

How Has This Been Tested?

Added unit tests for:

  • wildcard geohash prefix matching
  • exact #g matching without wildcard
  • generated SQL (LIKE 'prefix%' vs =)
  • in-memory event matching

All passing locally.

Screenshots (if appropriate):

Types of changes

  • Non-functional change (docs, style, minor refactor)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my code changes.
  • I added a changeset, or this is docs-only and I added an empty changeset.
  • All new and existing tests passed.

@coveralls
Copy link
Copy Markdown
Collaborator

coveralls commented Apr 27, 2026

Coverage Status

coverage: 64.097% (+0.08%) from 64.015% — kanishka0411:feat/geohash-prefix-filters into cameri:main

@kanishka0411 kanishka0411 force-pushed the feat/geohash-prefix-filters branch from 2846cd8 to b10b02b Compare April 27, 2026 13:43
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 27, 2026

🦋 Changeset detected

Latest commit: b10b02b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
nostream Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

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.

[REQUEST] search geohash tags by prefix

2 participants