Skip to content

Search for documents

POST /api/documentSearch

Search for existing Formbird documents

Arguments
  • your apiKey, for example: bf5b0500-9332-11e6-9c03-853f647fe4a4
  • from - indicates the number of initial results to skip, default is 0
  • pageSize - indicates the number of results that should be returned, default is 50
  • includeAllVersions - determines whether all versions are to be returned in results, default is false (ie. returns current version only)
  • filter - the elastic search query to search with
Example Request 1 - Using filter
curl http://localhost:3000/api/documentSearch \
 -H "apiKey: bf5b0500-9332-11e6-9c03-853f647fe4a4" \
 -d "filter={\"query\":{\"bool\":{\"must\":[{\"term\":{\"documentId\":\"dcfc63d0-9442-11e7-a6b2-d9cc8e84f3a6\"}}]}}}"

The above example request supplies a filter only. The default from and pageSize values are applied.

Example Response
{
    "statusCode": 200,
    "data": {
        "took": 98,
        "timed_out": false,
        "_shards": {
            "total": 5,
            "successful": 5,
            "failed": 0
        },
        "hits": {
            "total": 1,
            "max_score": 0,
            "hits": [{
                "_index": "fieldtec",
                "_type": "documents",
                "_id": "59b2097999628c19bccd80e9",
                "_score": 0,
                "_source": {
                    "systemHeader": {
                        "summaryName": "apiTest",
                        "keyIds": [],
                        "systemType": "document",
                        "excludeGeneralSearch": false,
                        "templateId": "547fe84c9c1d86680d9806bd",
                        "versionId": "de24de40-9442-11e7-a6b2-d9cc8e84f3a6",
                        "currentVersion": true,
                        "summaryDescription": "apiTest",
                        "createdBy": "548684a629a5e8d820b12c01",
                        "createdDate": "2017-09-08T03:07:37.380000+00:00",
                        "serverCreatedDate": "2017-09-08T03:07:37.380000+00:00",
                        "serverUpdatedDate": "2017-09-08T03:07:37.380000+00:00"
                    },
                    "text": "apiTest",
                    "documentId": "dcfc63d0-9442-11e7-a6b2-d9cc8e84f3a6"
                }
            }]
        }
    },
    "filter": false
}

The request returns an elastic search result containing the document(s) requested.

Example Request 2 - Using from and size
curl http://localhost:3000/api/documentSearch \
 -H "apiKey: bf5b0500-9332-11e6-9c03-853f647fe4a4" \
 -d "from=50&pageSize=50&filter={\"query\":{\"bool\":{\"must\":[{\"range\":{\"systemHeader.createdDate\":{\"gte\":\"2017-07-01T00:00:00.000\",\"lte\":\"2017-08-01T00:00:00.000\"}}},{\"term\":{\"appTags\":\"action\"}},{\"term\":{\"systemHeader.systemType\":\"document\"}}]}}}"

The above example request supplies a from, pageSize and filter. This request demonstrates how to return the next 50 documents, after skipping the first 50. Page through the results of a query by adjusting the from value in subsequent requests. The request returns an elastic search result containing the document(s) requested.

Example Request 3 - Using includeAllVersions
curl http://localhost:3000/api/documentSearch \
 -H "apiKey: bf5b0500-9332-11e6-9c03-853f647fe4a4" \
 -d "includeAllVersions=true&filter={\"query\":{\"bool\":{\"must\":[{\"term\":{\"documentId\":\"dcfc63d0-9442-11e7-a6b2-d9cc8e84f3a6\"}}]}},\"sort\":[{\"systemHeader.serverCreatedDate\":{\"order\":\"asc\"}}]}"

The above example request supplies an includeAllVersions, and filter. This request demonstrates how to return all versions of a document. The default from and pageSize values are applied. Include an elastic search sort within the filter parameter to order versions according to creation date. The request returns an elastic search result containing the document(s) requested.