Skip to content

How to delete documents from index and return affected rows count? #196

Answered by sanikolaev
d47081 asked this question in Q&A
Discussion options

You must be logged in to vote

Here's the docs https://github.com/manticoresoftware/manticoresearch-php/blob/master/docs/indexclass.md#deletedocuments

Here's an example:

➜  ~ cat test.php
<?php
require_once __DIR__ . '/vendor/autoload.php';

$config = ['host'=>'127.0.0.1','port'=>9308];
$client = new \Manticoresearch\Client($config);
$index = $client->index('t');
$index->drop(true);
$index->create([
    'f' => ['type' => 'text'],
]);

$index->addDocuments([
  ['f' => 'a'],
  ['f' => 'b'],
  ['f' => 'a']
]);

print_r($index->deleteDocuments(['match' => ['f' => 'a']]));
➜  ~ php test.php
Array
(
    [_index] => t
    [deleted] => 2
)

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
1 reply
@d47081
Comment options

Comment options

You must be logged in to vote
3 replies
@d47081
Comment options

@d47081
Comment options

@sanikolaev
Comment options

Answer selected by d47081
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants