Silversearch - Fulltext search for Silverbullet

I’ve been using SilverSearch for a while now and I have to say that it works beautifully - except for some of the “Some advanced tips” parts.

  • ext:png → 0 results, while I do have a lot of documents in .png format (searching for plain “png” returns all the places where they’re used) - maybe document names are not indexed somehow?
  • path:“some path” does not return anything, ever
  • -exclusions took me a while to understand that it must be written as -“words I want to exclude” and not -exclusions “words I want to exclude”

Could you @MrMugame help me out with these?

Thank you!

2 Likes

I updated it now, I hope this makes it a little clearer. It’s not in a new release yet.

The important part here is, that you always have to add some text to search for, so you can’t just get all files under a specific path, or all files with a specific extension. This is a restriction by the minisearch api, which has <insert long github comment> reasons. I could work around that, but it introduces some questions like “What would the sort order be?” and omnisearch doesn’t do it. If you really only want all files e.g. from a specific extension you could do ext:pdf pdf.

As for document names not being indexed: Right now a document for which Silversearch can’t retrieve content, will not be indexed. So if you want png files to be indexed you could do

event.listen {
    name = "silversearch:index",
    run = function (event) 
        local meta = event.data.meta
        if (meta.contentType != "image/png") then
             return
        end
        return { content = "" }
    end
}

Which will just return an empty string as the content for png files. I thought about making an option which would do this by default, would that be useful?

I guess it could be useful sometimes. Searching for documents is not something I do that often, but having their names indexed could be nice.