Boolean Searches? (Specifically the NOT operator)

De
December
Posts: 58
Joined: Fri Jul 01, 2016 7:02 am
Platform: Mac

Wed Mar 06, 2019 2:40 am Post

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?

User avatar
AmberV
Posts: 24307
Joined: Sun Jun 18, 2006 4:30 am
Platform: Mac + Linux
Location: Ourense, Galiza
Contact:

Wed Mar 06, 2019 6:35 pm Post

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.

      1. In the search results sidebar, press ⌘A to Select All, and then ⌥⌘R to Reveal in Binder.
      2. Without touching anything that would alter the selection, search for the second keyword you wish to omit.
      3. Click on the magnifying glass icon next to the search term, and set both of the following options:

        • Search Binder Selection Only
        • Invert Results
  3. 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....

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.
.:.
Ioa Petra'ka
“Whole sight, or all the rest is desolation.” —John Fowles

De
December
Posts: 58
Joined: Fri Jul 01, 2016 7:02 am
Platform: Mac

Wed Mar 06, 2019 9:08 pm Post

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!

User avatar
AmberV
Posts: 24307
Joined: Sun Jun 18, 2006 4:30 am
Platform: Mac + Linux
Location: Ourense, Galiza
Contact:

Fri Mar 08, 2019 2:04 pm Post

Alas, a few key ingredients above are exclusive to version 3. :( 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.

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….


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.

…on the Don’t Rock the Boat Mid-Stream principle (or wait, wasn’t that Changing Horses? Never mind…).


Well, if the two horses are on the same boat…
.:.
Ioa Petra'ka
“Whole sight, or all the rest is desolation.” —John Fowles

De
December
Posts: 58
Joined: Fri Jul 01, 2016 7:02 am
Platform: Mac

Fri Mar 08, 2019 2:14 pm Post

... especially in projects where the Draft folder tends to get shuffled somewhere below Trash and forgotten.

Oh how well you know me...(*grin*)

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

Hahaha. That would definitely lead to some tippy moments!

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