@@ -187,16 +187,72 @@ SEARCH_PEPPER=your-random-secret-string
187187
188188``` php
189189return [
190+ // Secret pepper for token hashing
190191 'search_pepper' => env('SEARCH_PEPPER', ''),
192+
193+ // Maximum prefix depth for token generation
191194 'max_prefix_depth' => 6,
195+
196+ // Minimum prefix length for search queries (default: 3)
197+ 'min_prefix_length' => env('ENCRYPTED_SEARCH_MIN_PREFIX', 3),
198+
199+ // Automatic indexing of encrypted casts
200+ 'auto_index_encrypted_casts' => true,
201+
202+ // Elasticsearch integration
192203 'elasticsearch' => [
193- 'enabled' => env('ENCRYPTED_SEARCH_DRIVER ', 'database') === 'elasticsearch' ,
194- 'host' => env('ELASTICSEARCH_HOST', 'http://localhost :9200'),
204+ 'enabled' => env('ENCRYPTED_SEARCH_ELASTIC_ENABLED ', false) ,
205+ 'host' => env('ELASTICSEARCH_HOST', 'http://elasticsearch :9200'),
195206 'index' => env('ELASTICSEARCH_INDEX', 'encrypted_search'),
196207 ],
208+
209+ // Debug logging
210+ 'debug' => env('ENCRYPTED_SEARCH_DEBUG', false),
197211];
198212```
199213
214+ ### Configuration Options
215+
216+ | Option | Default | Description |
217+ | --------| ---------| -------------|
218+ | ` search_pepper ` | ` '' ` | Secret pepper value for token hashing. ** Required for security.** |
219+ | ` max_prefix_depth ` | ` 6 ` | Maximum number of prefix characters to index (e.g., "wietse" → w, wi, wie, wiet, wiets, wietse) |
220+ | ` min_prefix_length ` | ` 3 ` | Minimum search term length for prefix queries. Prevents overly broad matches from short terms like "w" or "de". |
221+ | ` auto_index_encrypted_casts ` | ` true ` | Automatically index fields with ` encrypted ` cast types |
222+ | ` elasticsearch.enabled ` | ` false ` | Use Elasticsearch instead of database for token storage |
223+ | ` elasticsearch.host ` | ` http://elasticsearch:9200 ` | Elasticsearch host URL |
224+ | ` elasticsearch.index ` | ` encrypted_search ` | Elasticsearch index name |
225+ | ` debug ` | ` false ` | Enable debug logging for index operations |
226+
227+ ### Minimum Prefix Length
228+
229+ The ` min_prefix_length ` setting prevents performance issues and false positives from very short search terms.
230+
231+ ** Example with ` min_prefix_length = 3 ` (default):**
232+
233+ ``` php
234+ // ❌ Returns no results (too short)
235+ Client::encryptedPrefix('first_names', 'Wi')->get();
236+
237+ // ✅ Works normally (meets minimum)
238+ Client::encryptedPrefix('first_names', 'Wil')->get(); // Finds "Wilma"
239+
240+ // ✅ Exact search always works (ignores minimum)
241+ Client::encryptedExact('first_names', 'Wi')->get();
242+ ```
243+
244+ ** Recommended values:**
245+ - ` 1 ` : Allow single-character searches (more flexible, more false positives)
246+ - ` 2 ` : Require two characters (good for short names)
247+ - ` 3 ` : Require three characters (recommended - good balance)
248+ - ` 4 ` : Require four characters (very precise, less flexible)
249+
250+ To adjust this setting, add to your ` .env ` :
251+
252+ ``` env
253+ ENCRYPTED_SEARCH_MIN_PREFIX=3
254+ ```
255+
200256---
201257
202258## Usage
0 commit comments