Download the PHP package medienreaktor/meilisearch without Composer

On this page you can find all versions of the php package medienreaktor/meilisearch. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package meilisearch

Medienreaktor.Meilisearch

Integrates Meilisearch into Neos. Compatibility tested with Meilisearch versions 1.2 to 1.8.

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

✨ Features

🚀 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.

⚙️ Configuration

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

You can adjust all Meilisearch index settings to fit your needs (see Meilisearch Documentation). All settings configured here will directly be passed to Meilisearch.

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):

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

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:

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

📖 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 feature Description
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 fulltext search 
vector(vector) Performs a vector search (see below) 
filter(filterString) Filters by given filter string, e.g. filter('__nodeTypeAndSupertypes = "Neos.Neos:Document"') (see Meilisearch Documentation)
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: ['<em'>, '</em>'])
crop(cropLength, cropMarker) Sets the highlighting snippets length in words and the crop marker (optional, default: '…')
matchingStrategy(value) Sets the matching strategy 'last' or 'all', (default: 'last')
geoRadius(lat, lng, distance) Filters by geo radius
geoPoint(lat, lng) Sort by geo point
execute() Execute the query and return resulting nodes
executeRaw() Execute the query and return raw Meilisearch result data, enriched with node data

⚡ Usage with JavaScript / React / Vue

If you want to build your frontend with JavaScript, React or Vue, you can completely ignore above Neos and Fusion integration and use instant-meilisearch.

Please mind these three things:

1. Filtering for node context and dimensions

Setup your filter to always include the following filter string: (__parentPath = "$nodePath" OR __path = "$nodePath") AND __dimensionsHash = "$dimensionsHash" where $nodePath is the NodePath of your context node (e.g. site) and $dimensionHash is the MD5-hashed JSON-encoded context dimensions array.

You can obtain these values in PHP using:

In Fusion, you get these values (assuming site is your desired context node) using:

2. The node URI

The public URI to the node is in the __uri attribute of each Meilisearch result hit.

It is generated at indexing time and one reason we create separate index records for each node variant, even if they are redundant due to dimension fallback behaviour. This is in contrast to Flowpack.ElasticSearch.ContentRepositoryAdaptor, where only one record is created and multiple dimensions hashes are assigned.

For the URI generation to work, it is important to have a primary domain assigned to each of your sites.

3. Image URIs

If you need image URIs in your frontend, this can also be configured. First, make sure to set a base URL in your Settings.yaml:

Then, either configure your specific properties or all image properties to be indexed:

You can set your desired width, height and optional allowCropping, allowUpScaling and format values in the method arguments.

📍 Geosearch

Meilisearch supports filtering and sorting on geographic location. For this feature to work, your nodes should supply the __geo property with an object of lat/lng values. An easy way to achieve this is to use a proxy property:

The search query builder supports filtering with geoRadius() and sorting with geoPoint() (see above).

📐 Vector Search

You can use Meilisearch as a vector store with the experimental Vector Search feature. Activate it using the /experimental-features endpoint as described in the release notes.

Vectors for each document have to be provided by you and indexed in the _vector-property of your node. This can be done writing a custom Eel-helper that computes the vectors using a third-party tool like OpenAI or Hugging Face.

The search query builder supports querying by vectors. Depending on your use case, vectors have to be computed again for the search phrase, e.g.:

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

    vectorSearchQuery = ${this.searchVector ? Search.query(site).vector(this.searchVector) : null}

    searchResults = ${this.vectorSearchQuery.execute()}
}

To show similar documents to your current document (e.g. for Wikis, Knowledge Bases or News Rooms), use the current document's vector as search vector.

👩‍💻 Credits

This package is heavily inspired by and some smaller code parts are copied from:

All credits go to the original authors of these packages.


All versions of meilisearch with dependencies

PHP Build Version
Package Version
Requires neos/flow Version ^7.0 || ^8.0 || dev-master
neos/neos Version ^7.0 || ^8.0 || dev-master
neos/content-repository Version ^7.0 || ^8.0 || dev-master
neos/content-repository-search Version ^4.0 || dev-master
meilisearch/meilisearch-php Version *
guzzlehttp/guzzle Version *
http-interop/http-factory-guzzle Version ^1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package medienreaktor/meilisearch contains the following files

Loading the files please wait ....