Unindex a document
unindexfile
DELETE https://bezillion.com/api/v1/unindexfile/id?login=&password=
id is the unique identifier of a file in your index, e.g. 12345678-9abc-def0-1234-56789abcdef0
.
login | Your identification code. |
---|---|
password | Your password. |
NOTE: A POST is accepted.
You can test this function in the interface of your personal space.
Select files. Click on the trash can to remove them from the index.
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 -
{"status":"success","data":null}
Look for the file fox.txt:
$ curl -s --fail --show-error -X GET "https://bezillion.com/api/v1/searchindex?login=abcdef&password=ABCDEF&fq=file:fox.txt"
{"status":"success","data":{"docs":[{"date":1669597200,"file":"fox.txt","size":45,"id":"12345678-9abc-def0-1234-56789abcdef0","lang":"en","from":"local","score":1,"hl":false}]}}
{"status":"success","data":null}
Note the identifier of the file returned in the field id
: 12345678-9abc-def0-1234-56789abcdef0
.
Remove the file from your the index:
$ curl -s --fail --show-error -X DELETE "https://bezillion.com/api/v1/unindexfile/12345678-9abc-def0-1234-56789abcdef0?login=abcdef&password=ABCDEF"
{"status":"success","data":null}
If the identifier of the file is invalid, the service returns the error HTTP/1.1 400 Bad Request
.
If no file in your index has the specified identifier, the service doesn't return an error.
Download the code of the senddelete
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 senddelete
function.
Add the file unindexfile.php with the following content:
- require_once 'sendhttp.php';
Loads the code of the senddelete
function.
- function unindexfile($login, $password, $id) {
Defines the function unindexfile
.
$login
is your identification code. $password
is your password.
$id
is the unique identifier of a file in your index.
- $curl = 'https://bezillion.com/api/v1/unindexfile/' . $id . '?' . 'login=' . urlencode($login) . '&' . 'password=' . urlencode($password);
Sets $curl
to the URL of the unindexfile 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.
- $response=senddelete($curl);
Sends the HTTP request with senddelete
.
The arguments $id
, login
and password
are already in $curl
.
- if (!$response or $response[0] != 200) {
- return false;
- }
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, unindexfile
returns false.
- return true;
- }
Returns true
if the document has been removed from your index.
EXAMPLE
Assuming you have saved the files sendhttp.php and unindexfile.php in the current directory, run PHP in interactive mode, load the unindexfile
function and call it with as arguments your identification code and password, the id of the file to remove from your index:
$ php -a
php > require_once 'unindexfile.php';
php > $r=unindexfile('abcdef', 'ABCDEF', '12345678-9abc-def0-1234-56789abcdef0');
php > echo $r ? 'Ok' : 'Ko';
Ok
php > quit
NOTE: If unindexfile
returns false
, edit the code to display $response
.
SEE ALSO
Call the service API, Index a document, Search for a document
Comments
To add a comment, click here.