diff --git a/readme.md b/readme.md index 2dcdb9b..6a40bfa 100644 --- a/readme.md +++ b/readme.md @@ -35,6 +35,7 @@ This will create a config file at `config/plastic.php` and a mapping directory a - [Searching](#searching) - [Aggregation](#aggregation) - [Suggestions](#suggestions) +- [Highlighting](#highlighting) - [Mappings](#mappings) - [Populate An Index](#populate-an-index) - [Access The Client](#access-client) @@ -240,6 +241,23 @@ The suggestions query builder can also be accessed directly from the model as we Tag::suggest()->term('tag_term','admin')->get(); ``` +## [Highlighting]() + +```php +$highlight = new Highlight(); +$highlight->setTags([''], ['']); +$highlight->addField('title', ['matched_fields' => ['title']]); +$highlight->addField('content', ['matched_fields' => ['content']]); + +$highlight->setParameters([ + 'require_field_match' => false, + 'force_source' => true, +]); + + +$search->query->addHighlight($highlight); +``` + ## [Model Mapping]() Mappings are an important aspect of Elasticsearch. You can compare them to indexing in SQL databases. Mapping your models yields better and more efficient search results, and allows us to use some special query functions like nested fields and suggestions.