I often need to search within a number of files which have multiple tags. E.g a file tagged with “Active” and “2019” and “Supplier”
With the “Tag View” in DV 2 it was easy to Ctrl Click multiple tags, and then in the resultant file list, use “Search in Selection” and easily find what I need.
I know “Tag View” is not in DV 3, but assume there is still a method of achieving the same end result?
Just playing around with this instead of working, but…
How about this to search for documents with three tags (tag1, tag2, tag3):
a) In the side bar, in Global Tags, click on the database name. This will show you all that database’s tags in the list view.
b) Edit > Find in Database (cmd-alt-f) and you’ll open the main database search screen.
c) Type tags: tag1, tag2, tag3 - ie with a comma between the tags.
With very quick testing, that seems to work. It’s not the same as DT2, but it has got some advantages, because you can use wildcards. You can save common search configurations as well.
In DV 2 there is a standard “View” called “As Tags”.
That switches the view where all the tags are listed alphabetically down the right hand side pane. Ctrl Click any selection of these will provide a quick search result - which can be further searched with “in selection”.
For me it is extremely quick, and very useful.
I can do the same creating a smart group each time, but that is much more work.
@Brookter - I tried your suggestion, but it does not work with my data. When I add a comma after the first tag, the number of results immediately shrinks, (no idea why), and shrinks again when adding another tag.
I also tried using AND and OR between the tags, but that does not work.
Isn’t that what you want? To find the documents with all three tags? If you want to all the documents with any of them, then try entering this in the search field.
any: tags:test1,test2,test3
This gives me:
I didn’t know the exact syntax, and instead used the Advanced Search (with the three drop down boxes which are the same you get in Smart Groups). Once you’ve done that, DT3 adds the correct syntax to the search field, so you can learn it…
BTW, I’m not defending the decision to remove the Tag View, just experimenting with a way round it for the time being. HTH.
As @Cassady has suggested, (1) click on the group you want to analysis on the sidebar, (2) click on this icon at the bottom of the sidebar.
Once you do that, you can choose multiple tags either by drilling down in the tag cloud, or by entering the tags in the tag filter that is located at the top of the view pane:
But after after playing it for a few minutes, I’m not sure how you get it to show documents with tag1 OR tag2 OR tag3, rather than AND? (You can select more than one in the tag cloud with cmd-click, but it doesn’t seem to move them into the filter bar.)
Item is Tagged just ensures only tagged files are returned. Since I’m looking for a required tag in the next criterion, it’s redundant but also not harmful (and to show another available criterion).
Also, if I removed the required Tag from this search, the Tag is not freeware would match untagged files as well. Likely not the results desired.
I would also love to have an OR functionality in the tag cloud. Building a new search such as the one you describe is cumbersome and time consuming. Since you can cmd-click multiple tags in the tag cloud, would it be possible to write an apple script that would build the search you described above, combining the tags that are already in the tag filter (in an AND search) with the tags that were selected using cmd-click (in an OR search)? I don’t know the applescript functions for working with the tags in the tag filter or to access the currently selected tags in the tag cloud.
I have the same question, an Applescript to search for document with “tags:#Actionable-Goal tags!=-Archive”
This works well within Devonthink, but fails in Applescript
I’m currently using Smart Groups as a work-around
This script creates an “OR” query for selected tags of window 1, then opens a new window and sets its query. It’s not what you are discussing here but might get you started.
-- Open new window with query set to selected tags of window 1
-- Note: Select tags in the item list, not in the navigation sidebar
tell application id "DNtp"
try
set theTags to name of selected records
if theTags = {} then error "Please select some tags"
set theQuery to "any: tags:" & my tid(theTags, ";")
set newWindow to open window for record root of current database
set search query of newWindow to theQuery
activate
on error error_message number error_number
if the error_number is not -128 then display alert "DEVONthink" message error_message as warning
return
end try
end tell
on tid(theList, theDelimiter)
set d to AppleScript's text item delimiters
set AppleScript's text item delimiters to theDelimiter
set theString to theList as text
set AppleScript's text item delimiters to d
return theString
end tid
I thought you were talking about UI searches. You can get the search results via search results of think window 1, however if you only want to use results in a script then there’s no need to open a new window:
-- Search with query built from selected tags of window 1
-- Note: Select tags in the item list, not in the navigation sidebar
tell application id "DNtp"
try
set theTags to name of selected records
if theTags = {} then error "Please select some tags"
set theQuery to "any: tags:" & my tid(theTags, ";")
set theResults to search theQuery in root of current database
on error error_message number error_number
if the error_number is not -128 then display alert "DEVONthink" message error_message as warning
return
end try
end tell
on tid(theList, theDelimiter)
set d to AppleScript's text item delimiters
set AppleScript's text item delimiters to theDelimiter
set theString to theList as text
set AppleScript's text item delimiters to d
return theString
end tid