Note
This feature is experimental. It may change incompatibly or be removed in a future release (see Experimental Features). If you notice any issue, please let us know on the forum or elsewhere.
This document describes the v2 Similar Documents API of Fess, which lists the documents that have the same content as a given document. For the common response envelope and error model, see API Overview.
The base URL is http://<Server Name>/api/v2/ (local environment example: http://localhost:8080/api/v2).
Note
This API finds copies and near-identical documents. It does not find documents that are merely on the same topic (see “Which Documents Are Returned” below).
Listing Similar Documents
Request
| HTTP Method | GET |
| Endpoint | /api/v2/documents/{docId}/similar |
Returns the documents that have the same content signature as the document docId, so that a client can offer a “similar documents” link next to a hit.
The API is disabled by default. To use it, set
api.search.similar=trueinfess_config.propertiesand restart Fess. While it is disabled, it answersinvalid_request(400).features.similar_documentsof/api/v2/ui/configtells whether it is enabled.The same role filter, virtual host filter and additional query as
/api/v2/searchapply to the given document and to the returned documents. A document that does not exist and a document the caller cannot see both returnnot_found(404). The given document, and any other document with the same URL, is never returned.With
login.required=true, an anonymous caller getsauth_required(401). An access token can be used the same way as with/api/v2/search.Requests are limited to
api.search.similar.rate.limit.per.minute(default:30;0means unlimited) per minute, counted per logged-in user, or per client IP for a guest. Over the limit the endpoint answers429with aRetry-Afterheader.Only one page is returned, ordered by URL and then document ID. There is no
startor offset parameter.A request for which no virtual host is determined (the default host) gets no virtual host filter, so documents that have a virtual host value are also covered (the same as
/api/v2/search). Restrict documents that the users of the default host must not see by role.When the content of a document changes and it is crawled again, its
doc_idchanges. A saveddoc_idmay becomenot_found(404) after the re-crawl.
Which Documents Are Returned
Fess computes a content signature (content_minhash_bits) for each document when it is indexed. The API returns the documents whose signature is the same as that of the given document. It is the grouping used by the duplicate report (Document Report), the sdh search parameter and the similar_docs_* fields, but it works without result collapsing.
The documents are copies or have almost the same content. A document whose content was edited enough to change the signature is not returned, so this is not a search for documents on a similar topic.
datais an empty array (not an error) when the given document has no content or no word, and when the search engine runs without the CodeLibs plugins (search_engine.typeofvanilla,awsor the deprecatedcloud; see Search Engine Type).
Request Parameters
| Parameter | Description |
|---|---|
docId | Document identifier (path, required, pattern [A-Za-z0-9_-]{1,512}). A value that does not match produces invalid_request (400). |
num | Number of documents to return (query). The rules are those of num in Search API: the default is 10 (paging.search.page.size is not used). A value above paging.search.page.max.size is reduced to it, and page_size in the response shows the result. A value of 0 or less produces invalid_request (400). A value that is not an integer is ignored and the default is used. |
Table: Request Parameters
Response
On success (200), the following fields are returned directly under response in the common envelope.
Each field is described below.
| Field | Description |
|---|---|
doc_id | ID of the given document. |
exec_time | Execution time in seconds (a decimal string such as "0.01"). |
query_time | Search engine query time (int64, milliseconds). |
page_size | Number of documents asked for, after the limit described above. |
record_count | Number of documents that have the same signature, not only those in data. The exact count is tracked only up to query.track.total.hits (default: 10000). |
record_count_relation | When EQUAL_TO, the count is exact; when GREATER_THAN_OR_EQUAL_TO, only the lower bound is known. |
partial | Whether the result may be incomplete (bool). The query timeout (query.timeout) applies, as in a search. |
timed_out | Whether the query timeout elapsed (bool). |
shard_failed | Whether one or more shards failed (bool). |
data | Array of documents, ordered by URL and then document ID. Each element has the same fields as a hit of /api/v2/search (see Search API), including tags (the tags visible to the caller, see Tags API). There is no query to highlight, so content_description is the digest of the content, and there is no score. |
Table: Response Fields
Error Response
Table: Error Response