Search API

This document describes the v2 Search API of Fess. For the common response envelope, error model, and CSRF, see API Overview.

The base URL is http://<Server Name>/api/v2/ (local environment example: http://localhost:8080/api/v2).

Fetching All Documents (Scroll Search / NDJSON)

Request

HTTP Method GET
Endpoint /api/v2/documents/all

Streams all documents matching the query as NDJSON (application/x-ndjson). Each line is a {"data":{...}} object containing fields permitted by QueryFieldConfig#isApiResponseField.

If a failure occurs mid-stream, the final line is flushed as follows:

{"error":{"code":"internal_error","message":"stream error"}}

Therefore, clients must check the first key of the last line to distinguish successful completion (data) from a server error (error).

The query is built using the same parameter set as GET /search (q, sort, num, lang, ex_q, sdh, fields.*, as.*, track_total_hits, facet.*, geo.*). If scroll search is disabled with api.search.scroll=false, the endpoint returns invalid_request (400).

Request Parameters

The parameters explicitly specified in the spec are as follows.

Request Parameters
q Search term.
sort Sort order.
num Page (scroll batch) size (integer, >=1). A value of <= 0 results in invalid_request.
lang Search language. Can be specified multiple times (array).
ex_q Additional query expression. Can be specified multiple times (array).
fields.label Filter by label name. Can be specified multiple times (array). Part of the general fields.<name> family (see GET /search).
sdh Similar-document hash.

Table: Request Parameters

Response

On success (200), the Content-Type is application/x-ndjson, with one document per line as shown below.

{"data":{"url":"https://example.com/","title":"Example"}}
{"data":{"url":"https://example.org/","title":"Example Org"}}

Error Response

For details on the error model, see API Overview. The HTTP statuses returned by this endpoint are as follows.

Error Response
Status Code Description
400 Bad Request Invalid query, num <= 0, or scroll search disabled with api.search.scroll=false.
405 Method Not Allowed The HTTP method is not allowed.
500 Internal Server Error An internal server error occurred.

Table: Error Response