PHPackages                             medienreaktor/meilisearch - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Search &amp; Filtering](/categories/search)
4. /
5. medienreaktor/meilisearch

ActiveNeos-package[Search &amp; Filtering](/categories/search)

medienreaktor/meilisearch
=========================

Integrates Meilisearch into Neos.

v2.5.1(4w ago)101.0k↑131.3%3[1 issues](https://github.com/medienreaktor/Medienreaktor.Meilisearch/issues)[5 PRs](https://github.com/medienreaktor/Medienreaktor.Meilisearch/pulls)MITPHP

Since Jul 25Pushed 4w ago1 watchersCompare

[ Source](https://github.com/medienreaktor/Medienreaktor.Meilisearch)[ Packagist](https://packagist.org/packages/medienreaktor/meilisearch)[ RSS](/packages/medienreaktor-meilisearch/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (10)Dependencies (18)Versions (31)Used By (0)

Medienreaktor.Meilisearch
=========================

[](#medienreaktormeilisearch)

Integrates Meilisearch into Neos. **Compatibility tested with Meilisearch versions 1.2 to 1.16.**
**Note:** Vector search with built-in embedders is only available from Meilisearch version 1.6.0 and above.

This package aims for simplicity and minimal dependencies. It might therefore not be as sophisticated and extensible as packages like [Flowpack.ElasticSearch.ContentRepositoryAdaptor](https://github.com/Flowpack/Flowpack.ElasticSearch.ContentRepositoryAdaptor), and to achieve this, some code parts had to be copied from these great packages (see Credits).

✨ Features
----------

[](#-features)

- ✅ Indexing the Neos Content Repository in Meilisearch
- ✅ Supports Content Dimensions for all node variants
- ✅ CLI commands for building and flushing the index
- ✅ Querying the index via Search-/Eel-Helpers and QueryBuilder
- ✅ Frontend search form, result rendering and pagination
- ✅ Faceting and snippet highlighting
- ✅ Geosearch filtering and sorting
- ✅ Vector Search for semantic search / AI search
- 🔴 No asset indexing (yet)
- 🔴 No autocomplete / autosuggest (this is currently not supported by Meilisearch)

🚀 Installation
--------------

[](#-installation)

Install via composer:

```
composer require medienreaktor/meilisearch

```

There are several ways to install Meilisearch for development. If you are using DDEV, there is a [Meilisearch-snippet](https://github.com/ddev/ddev-contrib/tree/master/docker-compose-services/meilisearch).

⚙️ Configuration
----------------

[](#️-configuration)

Configure the Meilisearch client in your `Settings.yaml` and set the Endpoint and API Key:

```
Medienreaktor:
  Meilisearch:
    client:
      endpoint: ''
      apiKey: ''
```

You can adjust all Meilisearch index settings to fit your needs (see [Meilisearch Documentation](https://www.meilisearch.com/docs/reference/api/settings)). All settings configured here will directly be passed to Meilisearch.

```
Medienreaktor:
  Meilisearch:
    settings:
      displayedAttributes:
        - '*'
      searchableAttributes:
        - '__fulltext.text'
        - '__fulltext.h1'
        - '__fulltext.h2'
        - '__fulltext.h3'
        - '__fulltext.h4'
        - '__fulltext.h5'
        - '__fulltext.h6'
      filterableAttributes:
        - '__identifier'
        - '__dimensionsHash'
        - '__path'
        - '__parentPath'
        - '__nodeType'
        - '__nodeTypeAndSupertypes'
        - '_hidden'
        - '_hiddenBeforeDateTime'
        - '_hiddenAfterDateTime'
        - '_hiddenInIndex'
        - '_geo'
      sortableAttributes:
        - '_geo'
      rankingRules:
        - 'words'
        - 'typo'
        - 'proximity'
        - 'attribute'
        - 'sort'
        - 'exactness'
      stopWords: []
      typoTolerance:
        enabled: true
        minWordSizeForTypos:
          oneTypo: 5
          twoTypos: 9
      faceting:
        maxValuesPerFacet: 100
```

Please do not remove, only extend, above `filterableAttributes`, as they are needed for base functionality to work. After finishing or changing configuration, build the node index once via the CLI command `flow nodeindex:build`.

Document NodeTypes should be configured as fulltext root (this comes by default for all `Neos.Neos:Document` subtypes):

```
'Neos.Neos:Document':
  search:
    fulltext:
      isRoot: true
      enable: true
```

Properties of Content NodeTypes that should be included in fulltext search must also be configured appropriately:

```
'Neos.NodeTypes:Text':
  search:
    fulltext:
      enable: true
  properties:
    'text':
      search:
        fulltextExtractor: "${Indexing.extractHtmlTags(node.properties.text)}"

'Neos.NodeTypes:Headline':
  search:
    fulltext:
      enable: true
  properties:
    'title':
      search:
        fulltextExtractor: "${Indexing.extractHtmlTags(node.properties.title)}"
```

You will see that some properties are indexed twice, like `_path` and `__path`, `_nodeType` and `__nodeType`. This is due to the different *privacy* of these node properties:

- `_*`-properties are default Neos node properties that are private to Neos (and may change)
- `__*`-properties are private properties that are required for the Meilisearch-integration

We have to make sure that our required properties are always there, so we better index them separately.

### Disable fulltext extractor

[](#disable-fulltext-extractor)

To disable the fulltext extractor and don't index `fulltext` at all, you can use the given setting `enableFulltext`

```
Medienreaktor:
  Meilisearch:
    enableFulltext: false
```

This is useful if you depend on your own outofband rendering for document nodes.

### Set required attributes for indexing

[](#set-required-attributes-for-indexing)

With the setting `neededAttributesForIndex` you can define attributes who must be set to index the document. Otherwhise, the document get's deleted from the index. For example: You need to have the `title` attribute set, otherwise the node will not be indexed and (if present) will be removed from the index. You can add as many attributes as you want.

```
Medienreaktor:
  Meilisearch:
    neededAttributesForIndex:
      - 'title'
```

📖 Usage with Neos and Fusion
----------------------------

[](#-usage-with-neos-and-fusion)

There is a built-in Content NodeType `Medienreaktor.Meilisearch:Search` for rendering the search form, results and pagination that may serve as a boilerplate for your projects. Just place it on your search page to start.

You can also use search queries, results and facets in your own Fusion components.

```
prototype(Medienreaktor.Meilisearch:Search) < prototype(Neos.Neos:ContentComponent) {
    searchTerm = ${String.toString(request.arguments.search)}

    page = ${String.toInteger(request.arguments.page) || 1}
    hitsPerPage = 10

    searchQuery = ${this.searchTerm ? Search.query(site).fulltext(this.searchTerm).nodeType('Neos.Neos:Document') : null}
    searchQuery.@process {
        page = ${value.page(this.page)}
        hitsPerPage = ${value.hitsPerPage(this.hitsPerPage)}
    }

    facets = ${this.searchQuery.facets(['__nodeType', '__parentPath'])}
    totalPages = ${this.searchQuery.totalPages()}
    totalHits = ${this.searchQuery.totalHits()}
}

```

If you want facet distribution for certain node properties or search in them, make sure to add them to `filterableAttributes` and/or `searchableAttributes` in your `Settings.yaml`.

The search query builder supports the following features:

Query featureDescription`query(context)`Sets the starting point for this query, e.g. `query(site)``nodeType(nodeTypeName)`Filters by the given NodeType, e.g. `nodeType('Neos.Neos:Document')``fulltext(searchTerm)`Performs a keyword search `hybrid(searchTerm)`Performs a hybrid search with vector and keyword `vector(searchTerm)`Performs a vector search `filter(filterString)`Filters by given filter string, e.g. `filter('__nodeTypeAndSupertypes = "Neos.Neos:Document"')` (see [Meilisearch Documentation](https://www.meilisearch.com/docs/reference/api/search#filter))`exactMatch(propertyName, value)`Filters by a node property`exactMatchMultiple(properties)`Filters by multiple node properties, e.g. `exactMatchMultiple(['author' => 'foo', 'date' => 'bar'])``sortAsc(propertyName)`Sort ascending by property`sortDesc(propertyName)`Sort descending by property`limit(value)`Limit results, e.g. `limit(10)``from(value)`Return results starting from, e.g. `from(10)``page(value)`Return paged results for given page, e.g. `page(1)``hitsPerPage(value)`Hits per page for paged results, e.g. `hitsPerPage(10)``count()`Get total results count for non-paged results`totalHits()`Get total hits for paged results`totalPages()`Get total pages for paged results`facets(array)`Return facet distribution for given facets, e.g. `facets(['__type', '__parentPath'])``highlight(properties, highlightTags)`Highlight search results for given properties, e.g. `highlight(['__fulltext.text'])`, highlighted with given tags (optional, default: `['
