Boolean Searches? (Specifically the NOT operator)

Had a quick look for existing threads on this topic, but they seem to be extremely old (2006 eg), so posting the question afresh. Apologies if I’ve overlooked something recent!

I’m looking for a way to do a keyword searches that delivers “Keyword1” AND NOT “Keyword2”. For my workflow (and surely that of many other people?) this is a non-trivial desideratum. For example, I have my notes tagged by topic, Within those topics, some have additional tags (eg to mark them as Major Notes, or pertaining to a particular sub-topic); obviously I can search for those tags too. But sometimes I need the notes that are NOT major, or do NOT belong to a particular sub-topic — and I can’t figure out a straightforward way of pulling them up, Yes, I could instead mark them as Non-major/ assign them to a 'General ’ sub-topic etc. But I didn’t think of that at the outset. To do it now, I’d need some way of rounding them all up — circularity!! Is there some clever run-round I haven’t thought of?

Scrivener has no native support for defining Booleans within a query, just as a function of the overall search. So for more complex searches, you need to use a multi-stage approach instead—and that has improved a bit over the years. The basics go like this:

  1. You run your first search, the one you want to subtract from. That gives you a search result list to work from.
  2. Second, there are two options:
  • If the type of thing you wish to subtract is supported by the corkboard/outliner filter feature (just hit ⌘F like you would search for text), then you click the “hook” button to load the search results into the editor and filter it further. Sorting by columns is also a possibility for narrowing things down—not in that it filters the result, but you can isolate the cluster of items more easily if they are grouped together.
  • If the thing you need to filter by cannot be done with that tool (and keywords cannot be), then the goal is to use project search again, but this time using the previous search result as the basis, instead of the entire binder.

[list=1][*] In the search results sidebar, press ⌘A to Select All, and then ⌥⌘R to Reveal in Binder.

  • Without touching anything that would alter the selection, search for the second keyword you wish to omit.
  • Click on the magnifying glass icon next to the search term, and set both of the following options:

[list][*] Search Binder Selection Only

  • Invert Results

[] After having done either, you may want to preserve the list of results for a time: select all of the search results and then use the Documents ▸ Add to Collection ▸ New Collection….[/:m][/list:o]

And as you can imagine, these methods can be repeated, for more complex three-way results, or even to combine two different result lists together (via a collection), and then whittle down from there.

Thank you for this very thorough reply! Invert Results is exactly what I’m looking for (ie a ‘not’ operator).

I’m guessing this is a new feature in Scrivener v.3? Alas still conservatively clinging to v.2 until my current project is done with, on the Don’t Rock the Boat Mid-Stream principle (or wait, wasn’t that Changing Horses? Never mind…). But delighted to know that this useful feature awaits me. Is the same true of your suggestions re filtering Outliner results? Doesn’t seem to match what happens for me in v.2…

Sorting is a very shrewd suggestion. As you say, won’t work for keywords, but will keep in in mind for other purposes.

Wondering now whether I could get somewhere with the include/exclude feature. At the moment, compiling lies way in my future, so could assign this status at will for now, if that were easy…

Thanks again so much for the advice!

Alas, a few key ingredients above are exclusive to version 3. :frowning: You will still find the binder selection option, so multi-staging is possible (as well as the ever-useful sorting), but it is difficult to do negations effectively.

Filtering the corkboard or outliner is also a new thing. You can search by visible text in these views, or do a deeper search into main text and notes. There are also metadata and other filtering options. It solves a lot of Boolean style problems without having to resort to more advanced project search technique. Definitely something to look forward to, if you work with a lot of metadata.

I would misuse that setting as well, especially in projects where the Draft folder tends to get shuffled somewhere below Trash and forgotten. It’s a very handy axis given its special placement in a number of different tools.

That’s another thing to look forward to in v3 as well: you can make your own checkboxes (as well as lists, dates and of course text), and they can be used in said view filters and project search, too. They can even be used to dictate what compiles.

Well, if the two horses are on the same boat…

Oh how well you know me…(grin)

Hahaha. That would definitely lead to some tippy moments!

Thank you for brightening my morning. I love these boards.