File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed
Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff 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```
70111By default the following filters are used by search:
71112- Stemming filter for english/russian words,
You can’t perform that action at this time.
0 commit comments