Custom Filter Default to Searching Content?

Discussion related to "Everything" 1.5 Alpha.
Post Reply
theratchetorange
Posts: 4
Joined: Fri Feb 18, 2022 5:24 pm

Custom Filter Default to Searching Content?

Post by theratchetorange »

I've got a filter set up to search a path containing a knowledge base, and I've enabled Content Searching (which works wonderfully), but I'm curious if there's a way to negate the need to prepend "content:" every time I want to search the content AND the filenames.

Currently, I've got the following filter set up:

Name: Knowledge Base
Search: path:"KB Folder" content:
Keyboard Shortcut: Ctrl + K

Searching for: foo bar, for example, would only return results if "foo bar" was in the filename.

Searching for: content:foo bar, though, will return the results I'm looking for

What I'd like is for a filter that automatically takes the string provided and uses it to search both content and filename simultaneously and automatically, without manually typing "content:" first.

Is this something that's already possible?
void
Developer
Posts: 16897
Joined: Fri Oct 16, 2009 11:31 pm

Re: Custom Filter Default to Searching Content?

Post by void »

Please try creating a filter to search the filename or content:
  • In Everything, from the Search menu, click Add to filters....
  • Change the Name to:
    Filename or Content
  • Change the Search to:
    #replaceterms:#(:search:#):,#(:<#term:|content:#term:>#):
  • Change the Macro to:
    fc<search>
  • Click OK.
Filters can be activated from the Search menu, Filter bar (View -> Filters), right clicking the status bar, filter macro or filter keyboard shortcut.
theratchetorange
Posts: 4
Joined: Fri Feb 18, 2022 5:24 pm

Re: Custom Filter Default to Searching Content?

Post by theratchetorange »

Thanks for your reply!

The suggestion you provided worked wonderfully!

I wish I understood the query you provided; if you could take a moment to explain it, I'd really appreciate it.

Additionally, I'd like to filter out hidden files; when I put attrib:!H, it shows only hidden files, rather than excluding them.

Am I doing that wrong?

Thanks so much for such a great tool!
void
Developer
Posts: 16897
Joined: Fri Oct 16, 2009 11:31 pm

Re: Custom Filter Default to Searching Content?

Post by void »

#replaceterms:#(:search:#):,#(:<#term:|content:#term:>#):
This search uses the Everything Search Preprocessor.

The Search Preprocessor can be used to rewrite your searches.



A simple Search Preprocessor example:
#upper:abc
is replaced with:
ABC



Another simple example is:
#year:#today:
which is replaced with the current year.



When this filter is active, the text search: is replaced with the text from your search box.



#replaceterms: allows you to rewrite each term in your search.

For example, the search: ABC 123 is two terms because the space is converted to AND:
ABC AND 123

For example, the search: ABC | 123 is two terms because the | is converted to OR:
ABC OR 123

#(: and #): are used to escape any preprocessor characters in the parameters.

#replaceterms:<search,new-term-format> takes two parameters.
search is the current search.
new-term-format is the new term format, where you can use #term: to reference the old term
If I wanted to add a Z in front of both terms I could do the following:
#replaceterms:#(:ABC 123#):,#(:Z#term:#):
is replaced with:
ZABC Z123



An example of what our #replaceterms:#(:search:#):,#(:<#term:|content:#term:>#): does for the search ABC 123:
#replaceterms:#(:ABC 123#):,#(:<#term:|content:#term:>#):
The two terms ABC AND 123 are rewritten as:
ABC|content:ABC 123|content:123

#replaceterms:


Additionally, I'd like to filter out hidden files; when I put attrib:!H, it shows only hidden files, rather than excluding them.
Please try:
!attrib:h

The NOT operator (!) must go before the search function.

Please make sure you are indexing attributes for the best performance:
  • In Everything, from the Tools menu, click Options.
  • Click the Indexes tab on the left.
  • Check Index attributes.
  • Click OK.
Post Reply