Skip to content

Commit 69768a8

Browse files
Add facet option to schema index field definition
1 parent e82cda0 commit 69768a8

10 files changed

+69
-36
lines changed

packages/seal/src/Schema/Field/AbstractField.php

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public function __construct(
2727
public readonly bool $searchable,
2828
public readonly bool $filterable,
2929
public readonly bool $sortable,
30+
public readonly bool $facet,
3031
public readonly array $options,
3132
) {
3233
}

packages/seal/src/Schema/Field/BooleanField.php

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public function __construct(
3232
bool $searchable = false,
3333
bool $filterable = false,
3434
bool $sortable = false,
35+
bool $facet = false,
3536
array $options = [],
3637
) {
3738
if ($searchable) { // @phpstan-ignore-line
@@ -44,6 +45,7 @@ public function __construct(
4445
$searchable,
4546
$filterable,
4647
$sortable,
48+
$facet,
4749
$options,
4850
);
4951
}

packages/seal/src/Schema/Field/DateTimeField.php

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public function __construct(
3232
bool $searchable = false,
3333
bool $filterable = false,
3434
bool $sortable = false,
35+
bool $facet = false,
3536
array $options = [],
3637
) {
3738
if ($searchable) { // @phpstan-ignore-line
@@ -44,6 +45,7 @@ public function __construct(
4445
$searchable,
4546
$filterable,
4647
$sortable,
48+
$facet,
4749
$options,
4850
);
4951
}

packages/seal/src/Schema/Field/FloatField.php

+8-6
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,21 @@ public function __construct(
3232
bool $searchable = false,
3333
bool $filterable = false,
3434
bool $sortable = false,
35+
bool $facet = false,
3536
array $options = [],
3637
) {
3738
if ($searchable) { // @phpstan-ignore-line
3839
throw new \InvalidArgumentException('Searchability for FloatField is not yet implemented: https://github.com/php-cmsig/search/issues/97');
3940
}
4041

4142
parent::__construct(
42-
$name,
43-
$multiple,
44-
$searchable,
45-
$filterable,
46-
$sortable,
47-
$options,
43+
name: $name,
44+
multiple: $multiple,
45+
searchable: $searchable,
46+
filterable: $filterable,
47+
sortable: $sortable,
48+
facet: $facet,
49+
options: $options,
4850
);
4951
}
5052
}

packages/seal/src/Schema/Field/GeoPointField.php

+14-6
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
* ATTENTION: Different search engines support only one field for geopoint per index.
2323
*
2424
* @property false $searchable
25+
* @property false $facet
2526
*
2627
* @readonly
2728
*/
@@ -30,6 +31,7 @@ final class GeoPointField extends AbstractField
3031
/**
3132
* @param false $searchable
3233
* @param false $multiple
34+
* @param false $facet
3335
* @param array<string, mixed> $options
3436
*/
3537
public function __construct(
@@ -38,19 +40,25 @@ public function __construct(
3840
bool $searchable = false,
3941
bool $filterable = false,
4042
bool $sortable = false,
43+
bool $facet = false,
4144
array $options = [],
4245
) {
4346
if ($searchable) { // @phpstan-ignore-line
4447
throw new \InvalidArgumentException('Searchability for GeoPointField is not yet implemented: https://github.com/php-cmsig/search/issues/97');
4548
}
4649

50+
if ($facet) { // @phpstan-ignore-line
51+
throw new \InvalidArgumentException('Facet for GeoPointField is not yet implemented: <TODO create issue>');
52+
}
53+
4754
parent::__construct(
48-
$name,
49-
$multiple,
50-
$searchable,
51-
$filterable,
52-
$sortable,
53-
$options,
55+
name: $name,
56+
multiple: $multiple,
57+
searchable: $searchable,
58+
filterable: $filterable,
59+
sortable: $sortable,
60+
facet: $facet,
61+
options: $options,
5462
);
5563
}
5664
}

packages/seal/src/Schema/Field/IdentifierField.php

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
* @property false $searchable
2121
* @property true $filterable
2222
* @property true $sortable
23+
* @property false $facet
2324
*
2425
* @readonly
2526
*/
@@ -33,6 +34,7 @@ public function __construct(string $name)
3334
searchable: false,
3435
filterable: true,
3536
sortable: true,
37+
facet: false,
3638
options: [],
3739
);
3840
}

packages/seal/src/Schema/Field/IntegerField.php

+8-6
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,21 @@ public function __construct(
3232
bool $searchable = false,
3333
bool $filterable = false,
3434
bool $sortable = false,
35+
bool $facet = false,
3536
array $options = [],
3637
) {
3738
if ($searchable) { // @phpstan-ignore-line
3839
throw new \InvalidArgumentException('Searchability for IntegerField is not yet implemented: https://github.com/php-cmsig/search/issues/97');
3940
}
4041

4142
parent::__construct(
42-
$name,
43-
$multiple,
44-
$searchable,
45-
$filterable,
46-
$sortable,
47-
$options,
43+
name: $name,
44+
multiple: $multiple,
45+
searchable: $searchable,
46+
filterable: $filterable,
47+
sortable: $sortable,
48+
facet: $facet,
49+
options: $options,
4850
);
4951
}
5052
}

packages/seal/src/Schema/Field/ObjectField.php

+12-6
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public function __construct(
3333
$searchable = false;
3434
$filterable = false;
3535
$sortable = false;
36+
$facet = false;
3637

3738
foreach ($fields as $field) {
3839
if ($field->searchable) {
@@ -46,15 +47,20 @@ public function __construct(
4647
if ($field->sortable) {
4748
$sortable = true;
4849
}
50+
51+
if ($field->facet) {
52+
$facet = true;
53+
}
4954
}
5055

5156
parent::__construct(
52-
$name,
53-
$multiple,
54-
$searchable,
55-
$filterable,
56-
$sortable,
57-
$options,
57+
name: $name,
58+
multiple: $multiple,
59+
searchable: $searchable,
60+
filterable: $filterable,
61+
sortable: $sortable,
62+
facet: $facet,
63+
options: $options,
5864
);
5965
}
6066
}

packages/seal/src/Schema/Field/TextField.php

+8-6
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,17 @@ public function __construct(
2929
bool $searchable = true,
3030
bool $filterable = false,
3131
bool $sortable = false,
32+
bool $facet = false,
3233
array $options = [],
3334
) {
3435
parent::__construct(
35-
$name,
36-
$multiple,
37-
$searchable,
38-
$filterable,
39-
$sortable,
40-
$options,
36+
name: $name,
37+
multiple: $multiple,
38+
searchable: $searchable,
39+
filterable: $filterable,
40+
sortable: $sortable,
41+
facet: $facet,
42+
options: $options,
4143
);
4244
}
4345
}

packages/seal/src/Schema/Field/TypedField.php

+12-6
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public function __construct(
3434
$searchable = false;
3535
$filterable = false;
3636
$sortable = false;
37+
$facet = false;
3738

3839
foreach ($types as $fields) {
3940
foreach ($fields as $field) {
@@ -48,16 +49,21 @@ public function __construct(
4849
if ($field->sortable) {
4950
$sortable = true;
5051
}
52+
53+
if ($field->facet) {
54+
$facet = true;
55+
}
5156
}
5257
}
5358

5459
parent::__construct(
55-
$name,
56-
$multiple,
57-
$searchable,
58-
$filterable,
59-
$sortable,
60-
$options,
60+
name: $name,
61+
multiple: $multiple,
62+
searchable: $searchable,
63+
filterable: $filterable,
64+
sortable: $sortable,
65+
facet: $facet,
66+
options: $options,
6167
);
6268
}
6369
}

0 commit comments

Comments
 (0)