searching across databases

edit: nevermind, figured out how. get the root group of a database
It seems that the searching command for the DTPO application requires records to be selected. Does this preclude scripting searching across entire databases or across the entire DevonThink installation? I understand that when you query a database for its groups you get records in return(the groups), but is there a mechanism to get the databases as records also? Otherwise I feel that the searching API is a little bit limited.

Also, is there a document describing the Scripting API? Adobe has excellent ones for their programs. I feel that the applescript dictionary and the resulting header files are a little bit limited as far as comments.

Just to share, my eventual goal is to create a menu bar based application which permits searching DTPO. Am I reinventing the wheel here? I know about ammonite and have bought it but I don’t think that it really allows the depth of search permitted with the DTPO advanced search feature.

I am having problems with the search API. When I call it from applescript I can of course omit the properties, but calling it from Objective-C requires them, are there defaults that I can use? Because searching currently across the root group of a database is giving me rather few results back.

- (IBAction)search:(id)sender {
DevonThinkApplication *dtpo = [SBApplication applicationWithBundleIdentifier:@"com.devon-technologies.thinkpro2"];
DevonThinkDatabase *currentDB = [dtpo currentDatabase];
DevonThinkRecord *root_group =  [currentDB root];
NSArray *searchResults = [dtpo search:[_searchField stringValue] age:100000.00 comparison:DevonThinkLkcpFuzzy in:root_group label:0 locking:NO state:NO unread:NO within:DevonThinkLkwhAll];
 NSLog(@"%i", [searchResults count]);

Default values should be…

label: NSNotFound
locking/state/unread: NSMixedState
age: 0.0

Awesome, thanks