docker run -itd --rm -p 7700:7700 getmeili/meilisearch:v1.3
docker-compose 参数
version: "3"
networks:
flyserver:
driver: bridge
services:
search:
image: getmeili/meilisearch:v1.3
restart: always
environment:
- MEILI_MASTER_KEY=masterKey
ports:
- "7700:7700"
networks:
- flyserver
user: root
tty: true
require_once __DIR__ . '/vendor/autoload.php';
use Meilisearch\Client;
$client = new Client('http://127.0.0.1:7700', 'masterKey');
$index = $client->index('movies');
$documents = [
['id' => 1, 'title' => 'Carol', 'genres' => ['Romance, Drama']],
['id' => 2, 'title' => 'Wonder Woman', 'genres' => ['Action, Adventure']],
['id' => 3, 'title' => 'Life of Pi', 'genres' => ['Adventure, Drama']],
['id' => 4, 'title' => 'Mad Max: Fury Road', 'genres' => ['Adventure, Science Fiction']],
['id' => 5, 'title' => 'Moana', 'genres' => ['Fantasy, Action']],
['id' => 6, 'title' => 'Philadelphia', 'genres' => ['Drama']],
["id" => 7, "title" => "fiy", "genres" => ["01","02"]],
["id" => 8, "title" => "fiy", "genres" => ["03","04"]],
];
$index->addDocuments($documents);
$index->updateFilterableAttributes([
'id',
'genres'
]);
$search = $index->search(
'fiy',
[
'filter' => ['id > 2', "genres = '01'"]
]
);
print_r($search->getHits());