Jump to content

Search file by name and content


Recommended Posts

I'm trying to configure a file filter workflow to search both in the filename and it's content. However I don't seen to be getting the correct results.

 

I have a markdown file named "stats - moments.md" with the string "=todo" inside it. When I search for either "stats" or "=todo", I got the expected results. However, when I search for "stats =todo" I don't get any results back. Is this the intended behaviour?

 

I've posted what I hope is a reproducible example on github with the search scope set to `~/afred-reprex`.

Link to comment

Hi @fjuniorr, welcome to the forum. Great description of your issue.

 

On 3/9/2019 at 11:33 PM, fjuniorr said:

Is this the intended behaviour?

 

Unfortunately, yes. From your screenshot:

 

Quote

Note that {query} values are OR'ed together, string constant values are AND'ed together.

 

6091bc5ec95dfd60581336fab38d71eb.png

 

 

 

 

Edited by deanishe
Link to comment

@deanishe @fjuniorr Ello! :)

 

By default, what's happening is that both words "stats" and "=todo" are being searched for in both fields; You don't get a result because both words aren't found in the title and both words aren't found in the content.

 

Here's a workflow that allows you to search by entering part of the title, then some content to return results.

 

Here's the download link:

https://www.dropbox.com/s/6yaqeg8koglpxae/Search File Name then Content.alfredworkflow?dl=0

 

Taking a look at this example, you would type the keyword "fname" followed by the file name, hit return then enter some of the content to see your results returned in-line.

 

You'll notice the Metadata fields are empty in the file filter; The JSON object is used to dynamically set these based on your input from the first keyword.

 

It's not possible to currently put variables into the File Filter's metadata fields, but that's something we're aware of and is on our list of considerations :) Let me know how you get on.

 

Cheers,
Vero

Link to comment

Thank you very much for this workflow!

 

The problem that still remains for my use case is that I don't know in advance where the words will appear (ie. it might be the case that both words only occur in the file content, instead of "stats" in the filename and "=todo" in the file content) and therefore can't use this type of dynamic filter.

 

But again, thanks for the help and attention.

 

Regards,

Link to comment
  • 1 year later...
On 3/15/2019 at 2:47 AM, Vero said:

@deanishe @fjuniorr Ello! :)

 

By default, what's happening is that both words "stats" and "=todo" are being searched for in both fields; You don't get a result because both words aren't found in the title and both words aren't found in the content.

 

Here's a workflow that allows you to search by entering part of the title, then some content to return results.

 

Here's the download link:

https://www.dropbox.com/s/6yaqeg8koglpxae/Search File Name then Content.alfredworkflow?dl=0

 

Taking a look at this example, you would type the keyword "fname" followed by the file name, hit return then enter some of the content to see your results returned in-line.

 

You'll notice the Metadata fields are empty in the file filter; The JSON object is used to dynamically set these based on your input from the first keyword.

 

It's not possible to currently put variables into the File Filter's metadata fields, but that's something we're aware of and is on our list of considerations :) Let me know how you get on.

 

Cheers,
Vero

There any solution for this function? First search the file, then search the file content.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...