sol icon indicating copy to clipboard operation
sol copied to clipboard

Searching Through Files

Open g-cqd opened this issue 3 years ago • 2 comments

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

g-cqd avatar Jun 22 '22 06:06 g-cqd

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?

ospfranco avatar Jun 22 '22 08:06 ospfranco

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

g-cqd avatar Jul 03 '22 10:07 g-cqd

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

chrismatheson avatar Aug 20 '22 21:08 chrismatheson

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 avatar Aug 21 '22 07:08 ospfranco

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.

ospfranco avatar Aug 21 '22 12:08 ospfranco

@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?

chrismatheson avatar Aug 22 '22 07:08 chrismatheson

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

ospfranco avatar Aug 22 '22 08:08 ospfranco

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 ? :)

chrismatheson avatar Aug 23 '22 07:08 chrismatheson

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 :)

ospfranco avatar Aug 23 '22 08:08 ospfranco

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

chrismatheson avatar Aug 23 '22 08:08 chrismatheson

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

g-cqd avatar Aug 23 '22 11:08 g-cqd