4

Domino Data Service is a good thing but is it possible to search for documents by key. I didnt find anything in the api and the url parameters about it.

user2316219
  • 304
  • 1
  • 11

2 Answers2

3

I tried the above and the requests usually fail on the server timeout after 30 seconds. Calls to /api/data/documents won't serve the purpose with parameters like sortcolumn or keysexactmatch, therefore calls to
/api/data/collections should be used for these. Also, I don't think that arguments like sortcolumn would work on a document collection, because there isn't a column to be sorted in the first place, columns are in the views and not in documents, so view collection should be queried instead. That also mimics the behavior of getDocumentByKey method, which can't be called against document, but against the view. So instead:

http://HOSTNAME/DATABASE.nsf/api/data/documents?search=QUERY&searchmaxdocs=N

I would call

http://HOSTNAME/DATABASE.nsf/api/data/collections/name/viewname?search=QUERY&searchmaxdocs=N

and instead of

http://HOSTNAME/DATABASE.nsf/api/data/documents?sortcolumn=COLUMN&sortorder=ascending&keys=ROWVALUE&keysexactmatch=true

I would call:

http://HOSTNAME/DATABASE.nsf/api/data/collections/name/viewname?sortcolumn=COLUMN&sortorder=ascending&keys=ROWVALUE&keysexactmatch=true

where 'viewname' is the name of the view that is searched. That is much faster, which comes in handy when working with larger databases.

Tomas Antos
  • 284
  • 2
  • 6
2

You would do something like the following:

GET http://HOSTNAME/DATABASE.nsf/api/data/documents?search=QUERY&searchmaxdocs=N

N would be the total number of documents to return and QUERY would be your search phrase. The QUERY would be the same as doing a full text search.

For column lookups it should be something like this:

GET http://HOSTNAME/DATABASE.nsf/api/data/documents?sortcolumn=COLUMN&sortorder=ascending&keys=ROWVALUE&keysexactmatch=true

COLUMN would be the column name. ROWVALUE would be the key you are looking for.

There are further options for this. More details here.

http://infolib.lotus.com/resources/domino/8.5.3/doc/designer_up1/en_us/DominoDataService.html#migratingtowebsphereportalversion7.0

Simon O'Doherty
  • 9,259
  • 3
  • 26
  • 54
  • The parameters you describe in the second URI are not valid for that API - see: [Document collection](http://infolib.lotus.com/resources/domino/8.5.3/doc/designer_up1/en_us/DominoDataService.html#ddapi_ref_documentcollection): GET http://{host}/{database}/api/data/documents?{parameters} – orbanbalage Jul 21 '16 at 13:28
  • That post is from 3 years ago. DDS may have changed since. – Simon O'Doherty Jul 21 '16 at 13:29
  • I looked into this quite deeply and found that it hasn't changed: in the /documents API there's no view mentioned, so there's no notion of a column. Which column in whcih view woul it use ? – user2808054 Mar 05 '20 at 16:47
  • If you want to get a document's content, you have to access it by its UNID or I thinnk NoteId, you can't get it via a key in the view. If yo do that, you can only get the view columns back. It'd be a delight if you could get the whole doc via a view though, that would have saved me writing an agent to do just that – user2808054 Mar 05 '20 at 16:49