ospfranco / sol

MacOS launcher & command palette
MIT License
1.92k stars 89 forks source link

File search #45

Closed g-cqd closed 1 year ago

g-cqd commented 2 years ago

Hi Oscar,

Are you planning to implement a file search in Sol ?

Would be great to have one, with something similar to the Google Dorks to make it more convenient to look for specific files.

It may be an easy feature or it may not but overall I can't work on that myself at the moment.

Best Regards Guillaume

ospfranco commented 2 years ago

Yeah, it's something that's been on my to-do for quite some time, I don't think it is easy to do it properly that's why I have been postponing it. I don't know how google docs works, care to provide some context?

g-cqd commented 2 years ago

Google dorks are used to make specific search faster on Google. For example, if you're looking for file, for a certain format, you can just type: whatever your search filetype:pdf

You can search for results only served by some website with site, and many other things like operators (OR, AND, ...) and a lot more.

See https://support.google.com/websearch/answer/2466433?visit_id=637924421885054793-2312646897&rd=1

chrismatheson commented 1 year ago

Would an acceptable interim/MVP implementation be to shell out to mdfind (for Mac, and I assume windows / linux have equivalents)

ospfranco commented 1 year ago

Doing shell commands is inefficient but it is a good idea to use the spotlight search. I tried used one of the native APIs but I'm having some issues

https://stackoverflow.com/questions/73431964/how-to-do-a-spotlight-search-in-swift-nsmetadataquery

ospfranco commented 1 year ago

I got it working, it executes a Spotlight search, which is very nice because I don't have to worry about the implementation details of a working search. On the other hand the qualifiers @aemi-dev wanted were not implemented. I will close this issue for now. I don't really have the time to implement a more advanced search, so if anyone wants something more advanced... well... donation is the way to go I guess.

chrismatheson commented 1 year ago

@ospfranco that was some super fast work there! :)

I have just upgraded to V1.1.52 via the auto-upgrader, but I don't believe native file search is working for me. Is there a special sub command to trigger it?

ospfranco commented 1 year ago

nope, I'm just calling the spotlight native APIs and sometimes spotlight returns no good file matches, not much I can do about that

chrismatheson commented 1 year ago

https://user-images.githubusercontent.com/420915/186101964-a3731fe4-92a2-4b06-8d31-f52fff531969.mov

This video shows the search term "rise" in spotlight and then sol. In my downloads folder I have a folder & movie which should match (see spotlight results a few down) but im not seeing them from sol.

with other terms I do get folder realists which I assume are from spotlight.

Have you got any advise how I could potentially go about debugging this and see if I can help improve things ? :)

ospfranco commented 1 year ago

Not really a bug, even though I'm using a Spotlight query, one doesn't get full access to the querying capabilities against the spotlight database. I basically do a simple string comparison to try to find matches:

https://github.com/ospfranco/sol/blob/main/macos/sol-macOS/lib/FileSearcher.swift#L51

Tbh, I don't use this feature, so if you need it PRs are welcome :)

chrismatheson commented 1 year ago

Thanks for the pointer :). ill see if I can figure out how to hack on this a bit.

Yeah it did feel like the NSMetadataQuery results are a bit ... unranked, compared to spotlight results. Ill have a little read around this area as well

g-cqd commented 1 year ago

Thanks Oscar for this feature, it's already nice to have it although there aren't the qualifiers yet.