Tinderbox Forum

Stuck on simple search

Here’s something that’s bugged me for years, and I don’t know if maybe I’m just missing something…

I don’t really know how to do a simple search in Tinderbox. Here’s an example:

I have a note in my file called “Vancouver eye doctors” (or maybe “eye doctors in vancouver”, I don’t know – which is the point). So I hit cmd-f to search for “vancouver doctors” and get… nothing.

Pretty much every search system I’m aware of will return that note, except for Tinderbox. Of course, they don’t have agents. But I admit that I’m not inclined to go, “Hrm, it didn’t find anything for ‘Vancouver doctors’, let me just knock out a quick agent…”

($Name.icontains('vancouver') & $Name.icontains('doctor')) | ($Text.icontains('vancouver') & $Text.icontains('doctor'))

There’s just a really big gap between command-f (which is fast, but highly specific in how it matches notes), and writing an agent to perform what appears to be a simple search.

Is there a slick search mechanism I’m totally missing? How do other people solve the problem of “quickly find me notes that have these two words in them” ?

2 Likes

Yes, that query works.

Queries are undoubtedly super powerful. My point is that I find it overly burdensome to construct a full query like that any time I want to search for a note that contains more than one word.

Is there no middle ground between the naive find that essentially works for one word searches, and a full-on query?

1 Like

Understood.

(Wrong answer deleted.)

Few searches (beside Google) will take the query

Vancouver doctors

and match

Eye doctors in Vancouver.

Failing this: BBEdit, Word, Pages, TextEdit, Tinderbox, Coda 2, Xcode, Panorama.
Passing: Google, mail.app

I believe the mail.app, when you search for “Vancouver doctors”, actually searches for the regular expression Vancouver|doctors. You can do that, too.

A few other passing ones: agenda, nvalt, devonthink

That will match any email that includes vancouver OR doctors - but the apps I use do an implicit and. To search for a specific string, you wrap it in quotes.

Will you please consider making command-f operate like mail, google, agenda, nvalt, devonthink?

As it is, to search for a note with two words in it, I have to create action code with four actions, three boolean operators, and two sets of parens. That doesn’t seem a bit excessive to anyone else?

Is everyone here really writing multi-part queries every time they want to find a note with more than one keyword in it?

2 Likes

it also matches “witch doctors” and “vancouver is a place”

I’m checking with the DEVONthink developer.

I’m wondering what happens in the Finder/Spotlight. I’d always assumed there was an implicit AND. I’ve just done a quick search in Finder, and if I search for “social” AND “identity” (quote marks around the words but not the operator) I get 591 hits, exactly the same as if I search for social identity (no quote marks, no operator). If I search for “social identity” (with quote marks) I get 183. But if I search for “social” OR “identity” I get no hits at all.

Spotlight is complex, and perhaps not a model to emulate.

This works:
(?=.*vancouver)(?=.*doctor)

Short term hack could involve text expander snippet, but it also seems reasonable to have search use this approach in general, perhaps with a toggle in find popup?

Here’s a textexpander Applescript snippet to wrap all query words with the regular expression syntax to allow searching for all of them in any order. Sequence to make it work is cmd-F in Tinderbox, then type ‘findwords’ (or whatever you rename the snippet) in the query box, then type words in textexpander fill-in, enter to replace query text, enter to search.

It’s a hack until this behavior could be made the default, which I am also in favor of.

-- Script to split string and wrap in regex to search for matches of all words in any order

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

--set theResponse to the text returned of (display dialog "query?" default answer "")
return split("%filltext:name=field 1%", space) as string

to split(someText, delimiter)
	set AppleScript's text item delimiters to delimiter
	set someText to someText's text items
	set AppleScript's text item delimiters to {""} --> restore delimiters to default value
	set someText to replaceItemInList(someText)
	return someText
end split

on replaceItemInList(theList)
	repeat with a from 1 to the count of theList
		set thisItem to item a of theList
		set thisItem to "(?=.*" & thisItem & ")"
		set item a of theList to thisItem
	end repeat
	return theList
end replaceItemInList

In full agreement with this. More passing ones: Scrivener, Workflowy, Zotero, Bookends…

How about an operator

words("doctor Vancouver")

which would return true for any note in which both “doctor” and “Vancouver” appear in either the $Name or the $Text? (I’d welcome better suggestions for the name of the operator.)

Mark, I’m curious about why this isn’t just the default search assumption. Are there use cases you’re thinking of here where simple search is best? I feel like I’ve been trained by the apps mentioned above to assume when I’m searching across multiple blobs of text (emails, documented, notes) that the search works as the operator search you describe above.

If I’m searching for “Mark Bernstein”, I typically don’t want to retrieve

Leonard Bernstein made his mark in 1943 when called on to replace an aging Bruno Walter.

This is of particular concern for agents, which you want to retrieve specifically the things you expect them to.

This is useful, I can see how that search wouldn’t work. I guess my perspective, and maybe Pat’s?, is that I have different expectations when doing a global search using cmd-f on the document vs. creating an agent. I want all that flexibility in the agent, but when doing a “quick” search, I’m ok with more “noisy” hits rather than fewer relevant hits.

My feelings are:

  1. words("doctor Vancouver") would be generally useful, and an improvement over the current state of things – the words should be order independent, and either it’s case-insensitive or there’s a corresponding iwords
  2. I think writing action code for a quick command-f is too high a burden for new users – but that’s not my primary concern here, so okay
  3. To search for the exact string “Mark Bernstein” I would propose "Mark Bernstein" – using quotes – as opposed to Mark Bernstein which matches `Leonard Bernstein made his mark…"

Anyway, for me personally, yes the words() action code gets the job done just fine! And can be used elsewhere in action code.

But this wouldn’t work in agents, where the search string is already in quotes. We could further separate search and agents, but that too has its costs.

Now that you have explained it, I fully understand why search works like it does in the cmd-f window. Not many other applications have as many ways to perform a search, so their search box are easier to code for a particular behaviour. However, as a data point, I had no idea that the window wasn’t assuming an AND or accepting quotes for phrases until @pat brought it up. For what it’s worth, some kludging to mimic the Google/DEVONthink etc methodology would be a plus in my view, although I obviously don’t know what that would entail under the hood.

Tinderbox - from a beginner’s standpoint (for over a year) - remains ‘trippy’ to me that this one singular issue of performing a simple search (as explored above) has really been such a hurdle to using Tinderbox effectively. It feels like such a peculiarity, a quirk, a kink, in not being able to do a quick search like I do in many other daily-used programs/applications. This one ‘feature’ I’m sure would assist adoption of Tinderbox more quickly for manifold others.

1 Like