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

NIP-50 search filter should work with multiple values #772

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

viktorvsk
Copy link
Contributor

In order to use search filter in the same way as kinds and authors it needs to accept array of strings. Those values will be used as AND conditions so that we could say that {"kind": 1, "search": ["without_tag:e", "followers_of:<pubkey>"]} we want to find root notes of our followers for instance.

…h AND condition in the same way `kinds` and `authors` are used
@arthurfranca
Copy link
Contributor

arthurfranca commented Sep 10, 2023

The NIP-50 search extension feels like an after thought. This is a mess: { search: "extension:1 look at this: full text search query extension:2" }. Edit: Nevermind, its ok.

So @viktorvsk I guess it should be {"kind": 1, "search": "without_tag:e followers_of:<pubkey>"}

@viktorvsk
Copy link
Contributor Author

So @viktorvsk I guess it should be {"kind": 1, "search": "without_tag:e followers_of:<pubkey>"}

why would we limit searches to non-space strings? Are there any disadvantages to using an array?

@arthurfranca
Copy link
Contributor

I think they got inspired by githubs is:open is:pr a free text example so relay should collect and remove the extensions first. The rest is free text with spaces allowed

@viktorvsk
Copy link
Contributor Author

So there is no way to filter {“search”:”fuzzy_search_tags:Cheshire Cat full_text_search:once upon a time”} using this NIP at the moment?

@fiatjaf
Copy link
Member

fiatjaf commented Sep 10, 2023

Search engines have all kinds of quirks that can be supported using just free text queries, I think we're fine relying on "whatever:something blabla OR blublu", no?

@staab
Copy link
Member

staab commented Sep 10, 2023

I personally have always found structured text queries to be extremely annoying because they are subject either to user-defined input (resulting in syntax errors or unexpected results) or complicated escaping. Structured data and user input should never be mixed. But maybe I'm wrong since that's contrary to established convention in full text search.

@viktorvsk
Copy link
Contributor Author

viktorvsk commented Sep 10, 2023

I want to implement some essential yet simple filters which are a must imo in order to access data efficiently. In my opinion they (most of them) should better be a part of NIP-1 but in order to not make it too complex I think of implementing them in context of NIP-50

Some examples are:

- Events without specific tag
- Events of friends (of friends) by pub key
- Fuzzy/fulltext search by content
- Events matching local/pet/nip5 name
- Exclude events by author, kind etc

And I don't see any sense to implement them as a single string because I see a lot of problems and zero profit. So I have 3 options:

  • customize nip1
  • customize nip50
  • create new nip

For now I tend use a slightly customized nip50 at least until I see an argument in favor of search arg to have a string value

@Semisol
Copy link
Collaborator

Semisol commented Sep 10, 2023

All conditions in a search are ANDed.
For OR conditions you can use multiple filters.
If you want more complex structuring like (a OR b) AND c you would need a proper spec for it. I would imagine something like this

  • a AND b: Both conditions must match
  • a OR b: Any condition may match
  • -a: Inverse of
  • (a): Resolving ambiguity in cases like a AND (b OR c)
  • "a phrase": Exact phrase match
  • word: Word match

You would also need to separate extensions like include:spam from conditions like say followers:>=50 and that gets hard.

I don't think there will be an easy spec

@viktorvsk
Copy link
Contributor Author

Yeah I'm talking exactly about AND filters. If say I want to find "all root notes of my friends which have text like something like 'I love nostr and bitcoin'"

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.

5 participants