$client->index('books')->updateDictionary(['J. R. R.', 'W. E. B.']);
$client->index('products')->updateDisplayedAttributes([ 'title', 'description' ]);
$client->index('books')->updateFaceting([ 'maxValuesPerFacet' => 2, 'sortFacetValuesBy' => ['*' => 'alpha', 'genres' => 'count'] ]);
$client->index('products')->updateFilterableAttributes( ['id','category_id','name','_geo','city_id']);
$client->index('products')->updateSettings([
'pagination' => [
'maxTotalHits' => 10000
]
]);
$client->index('products')->updateRankingRules([
'words',
'sort',
'typo',
'proximity',
'attribute',
'exactness'
]);
$client->index('movies')->search('products', [
'attributesToSearchOn' => ['title']
]);
$client->index('products')->updateSortableAttributes(['id','name','_geo']);
$client->index('movies')->updateSynonyms([
'wolverine' => ['xmen', 'logan'],
'logan' => ['wolverine', 'xmen'],
'wow' => ['world of warcraft']
]);
$client->index('products')->updateTypoTolerance([
'minWordSizeForTypos' => [
'oneTypo' => 4,
'twoTypos' => 10
],
'disableOnAttributes' => [
'title'
]
]);
//отключаем учет ошибок в написании (можно также задавать лимит символов)
$client->index('products')->updateTypoTolerance([
'enabled' => false
]);
SCOUT_DRIVER=meilisearch
MEILISEARCH_HOST=http://meilisearch:7700
MEILISEARCH_KEY=someKey
'meilisearch' => [
'host' => env('MEILISEARCH_HOST', 'http://localhost:7700'),
'key' => env('MEILISEARCH_KEY', null),
'index-settings' => [
Product::class => [
'sortableAttributes' => ['name', '_geo'],
'filterableAttributes' => ['id', 'name', '_geo', 'category_id'],
],
],
],
Product::search(
'Какое-либо название',
function (SearchIndex $meilisearch, string $query, array $options) {
$options['filter'] = "category_id IN[$ids]";
$options['sort'] = ["title:desc"];
$options['limit'] = 100;
return $meilisearch->search($query, $options);
}
)->get();
$client->multiSearch([
(new SearchQuery())
->setIndexUid('products')
->setQuery(‘запрос 1’')
->setLimit(5),
(new SearchQuery())
->setIndexUid('categories')
->setQuery('запрос 2')
->setLimit(5),
(new SearchQuery())
->setIndexUid('comments')
->setQuery('запрос 3')
]);
$client->index('products')->search('classic', [
'facets' => ['color', 'size', 'country']
]);
$client->index('products')->updateSearchableAttributes([
'title',
'brand',
'description'
]);
Product::search(
'Какое-либо название',
function (SearchIndex $meilisearch, string $query, array $options) {
$options['filter'] = "_geoRadius($lat,$long,$dist) AND id IN[$ids]";
$options['sort'] = ["_geoPoint($lat,$long):$dir"];
$options['limit'] = $count;
return $meilisearch->search($query, $options);
}
)->get();
curl \
-X PATCH 'http://localhost:7700/indexes/movies/settings' \
-H 'Content-Type: application/json' \
--data-binary '{
"embedders": {
"default": {
"source": "huggingFace",
"model": "BAAI/bge-base-en-v1.5",
"documentTemplate": "A movie titled '{{doc.title}}' whose description starts with {{doc.overview|truncatewords: 20}}"
}
}
}'
curl -X POST -H 'content-type: application/json' \
'localhost:7700/indexes/products/search' \
--data-binary '{
"q": "kitchen utensils",
"hybrid": {
"semanticRatio": 0.9,
"embedder": "default"
}
}'