Skip to content

Commit

Permalink
skipped test according to client version
Browse files Browse the repository at this point in the history
  • Loading branch information
hkulekci committed Nov 18, 2023
1 parent 0e38feb commit b76dece
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions tests/Functional/Knn/KnnTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

namespace ONGR\ElasticsearchDSL\Tests\Functional\Knn;

use ONGR\ElasticsearchDSL\Aggregation\Bucketing\DateHistogramAggregation;
use Composer\InstalledVersions;
use Elastic\Elasticsearch\Client;
use ONGR\ElasticsearchDSL\Knn\Knn;
use ONGR\ElasticsearchDSL\Query\TermLevel\TermQuery;
use ONGR\ElasticsearchDSL\Search;
Expand Down Expand Up @@ -88,15 +89,19 @@ public function testKnnSearchWithFilter(): void
*/
public function testKnnSearchWithSimilarity(): void
{
$knn = new Knn('vector_field', [1, 2, 3], 1, 1);
$knn->setFilter(new TermQuery('label', 2));
$knn->setSimilarity(0.1);
if (version_compare(Client::VERSION, '8.8') === 1) {
$knn = new Knn('vector_field', [1, 2, 3], 1, 1);
$knn->setFilter(new TermQuery('label', 2));
$knn->setSimilarity(0.1);

$search = new Search();
$search->addKnn($knn);
$results = $this->executeSearch($search, true);
$this->assertCount(1, $results['hits']['hits']);
$this->assertEquals('doc_3', $results['hits']['hits'][0]['_id']);
$search = new Search();
$search->addKnn($knn);
$results = $this->executeSearch($search, true);
$this->assertCount(1, $results['hits']['hits']);
$this->assertEquals('doc_3', $results['hits']['hits'][0]['_id']);
} else {
$this->markTestSkipped('This feature comes with Elasticsearch >=8.8.x');
}
}

/**
Expand Down

0 comments on commit b76dece

Please sign in to comment.