Search API documentation

How frontend should use /api/v2/search API to retrieve documents.

REQUEST:

For now, search API is triggered by a simple GET with few query params :

RESPONSES:

Whatever the request is, the response has always the same schema :

{
    "total": 0,
    "messages_hits": {
        "total": 0,
        "messages": [
                     {
                        "id": "xxxxx",
                        "score": 3.374578,
                        "highlights": {
                            "a_field_name": ["a string", "another string"],
                            "another_field_name": ["string","string"]
                        },
                        "document": { // full message doc here }
                      },
                      { // another message }
        ]
    },
    "contact_hits": {
        "total": 0,
        "contacts": [
                      {
                        "id": "xxxx,
                        "score": 4.625036,
                        "highlights": {
                            "field_name": ["string"],
                            "another_field": ["string"]
                        },
                        "document": { // full contact doc here },
                      },
                        { // another contact }
        ]
    }
}

total fields always count how many docs have been found for the current search, whatever the actual number of docs are effectively returned.

messages and contacts arrays hold the documents matching the request. How many documents are in these arrays depends of the request context: - if no doctype param has been provided in the request, arrays contain the top 5 relevant documents for each type. - if doctype param has been provided in the request, one array is empty (the one that do not match the doctype requested), other one holds has many documents as limit param, or 10 by default. - documents are sorted by relevance.