Searching DEVONthink using DEVONagent

I’m trying to create a plugin for DEVONagent that will allow it to search DEVONthink Pro Office using its web server functionality.

So far, although my DTPO search for “philosophy” turns up a large number of links (many of them plain text files), DEVONagent only sees the entries which are web pages and have an originating URL. That is, I get 47 hits in DTPO, but only 4 hits in DEVONagent. Also, double-clicking on the hits that DA does see causes it to visit the original URL, not the copy in DTPO.

Here is my plugin:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>Name</key>
	<string>DEVONthink Pro Office</string>
	<key>Info</key>
	<string>DEVONthink Pro Office Plugin 1.0 ©2007 John Wiegley</string>
	<key>Description</key>
	<string>Searches your DEVONthink Pro Office.</string>
	<key>Version</key>
	<string>1.0</string>
	<key>Identifier</key>
	<string>com.johnwiegley.dtpo.plugin</string>
	<key>EngineUrl</key>
	<string>http://localhost:8080/search?q=_agentQuery_&amp;w=4&amp;o=0&amp;c=0&amp;start=_agentOffset_&amp;num=_agentNumber_</string>
	<key>EncodingUrl</key>
	<string>UTF-8</string>
	<key>Start</key>
	<integer>0</integer>
	<key>OffsetPerPage</key>
	<integer>100</integer>
	<key>ResultsPerPage</key>
	<integer>100</integer>
	<key>LinksStart</key>
	<string>&lt;ol start=</string>
	<key>LinksEnd</key>
	<string>&lt;/ol&gt;</string>
	<key>Keyword</key>
	<string>dtp</string>
</dict>
</plist>

Note that I’m guessing this has to do with the way that DTPO’s server outputs the href links:


<a href="rands.philosophy.txt?id=584021&action=view" set="yes">rands.<span class="markup">philosophy</span>.txt</a>

Since it’s a server-relative URL without an HTML extension, perhaps DA is ignoring it. But since it is browsable, shouldn’t there be a way to get DA to show it as a hit?

Getting this to work would be a great way to add my DEVONthink database to my typical “Fast Scan” search set, letting me search against whatever I have archived there, since I tend not to use the DEVONagent archive much.

Thank you,
John

There are several issues. First, use c=1 and w=0 in the URL (no case searching for the contents). Set OffsetPerPage and ResultsPerPage to 50. Finally, remove LinksEnd/LinksStart and add LinksMatching & Operators:


<key>LinksMatching</key>
<string>*&action=view*</string>
<key>Operators</key>
<integer>1</integer>

Unfortunately this does still not really work - DEVONagent skips the RTF/RTFD/PDF links. A future release of DA and/or DTPO will improve the compatibility.