src/elastic-connection.c
void elastic_connection_json(struct elastic_connection *conn, json_object *jobj)
{
    FUNC_START();
    struct json_object *jvalue = NULL;

    i_assert(jobj != NULL);

    /* Check for error description */
    if (json_object_object_get_ex(jobj, "error", &jvalue)) {
        i_error("fts_elastic: %s", json_object_get_string(jvalue));
        return;
    }

    /* Check if errors are present in response */
    if (json_object_object_get_ex(jobj, "errors", &jvalue)) {
        i_error("fts_elastic: errors in response");
    }

    /* Check if _scroll_id are present in response */
    if (json_object_object_get_ex(jobj, "_scroll_id", &jvalue)) {
        conn->ctx->scroll_id = p_strdup(conn->ctx->pool, json_object_get_string(jvalue));
    }

    switch (conn->post_type) {
    case ELASTIC_POST_TYPE_SEARCH:
        if (!json_object_object_get_ex(jobj, "hits", &jvalue)) {
            i_error("fts_elastic: no .hits in search response");
            break;
        }
        if (!json_object_object_get_ex(jvalue, "hits", &jvalue)) {
            i_error("fts_elastic: no .hits.hits in search response");
            break;
        }
        elastic_connection_search_hits(conn->ctx, jvalue);
        break;
    case ELASTIC_POST_TYPE_BULK:
    case ELASTIC_POST_TYPE_REFRESH:
    case ELASTIC_POST_TYPE_DELETE:
    case ELASTIC_POST_TYPE_DELETE_BY_QUERY:
        /* not implemented */
        break;
    }
    FUNC_END();
}
/* extract values from resulting json object */
extract values from resulting json object
extract values from resulting json object
void elastic_connection_json(struct elastic_connection *conn, json_object *jobj)
{
    FUNC_START();
    struct json_object *jvalue = NULL;
    i_assert(jobj != NULL);
    if (json_object_object_get_ex(jobj, "error", &jvalue)) {
        i_error("fts_elastic: %s", json_object_get_string(jvalue));
        return;
    }
    if (json_object_object_get_ex(jobj, "errors", &jvalue)) {
        i_error("fts_elastic: errors in response");
    }
    if (json_object_object_get_ex(jobj, "_scroll_id", &jvalue)) {
        conn->ctx->scroll_id = p_strdup(conn->ctx->pool, json_object_get_string(jvalue));
    }
    switch (conn->post_type) {
    case ELASTIC_POST_TYPE_SEARCH:
        if (!json_object_object_get_ex(jobj, "hits", &jvalue)) {
            i_error("fts_elastic: no .hits in search response");
            break;
        }
        if (!json_object_object_get_ex(jvalue, "hits", &jvalue)) {
            i_error("fts_elastic: no .hits.hits in search response");
            break;
        }
        elastic_connection_search_hits(conn->ctx, jvalue);
        break;
    case ELASTIC_POST_TYPE_BULK:
    case ELASTIC_POST_TYPE_REFRESH:
    case ELASTIC_POST_TYPE_DELETE:
    case ELASTIC_POST_TYPE_DELETE_BY_QUERY:
        break;
    }
    FUNC_END();
}
void elastic_connection_json ( struct elastic_connection * conn , json_object * jobj ) { FUNC_START ( ) ; struct json_object * jvalue = NULL ; i_assert ( jobj != NULL ) ; if ( json_object_object_get_ex ( jobj , " " , & jvalue ) ) { i_error ( " " , json_object_get_string ( jvalue ) ) ; return ; } if ( json_object_object_get_ex ( jobj , " " , & jvalue ) ) { i_error ( " " ) ; } if ( json_object_object_get_ex ( jobj , " " , & jvalue ) ) { conn -> ctx -> scroll_id = p_strdup ( conn -> ctx -> pool , json_object_get_string ( jvalue ) ) ; } switch ( conn -> post_type ) { case ELASTIC_POST_TYPE_SEARCH : if ( ! json_object_object_get_ex ( jobj , " " , & jvalue ) ) { i_error ( " " ) ; break ; } if ( ! json_object_object_get_ex ( jvalue , " " , & jvalue ) ) { i_error ( " " ) ; break ; } elastic_connection_search_hits ( conn -> ctx , jvalue ) ; break ; case ELASTIC_POST_TYPE_BULK : case ELASTIC_POST_TYPE_REFRESH : case ELASTIC_POST_TYPE_DELETE : case ELASTIC_POST_TYPE_DELETE_BY_QUERY : break ; } FUNC_END ( ) ; }
extract values from resulting json object
extract values from resulting json object
/* Check for error description */ /* Check if errors are present in response */ /* Check if _scroll_id are present in response */ /* not implemented */