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

"Mention" search on partial name #162

Open
KyleMaas opened this issue Feb 3, 2021 · 8 comments
Open

"Mention" search on partial name #162

KyleMaas opened this issue Feb 3, 2021 · 8 comments

Comments

@KyleMaas
Copy link

KyleMaas commented Feb 3, 2021

Tangentially related to #161, I have not been able to find a way to do a search on the name of a mention. mentions looks like it's only intended to search on IDs. For the purposes of ssb-meme, I'd like to be able to search for "ima" and get mentions of blobs which were named "image.png", "Imagine.jpg", etc. Doesn't need to be a full text search, but even just a search on the first bytes would be nice, case insensitive and ideally at less than 32 bits so that three characters like "ima" would work.

@KyleMaas
Copy link
Author

KyleMaas commented Feb 3, 2021

[T]he feature I was looking for would have been for the Markdown editors we're use in ssb-browser-demo, which allow users to type "@" and have a list of user suggestions pop up which get winnowed down as you type. I was hoping to do the same thing with "&", per @arj03's feature request arj03/ssb-browser-demo#124 and I got it working in arj03/ssb-browser-demo#162 using a port of ssb-meme to db2 here: https://github.com/ssbc/ssb-meme

But it's...kludgy. I ended up having to pull the most recent posts and run them through ssb-meme's mention search. It would have been much nicer if I could do a prefix search for mention names.

From #161 (comment)

@staltz
Copy link
Member

staltz commented Feb 3, 2021

Have you tried the full-mentions plugin? It's roughly documented in the readme. Because it's a leveldb index, it should be possible to search for all entries that share a common prefix, using leveldb's gte/lte range scans.

@KyleMaas
Copy link
Author

KyleMaas commented Feb 3, 2021

I looked at it, but didn't find enough documentation to feel comfortable using it. It looked like it was documented as an example of how to implement an operator rather than something you could actually confidently use without it being deprecated or radically changed over new versions.

@KyleMaas
Copy link
Author

KyleMaas commented Feb 3, 2021

Okay, so I just tried fullMentions. As it currently operates, it seems to run on an exact match system, and only on certain things. So, for example, if I do fullMentions('@6CAxOI3f+LUOVrbAl0IemqiS7ATpQvr9Mdw9LC4+Uv0=.ed25519') I get matches but if I do fullMentions('@6ca') I get nothing. If I do a search for a full blob ID, I get nothing. If I do a search for a full blob name that I know is in the database, I get nothing.

@KyleMaas
Copy link
Author

KyleMaas commented Feb 3, 2021

For that matter, if I run SSB.db.getIndex("fullMentions").getMessagesByMention('@6CAxOI3f+LUOVrbAl0IemqiS7ATpQvr9Mdw9LC4+Uv0=.ed25519', false, (err, msgs) => { console.log(msgs) })

I get messages. If I run SSB.db.getIndex("fullMentions").getMessagesByMention('@6CA', false, (err, msgs) => { console.log(msgs) })

I get nothing.

@KyleMaas
Copy link
Author

KyleMaas commented Feb 3, 2021

Okay, so here's why it doesn't find blobs - they're ignored for indexing:

https://github.com/ssb-ngi-pointer/ssb-db2/blob/a75f2e4fbb72009dd908aa24b3692fa17df98e2f/indexes/full-mentions.js#L54

@staltz
Copy link
Member

staltz commented Feb 3, 2021

Check the implementation at indexes/full-mentions. It exposes a method getMessagesByMention. We could easily make another method that does a partial match, and then another operator to accompany that new method.

@KyleMaas
Copy link
Author

KyleMaas commented Jul 7, 2021

Any possibility of:

  1. Extending this to blobs, and
  2. Allowing search by name?

Currently the index only allows search by ID, and then searching can only be done by full ID.

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

No branches or pull requests

2 participants