diff options
| author | Yuriy Andamasov <yuriy@vyos.io> | 2026-05-22 11:40:40 +0300 |
|---|---|---|
| committer | Yuriy Andamasov <yuriy@vyos.io> | 2026-05-23 13:25:01 +0300 |
| commit | fc0e71e28e49d9cdc84fadfda40692bdfc415a6c (patch) | |
| tree | f4fbbcc1ad390680ca45077da6d64a882155207a /src/__tests__/VyOSElasticModernFulltextStorageEngineTestCase.php | |
| parent | 67d619a782eef8df6437525c45a63c9485c13a6a (diff) | |
| download | phorge-elasticsearch-modern-fc0e71e28e49d9cdc84fadfda40692bdfc415a6c.tar.gz phorge-elasticsearch-modern-fc0e71e28e49d9cdc84fadfda40692bdfc415a6c.zip | |
Engine: Add buildIndexMappings() helper (single typeless mapping)
Single 'properties' block, documentType as a keyword field inside it,
no include_in_all anywhere (the field was removed in ES 6).
Relationships emit as keyword fields with doc_values: false, matching
the bundled engine's ES-5-mode behavior. Field-data multi-analyzer
shape (raw, keywords, stems) preserved.
🤖 Generated by [robots](https://vyos.io)
Diffstat (limited to 'src/__tests__/VyOSElasticModernFulltextStorageEngineTestCase.php')
| -rw-r--r-- | src/__tests__/VyOSElasticModernFulltextStorageEngineTestCase.php | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/__tests__/VyOSElasticModernFulltextStorageEngineTestCase.php b/src/__tests__/VyOSElasticModernFulltextStorageEngineTestCase.php index ff4ade8..ab6f5c6 100644 --- a/src/__tests__/VyOSElasticModernFulltextStorageEngineTestCase.php +++ b/src/__tests__/VyOSElasticModernFulltextStorageEngineTestCase.php @@ -112,4 +112,58 @@ final class VyOSElasticModernFulltextStorageEngineTestCase $filter); } + public function testBuildIndexMappingsShape() { + $engine = id(new VyOSElasticModernFulltextStorageEngine()) + ->setVersion(7); + + $doc_types = array('TASK', 'DREV'); + $fields = array('title', 'body', 'comment'); + $relationships = array('authorPHID', 'projectPHID'); + $mappings = $engine->buildIndexMappings( + $doc_types, $fields, $relationships, 'text'); + + // Single typeless mapping with one 'properties' block. + $this->assertTrue(isset($mappings['properties'])); + $this->assertFalse(isset($mappings['TASK'])); + $this->assertFalse(isset($mappings['DREV'])); + + // Field properties exist with the multi-analyzer shape. + $this->assertTrue(isset($mappings['properties']['title'])); + $this->assertEqual('text', $mappings['properties']['title']['type']); + $this->assertTrue( + isset($mappings['properties']['title']['fields']['raw'])); + $this->assertTrue( + isset($mappings['properties']['title']['fields']['keywords'])); + $this->assertTrue( + isset($mappings['properties']['title']['fields']['stems'])); + + // Relationships emit as keyword fields with doc_values:false. + $this->assertEqual( + 'keyword', + $mappings['properties']['authorPHID']['type']); + $this->assertEqual( + false, + $mappings['properties']['authorPHID']['doc_values']); + $this->assertEqual( + 'date', + $mappings['properties']['authorPHID_ts']['type']); + + // No include_in_all anywhere. + $this->assertFalse( + isset($mappings['properties']['authorPHID']['include_in_all'])); + + // documentType is a keyword field inside properties. + $this->assertEqual( + 'keyword', + $mappings['properties']['documentType']['type']); + + // Standard date fields present. + $this->assertEqual( + 'date', + $mappings['properties']['dateCreated']['type']); + $this->assertEqual( + 'date', + $mappings['properties']['lastModified']['type']); + } + } |
