Relate a document


GET https://bezillion.com/api/v1/relatefile/id?login=&password=

id is the unique identifier of a file in your index, e.g. 12345678-9abc-def0-1234-56789abcdef0.

loginYour identification code.
passwordYour password.

You can test this function in the interface of your personal space.




2022-11-28 14:00 30,9k en fox.jpg

 1 • 

2022-11-28 02:00 45 en fox.txt

A search of proximity lists the documents similar to a document of reference and terms in common.

The quick brown fox
jumps over
the lazy dog.

Index the file:

$ curl -s --fail --show-error -X POST "https://bezillion.com/api/v1/indexfile?login=abcdef&password=ABCDEF" -F "file=@fox.txt" -o -

Look for the file fox.txt:

$ curl -s --fail --show-error -X GET "https://bezillion.com/api/v1/searchfile?login=abcdef&password=ABCDEF&fq=file:fox.txt"

Note the identifier of the file returned in the field id: 12345678-9abc-def0-1234-56789abcdef0.


Index the file:

$ curl -s --fail --show-error -X POST "https://bezillion.com/api/v1/indexfile?login=abcdef&password=ABCDEF" -F "lang=eng" -F "psm=6" -F "file=@fox.jpg" -o -

Look for the file fox.jpg:

$ curl -s --fail --show-error -X GET "https://bezillion.com/api/v1/searchindex?login=abcdef&password=ABCDEF&fq=file:fox.jpg"

Look for the files similar to the file fox.txt:

$ curl -s --fail --show-error -X GET "https://bezillion.com/api/v1/relatefile/12345678-9abc-def0-1234-56789abcdef0?login=abcdef&password=ABCDEF"

NOTE: If a search returns nothing, the field data is null:


Download the code of the sendget function from the iZend library. Copy the file in the space of your application.

NOTE: See the page Call the service API for a description of the sendget function.

Add the file relatefile.php with the following content:

  1. require_once 'sendhttp.php';

Loads the code of the sendget function.

  1. function relatefile($login, $password, $id) {

Defines the function relatefile. $login is your identification code. $password is your password. $id is the unique identifier of a file in your index.

  1.     $curl = 'https://local.bezillion.com/api/v1/relatefile/' . $id . '?' . 'login=' . urlencode($login) . '&' . 'password=' . urlencode($password);

Sets $curl to the URL of the relatefile action of the API with the identifier of the file, the identification code and the password of the user's account. $login and $password must be escaped.

  1.     $response=sendget($curl);

Sends the HTTP request with sendget. The arguments $id, login and password are already in $curl.

  1.     if (!$response or $response[0] != 200) {
  2.         return false;
  3.     }

If $response is false, the server is unreachable. If $response[0] doesn't contain the HTTP return code 200 Ok, an execution error has occurred. In case of error, relatefile returns false.

  1.     $r=json_decode($response[2], true);

Decodes the data returned in JSON.

  1.     if ($r['status'] == 'success') {
  2.         return ($r['data']);
  3.     }

Returns the result of the search if the action has succeeded.

  1.     return false;
  2. }

Returns false in case of error.


Assuming you have saved the files sendhttp.php and relatefile.php in the current directory, run PHP in interactive mode, load the relatefile function and call it with as arguments your identification code and password, the id of the file fox.txt in your index:

$ php -a
php > require_once 'relatefile.php';
php > $r=relatefile('abcdef', 'ABCDEF', '12345678-9abc-def0-1234-56789abcdef0');
php > $print_r($r);
    [count] => 1
    [docs] => Array
            [0] => Array
                    [file] => fox.jpg
                    [size] => 30917
                    [extra] => 
                    [id] => 75efc8d3-5f88-4902-81eb-1c33dfa7a385
                    [date] => 1669597200
                    [from] => local
                    [lang] => en
                    [score] => 1.1002516
php > quit

NOTE: If relatefile returns false, edit the code to display $response.


Call the service API, Index a document, Search for a document , Unindex a document


To add a comment, click here.