-
Notifications
You must be signed in to change notification settings - Fork 202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Collapse #314
Comments
Just put it to the Here's a rewritten example from <?php
require 'vendor/autoload.php'; //Composer autoload
$client = ClientBuilder::create()->build(); //elasticsearch-php client
$matchAll = new ONGR\ElasticsearchDSL\Query\MatchAllQuery();
$search = new ONGR\ElasticsearchDSL\Search();
$search->addQuery($matchAll);
$params = [
'index' => 'your_index',
'body' => array_merge(
$search->toArray(),
['collapse' => ['field' => 'field_to_collapse_on']], // Here your collapse param goes
),
];
$results = $client->search($params); |
Just FYI how i did it if ($collapseResults) {
$client = $index->getClient();
$params = [
'index' => $index->getIndexName(),
'body' => array_merge(
$search->toArray(),
['collapse' => ['field' => 'my_field']]
),
];
$results = $client->search($params);
$iterator = new RawIterator(
$results,
$index,
$index->getConverter(),
$index->getScrollConfiguration($results, $search->getScroll())
);
$elasticSearchResults = iterator_to_array($iterator);
} else {
$elasticSearchResults = iterator_to_array($index->findRaw($search));
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can you please add collapse?
https://www.elastic.co/guide/en/elasticsearch/reference/6.8/search-request-collapse.html
The text was updated successfully, but these errors were encountered: