From a529a40ec8569a7010df4965c4e7fff9e81eb125 Mon Sep 17 00:00:00 2001 From: Yuriy Andamasov Date: Fri, 22 May 2026 11:38:59 +0300 Subject: Engine: Add buildTypeFilter() helper (body-level documentType filter) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤖 Generated by [robots](https://vyos.io) --- ...SElasticModernFulltextStorageEngineTestCase.php | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/__tests__/VyOSElasticModernFulltextStorageEngineTestCase.php') diff --git a/src/__tests__/VyOSElasticModernFulltextStorageEngineTestCase.php b/src/__tests__/VyOSElasticModernFulltextStorageEngineTestCase.php index 1762d32..95558a1 100644 --- a/src/__tests__/VyOSElasticModernFulltextStorageEngineTestCase.php +++ b/src/__tests__/VyOSElasticModernFulltextStorageEngineTestCase.php @@ -89,4 +89,29 @@ final class VyOSElasticModernFulltextStorageEngineTestCase $this->assertEqual('/_search', $engine->getSearchUri(array())); } + public function testBuildTypeFilter() { + $engine = id(new VyOSElasticModernFulltextStorageEngine()) + ->setVersion(7); + $filter = $engine->buildTypeFilter(array('TASK', 'DREV')); + $expected = array( + 'terms' => array( + 'documentType' => array('TASK', 'DREV'), + ), + ); + $this->assertEqual($expected, $filter); + } + + public function testBuildTypeFilterEmpty() { + // Empty list still produces a filter; the caller is responsible + // for normalizing "no types specified" to "all indexable types" + // before calling this method. This matches the bundled engine's + // pattern (executeSearch() normalizes before URL construction). + $engine = id(new VyOSElasticModernFulltextStorageEngine()) + ->setVersion(7); + $filter = $engine->buildTypeFilter(array()); + $this->assertEqual( + array('terms' => array('documentType' => array())), + $filter); + } + } -- cgit v1.2.3