Help with "simple" Smart-Group selection

Hello all,

I’m actually embarrassed about popping up this question – it’s something that should be so simple, but I am having endless trouble trying to get it right.

It once again confirms how much I still have to learn about ‘simple’ programming concepts – since (in my head) a ‘search-pattern’ sometimes ends up feeling like I’m trying to programme something… :unamused:

All I want, is a smart group that will watch my DB, looking for:

1.) EITHER plain text or RTF files
2.) That contain EITHER “Term A” or “Term B”
OR
3.) Are tagged with “Tag A” or Tag B"

My Search pattern is as follows:


1 [ANY] of the following are true
2         [KIND] [is] [Plain Text]
3         [ANY] of the following are true
4                 [CONTENT] matches [Term A   Term B]
5                 [TAG] is [Tag A]
6                 [TAG] is [Tag B]
7         [KIND] [is] [Rich Text]
8         [ANY] of the following are true
9                 [CONTENT] matches [Term A   Term B]
10               [TAG] is [Tag A]
11               [TAG] is [Tag B]

With the above set, the following files are pulled into the Smart Folder:

a.) Doc AND Docx files –– which I would dearly like to EXCLUDE from the above, but since they are presumably deemed Plain/Rich Text files, I’m struggling to work out how to do that.

b.) PDF + Text files. :open_mouth:

c.) 2700 odd RTF files that are inside my DB ℅ the “Import from Bookends” feature.

Some random other files, including Scrivener files.

Obviously the search function is not running in the same manner I envisaged.
I’m clearly lacking some quality [facepalm] moments – so would appreciate some clarification on what I am fundamentally misunderstanding about the search-pattern >> no doubt falling apart where I start nesting things… :blush:

Lastly – for what I need, should I avoid the smart-group all together, and rather work off a saved advanced search run, which can be saved as a smart group as well?

This one should do what you want.


I suspect where you got tripped up was nesting the search term ‘term1 OR term2’. As this criterion is common to all documents, it should not be nested as a compound predicate. Once you have the common-to-all-documents search term(s) at the top level, the necessary syntax to nest the compound predicates becomes easier to visualize. Note that ‘becomes easier’ is not the same as simple. I really would like to see an easier way to build compound searchers in a future release of DEVONthink.

Greg – appreciate the time/effort put into your reply – will roll and it out, and see what I can manage to get right!

I don’t know nearly enough about this kind of thing to be able to make suggestions – but if there is an easier way for the DTPO people to roll something out, that would obviously be appreciated.

Interestingly, the more complex/longer my search-pattern became, the closer it came to what I needed, but without it ever being perfect. I accordingly presumed I must be doing something wrong, since I figured it couldn’t possibly be so cumbersome… Guess it might just be! :slight_smile:

Thanks for the explanation – some useful tips there about what to start with.

Tried it out now – the hit’s have now dropped down from thousands to ‘only’ 254.

It still contains the Word/docx documents (that I will work out how to exclude next) – but, less understandably, it also throws in PDF+Text [OCR’ed] documents?? That’s what I don’t get.

EDIT: Getting closer! :smiley:

The “ALL” at the top means that ANY file that contains “Term 1” OR “Term 2” will be spotted, since it presumably runs that 1st. Only thereafter, does it filter down to check if RTF/Plain text… At least, that’s how I think its working.

It explains why the PDFs are being included – they contain Term 1 OR Term 2 in their content.

Changing [ALL] to [ANY] drops the PDFs, docx/Word files – AND it appears, the Plain Text files… I’ll play around some more – at least I feel like I’m getting somewhere.

Thanks again.

Edit AGAIN:

At the risk of having a conversation with myself, this appears to have done the trick!
Greg put me on the right path to getting my head around things! 8)


1 [ALL] of the following are true
2     [ANY] of the following are true
3             [ALL] of the following are true
4                    [KIND] is [Plain Text]
5                             [ANY] of the following are true
6                                     [CONTENT] matches [T1 OR T2]
7                                     [TAG] is [TagA]
8                                     [TAG] is [TagB] 
9                    [KIND] is [Rich Text]
10                           [ANY] of the following are true
11                                  [CONTENT] matches [T1 OR T2]
12                                  [TAG] is [TagA]
13                                  [TAG] is [TagB]

Maybe putting the steps down (as above) will help someone else somewhere down the line!

And if any of you other gurus know of an even simpler/more direct approach, please share!

The ‘All’ plus ‘Any’ at the same level means both-that is the smart group will find all documents that meet 'All" plus a minimum of one of the ‘Any’ search terms. I’ve tested the smart group that I posted, and you should not be getting any PDF documents. Check your smart group to ensure you have the same levels of indents as the one I posted.

The Word docs probably cannot be excluded without including additional terms in the search as they are considered rich text. Do you have your documents set to show the extension? If so, you could exclude documents containing .doc(x) in the document name as a search term.

Posted while you were posted the second edit

I’ve gotten in the habit of using the full Search window (Tools > Search) to create smart groups, instead of the smart group editor.

For the text query terms (if any) I use the query field of the Search window. It’s easy to see and set additional filters, including Label and so forth in the available options (reducing the need to write out such predicates in the smart group editor). Once in a while I want to do a search employing Fuzzy treatment of text terms.

I then supplement those criteria using the Advanced button.

When I’m satisfied with the search results, I can click on the “+” button to the right of the query field and Name and save the new smart group.

Excellent hint, Bill ! I have used the search window a zillion times, and never appreciated that little “+” button. Maybe it should be called “save” instead of “+” (I guess that’s what the tool tip is for). Using the search window is a great way of developing somewhat more complicated criteria for a smart group.

Setting the search criteria in the smart group editor is pretty straightforward, until one needs to construct more advanced searches, e.g. searching for more than one Label. It’s when the user needs to create compound predicates, even with the advanced button of the search window, that the process become tedious and often confusing.