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

Implement nip50 fulltext searching #68

Merged
merged 8 commits into from
Jan 15, 2025
Merged

Implement nip50 fulltext searching #68

merged 8 commits into from
Jan 15, 2025

Conversation

jb55
Copy link
Contributor

@jb55 jb55 commented Jan 13, 2025

This adds support for nip50 fulltext searches. This allows you to use
the nostrdb query interface for executing fulltext searches instead of
the typical ndb_text_search api. The benefits of this include a
standardized query interface that also further filters on other fields
in the filter.

I've updated ndb, so you can test via:

Example query

Searching my notes from the local notedeck db with the text 'gm'

$ ndb -d ~/.local/share/notedeck/db query --until 1735401900 -a 32e1827635450ebb3c5a7d12c1f8e7b2b514439ac10a67eef3d9fd9c5c68e245 --limit 2 --search 'gm' | jq .content
"gm. what's everyone up to today."

jb55 added 6 commits January 13, 2025 19:48
We will be using this for our nip50 search support
This can be used to quicky pull the search string
from a filter
No functional changes, just formatting cleanups
Add a helper for sorting search words from largest to smallest. This
should help search performance. For example, let's say our search index
is like so:

"the pokemon is cool"

the
the
the
...
* 1000

Our root word search would have to start 1000 new recursive queries. By
sorting by the largest word:

pokemon
pokemon
pokemon
...
* 10

We only have to do 10 recursive searches, assuming larger words are less
common, which will likely be the case most of the time
Update fulltext search queries to include an optional filter. This can
be used to narrow down the fulltext search. This is another step towards
nip50 support in nostrdb.

I noticed the code was exiting dubiously in certain situations... so we
fix that as well. It's possible we were missing search results because
of this.
@jb55 jb55 changed the title nip50: add support for search field in filters Implement nip50 fulltext searching Jan 14, 2025
jb55 added 2 commits January 13, 2025 21:53
This adds support for nip50 fulltext searches. This allows you to use
the nostrdb query interface for executing fulltext searches instead of
the typical `ndb_text_search` api. The benefits of this include a
standardized query interface that also further filters on other fields
in the filter.

Changelog-Added: Add nip50 search filters and queries
@jb55 jb55 merged commit 7e36518 into master Jan 15, 2025
1 check passed
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