multi percolate
does elastica support the multi percolate api as defined in http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-percolate.html#_multi_percolate_api ?
i did not find anything, but maybe i missed it. (one can always hope)
the idea is to query the matching-or-not of many documents in one request.
i was trying to do this as a raw request on an index. turns out the data format to send is really peculiar: the body of the request has to contain separate json lines. each line for itself is valid json, but they are just one after the other, without a common wrapping. this looks very similar to the multi-search format. probably the implementation could look similar to Elastica\Multi\Search.
luckily i figured out that for our project we can do without mpercolate for now, so i don't plan a PR right now. but we could leave the issue as a starting point if you agree.
I like the starting point and we could directly make it part of the Multi folder as there are already approaches for Search and ResultSet: https://github.com/ruflin/Elastica/tree/master/lib/Elastica/Multi
the elasticsearch support (zachary) gave me this example, if it is any help:
$client = new Client();
$index = $client->getIndex('twitter');
$type = $index->getType('tweet');
$mpercolate = [
'{"percolate" : {"index" : twitter", "type" : "tweet"}}',
'{"doc" : {"message" : "some text"}}',
'{"percolate" : {"index" : twitter", "type" : "tweet", "id" : "1"}}',
'{}'
//etc etc
];
// add a newline between each JSON, and a final terminating newline
$mpercolate = implode("\n", $mpercolate) . "\n";
$path = $index->getName() . '/' . $type->getName() . '/_mpercolate';
$response = $client->request($path, Request::POST, $mpercolate);
$responseArray = $response->getData();
If this is just for testing, using a HEREDOC for the mpercolate tends to be simpler:
$mpercolate = <<<MPERCOLATE
{"percolate" : {"index" : twitter", "type" : "tweet"}}
{"doc" : {"message" : "some text"}}
{"percolate" : {"index" : twitter", "type" : "tweet", "id" : "1"}}
{}
MPERCOLATE;
Jep, that helps. I don't have the time to implement it right now but I hope someone is going to pick it up ;-)