Skip to content

Commit c97d9bc

Browse files
committed
Update README.md
1 parent 06457a2 commit c97d9bc

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,47 @@ In published config file add descriptions for models which need to be indexed, f
6666

6767
],
6868

69+
```
70+
You can also index values of **optional fields** (dynamic fields). For enable indexing for optional fields:
71+
72+
- In config for each necessary model add following option:
73+
```php
74+
'optional_attributes' => true
75+
76+
// or
77+
78+
'optional_attributes' => [
79+
'field' => 'custom_name' // with specifying of accessor name
80+
]
81+
```
82+
- In model add **special accessor**, that returns list of `field-name => field-value`.
83+
By default `getOptionalAttributesAttribute` accessor will be used.
84+
In case accessor name specified in config `getCustomNameAttribute` accessor will be used.
85+
86+
Example:
87+
88+
In config file:
89+
90+
```php
91+
'namespace\FirstModel' => [
92+
'fields' => [
93+
'name', 'full_description', // Fixed fields for indexing.
94+
],
95+
96+
'optional_attributes' => true // Enable indexing for dynamic fields
97+
],
98+
```
99+
100+
In model add following accessor:
101+
102+
```php
103+
publc function getOptionalAttributesAttribute()
104+
{
105+
return [
106+
'optional_attribute1' => "value1",
107+
'optional_attribute2' => "value2",
108+
];
109+
}
69110
```
70111
By default the following filters are used by search:
71112
- Stemming filter for english/russian words,

0 commit comments

Comments
 (0)