Meilisearch PHP | Documentation

Indexes extends Endpoint
in package
uses HandlesDocuments, HandlesSettings, HandlesTasks

Table of Contents

Constants

PATH  = '/indexes'

Properties

$apiKey  : string|null
$http  : Http
$tasks  : Tasks
$createdAt  : DateTimeInterface|null
$primaryKey  : string|null
$uid  : string|null
$updatedAt  : DateTimeInterface|null

Methods

__construct()  : mixed
addDocuments()  : Task
addDocumentsCsv()  : Task
addDocumentsCsvInBatches()  : array<int, Task>
addDocumentsInBatches()  : array<int, Task>
addDocumentsJson()  : Task
addDocumentsNdjson()  : Task
addDocumentsNdjsonInBatches()  : array<int, Task>
all()  : IndexesResults
allRaw()  : array<string|int, mixed>
cancelTasks()  : Task
create()  : Task
delete()  : Task
deleteAllDocuments()  : Task
deleteDocument()  : Task
deleteDocuments()  : Task
deleteTasks()  : Task
facetSearch()  : FacetSearchResult
fetchInfo()  : self
fetchPrimaryKey()  : string|null
fetchRawInfo()  : array<string|int, mixed>|null
getChat()  : array<string|int, mixed>
getCreatedAt()  : DateTimeInterface|null
getDictionary()  : array<int, non-empty-string>
getDisplayedAttributes()  : array<int, non-empty-string>
getDistinctAttribute()  : non-empty-string|null
getDocument()  : array<string|int, mixed>
getDocuments()  : DocumentsResults
getEmbedders()  : array<string|int, mixed>|null
getFaceting()  : array{maxValuesPerFacet: int, sortFacetValuesBy: array}
getFacetSearch()  : bool
getFilterableAttributes()  : array<int, non-empty-string|array{attributePatterns: list, features?: array{facetSearch: bool, filter: array{equality: bool, comparison: bool}}}>
getLocalizedAttributes()  : array<int, array{attributePatterns: list, locales: list}>|null
getNonSeparatorTokens()  : array<int, non-empty-string>
getPagination()  : array{maxTotalHits: positive-int}
getPrefixSearch()  : "indexingTime"|"disabled"
getPrimaryKey()  : string|null
getProximityPrecision()  : "byWord"|"byAttribute"
getRankingRules()  : array<int, non-empty-string>
getSearchableAttributes()  : array<int, non-empty-string>
getSearchCutoffMs()  : int|null
getSeparatorTokens()  : array<string|int, mixed>
getSettings()  : array<string|int, mixed>
getSortableAttributes()  : array<int, non-empty-string>
getStopWords()  : array<int, non-empty-string>
getSynonyms()  : array<non-empty-string, array<int, non-empty-string>>
getTask()  : Task
getTasks()  : TasksResults
getTypoTolerance()  : array{enabled: bool, minWordSizeForTypos: array{oneTypo: int, twoTypos: int}, disableOnWords: list, disableOnAttributes: list, disableOnNumbers: bool}
getUid()  : string|null
getUpdatedAt()  : DateTimeInterface|null
rawSearch()  : array<string|int, mixed>
resetDictionary()  : Task
resetDisplayedAttributes()  : Task
resetDistinctAttribute()  : Task
resetEmbedders()  : Task
resetFaceting()  : Task
resetFacetSearch()  : Task
resetFilterableAttributes()  : Task
resetLocalizedAttributes()  : Task
resetNonSeparatorTokens()  : Task
resetPagination()  : Task
resetPrefixSearch()  : Task
resetProximityPrecision()  : Task
resetRankingRules()  : Task
resetSearchableAttributes()  : Task
resetSearchCutoffMs()  : Task
resetSeparatorTokens()  : Task
resetSettings()  : Task
resetSortableAttributes()  : Task
resetStopWords()  : Task
resetSynonyms()  : Task
resetTypoTolerance()  : Task
search()  : SearchResult|array<string|int, mixed>
searchSimilarDocuments()  : SimilarDocumentsSearchResult
show()  : array<string|int, mixed>|null
stats()  : array<string|int, mixed>
swapIndexes()  : Task
update()  : Task
updateChat()  : Task
updateDictionary()  : Task
updateDisplayedAttributes()  : Task
updateDistinctAttribute()  : Task
updateDocuments()  : Task
updateDocumentsByFunction()  : Task
This is an EXPERIMENTAL feature, which may break without a major version.
updateDocumentsCsv()  : Task
updateDocumentsCsvInBatches()  : array<int, Task>
updateDocumentsInBatches()  : array<int, Task>
updateDocumentsJson()  : Task
updateDocumentsNdjson()  : Task
updateDocumentsNdjsonInBatches()  : array<int, Task>
updateEmbedders()  : Task
updateFaceting()  : Task
updateFacetSearch()  : Task
updateFilterableAttributes()  : Task
updateLocalizedAttributes()  : Task
updateNonSeparatorTokens()  : Task
updatePagination()  : Task
updatePrefixSearch()  : Task
updateProximityPrecision()  : Task
updateRankingRules()  : Task
updateSearchableAttributes()  : Task
updateSearchCutoffMs()  : Task
updateSeparatorTokens()  : Task
updateSettings()  : Task
updateSortableAttributes()  : Task
updateStopWords()  : Task
updateSynonyms()  : Task
updateTypoTolerance()  : Task
fill()  : $this
newInstance()  : self
batch()  : Generator
batchCsvString()  : Generator
batchNdjsonString()  : Generator

Constants

PATH

protected mixed PATH = '/indexes'

Properties

$createdAt

private DateTimeInterface|null $createdAt

$primaryKey

private string|null $primaryKey

$updatedAt

private DateTimeInterface|null $updatedAt

Methods

__construct()

public __construct(Http $http[, string|null $uid = null ][, string|null $primaryKey = null ][, DateTimeInterface|null $createdAt = null ][, DateTimeInterface|null $updatedAt = null ]) : mixed
Parameters
$http : Http
$uid : string|null = null
$primaryKey : string|null = null
$createdAt : DateTimeInterface|null = null
$updatedAt : DateTimeInterface|null = null

addDocuments()

public addDocuments(array<string|int, mixed> $documents[, string|null $primaryKey = null ]) : Task
Parameters
$documents : array<string|int, mixed>
$primaryKey : string|null = null
Return values
Task

addDocumentsCsv()

public addDocumentsCsv(string $documents[, string|null $primaryKey = null ][, string|null $delimiter = null ]) : Task
Parameters
$documents : string
$primaryKey : string|null = null
$delimiter : string|null = null
Return values
Task

addDocumentsCsvInBatches()

public addDocumentsCsvInBatches(string $documents[, int|null $batchSize = 1000 ][, string|null $primaryKey = null ][, string|null $delimiter = null ]) : array<int, Task>
Parameters
$documents : string
$batchSize : int|null = 1000
$primaryKey : string|null = null
$delimiter : string|null = null
Return values
array<int, Task>

addDocumentsInBatches()

public addDocumentsInBatches(array<string|int, mixed> $documents[, int|null $batchSize = 1000 ][, string|null $primaryKey = null ]) : array<int, Task>
Parameters
$documents : array<string|int, mixed>
$batchSize : int|null = 1000
$primaryKey : string|null = null
Return values
array<int, Task>

addDocumentsJson()

public addDocumentsJson(string $documents[, string|null $primaryKey = null ]) : Task
Parameters
$documents : string
$primaryKey : string|null = null
Return values
Task

addDocumentsNdjson()

public addDocumentsNdjson(string $documents[, string|null $primaryKey = null ]) : Task
Parameters
$documents : string
$primaryKey : string|null = null
Return values
Task

addDocumentsNdjsonInBatches()

public addDocumentsNdjsonInBatches(string $documents[, int|null $batchSize = 1000 ][, string|null $primaryKey = null ]) : array<int, Task>
Parameters
$documents : string
$batchSize : int|null = 1000
$primaryKey : string|null = null
Return values
array<int, Task>

allRaw()

public allRaw([array<string|int, mixed> $options = [] ]) : array<string|int, mixed>
Parameters
$options : array<string|int, mixed> = []
Return values
array<string|int, mixed>

create()

public create(string $uid[, array<string|int, mixed> $options = [] ]) : Task
Parameters
$uid : string
$options : array<string|int, mixed> = []
Tags
throws
Exception|ApiException
Return values
Task

deleteDocument()

public deleteDocument(string|int $documentId) : Task
Parameters
$documentId : string|int
Return values
Task

deleteDocuments()

public deleteDocuments(array<string|int, mixed> $options) : Task
Parameters
$options : array<string|int, mixed>
Return values
Task

fetchInfo()

public fetchInfo() : self
Return values
self

fetchPrimaryKey()

public fetchPrimaryKey() : string|null
Return values
string|null

fetchRawInfo()

public fetchRawInfo() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|null

getChat()

public getChat() : array<string|int, mixed>
Tags
since

Meilisearch v1.15.1

Return values
array<string|int, mixed>

getCreatedAt()

public getCreatedAt() : DateTimeInterface|null
Return values
DateTimeInterface|null

getDictionary()

public getDictionary() : array<int, non-empty-string>
Return values
array<int, non-empty-string>

getDisplayedAttributes()

public getDisplayedAttributes() : array<int, non-empty-string>
Return values
array<int, non-empty-string>

getDistinctAttribute()

public getDistinctAttribute() : non-empty-string|null
Return values
non-empty-string|null

getDocument()

public getDocument(non-empty-string|int $documentId[, array<string|int, mixed>|null $fields = null ]) : array<string|int, mixed>
Parameters
$documentId : non-empty-string|int
$fields : array<string|int, mixed>|null = null
Return values
array<string|int, mixed>

getEmbedders()

public getEmbedders() : array<string|int, mixed>|null
Tags
since

Meilisearch v1.13.0

Return values
array<string|int, mixed>|null

getFaceting()

public getFaceting() : array{maxValuesPerFacet: int, sortFacetValuesBy: array}
Return values
array{maxValuesPerFacet: int, sortFacetValuesBy: array}

getFacetSearch()

public getFacetSearch() : bool
Tags
since

Meilisearch v1.12.0

Return values
bool

getFilterableAttributes()

public getFilterableAttributes() : array<int, non-empty-string|array{attributePatterns: list, features?: array{facetSearch: bool, filter: array{equality: bool, comparison: bool}}}>
Return values
array<int, non-empty-string|array{attributePatterns: list, features?: array{facetSearch: bool, filter: array{equality: bool, comparison: bool}}}>

getLocalizedAttributes()

public getLocalizedAttributes() : array<int, array{attributePatterns: list, locales: list}>|null
Return values
array<int, array{attributePatterns: list, locales: list}>|null

getNonSeparatorTokens()

public getNonSeparatorTokens() : array<int, non-empty-string>
Return values
array<int, non-empty-string>

getPagination()

public getPagination() : array{maxTotalHits: positive-int}
Return values
array{maxTotalHits: positive-int}

getPrefixSearch()

public getPrefixSearch() : "indexingTime"|"disabled"
Tags
since

Meilisearch v1.12.0

Return values
"indexingTime"|"disabled"

getPrimaryKey()

public getPrimaryKey() : string|null
Return values
string|null

getProximityPrecision()

public getProximityPrecision() : "byWord"|"byAttribute"
Return values
"byWord"|"byAttribute"

getRankingRules()

public getRankingRules() : array<int, non-empty-string>
Return values
array<int, non-empty-string>

getSearchableAttributes()

public getSearchableAttributes() : array<int, non-empty-string>
Return values
array<int, non-empty-string>

getSearchCutoffMs()

public getSearchCutoffMs() : int|null
Return values
int|null

getSeparatorTokens()

public getSeparatorTokens() : array<string|int, mixed>
Return values
array<string|int, mixed>

getSettings()

public getSettings() : array<string|int, mixed>
Return values
array<string|int, mixed>

getSortableAttributes()

public getSortableAttributes() : array<int, non-empty-string>
Return values
array<int, non-empty-string>

getStopWords()

public getStopWords() : array<int, non-empty-string>
Return values
array<int, non-empty-string>

getSynonyms()

public getSynonyms() : array<non-empty-string, array<int, non-empty-string>>
Return values
array<non-empty-string, array<int, non-empty-string>>

getTask()

public getTask(int $uid) : Task
Parameters
$uid : int
Return values
Task

getTypoTolerance()

public getTypoTolerance() : array{enabled: bool, minWordSizeForTypos: array{oneTypo: int, twoTypos: int}, disableOnWords: list, disableOnAttributes: list, disableOnNumbers: bool}
Return values
array{enabled: bool, minWordSizeForTypos: array{oneTypo: int, twoTypos: int}, disableOnWords: list, disableOnAttributes: list, disableOnNumbers: bool}

getUid()

public getUid() : string|null
Return values
string|null

getUpdatedAt()

public getUpdatedAt() : DateTimeInterface|null
Return values
DateTimeInterface|null

rawSearch()

public rawSearch(string|null $query[, array<string|int, mixed> $searchParams = [] ]) : array<string|int, mixed>
Parameters
$query : string|null
$searchParams : array<string|int, mixed> = []
Return values
array<string|int, mixed>
public search(string|null $query[, array<string|int, mixed> $searchParams = [] ][, array<string|int, mixed> $options = [] ]) : SearchResult|array<string|int, mixed>
Parameters
$query : string|null
$searchParams : array<string|int, mixed> = []
$options : array<string|int, mixed> = []
Tags
phpstan-return

($options is array{raw: true|non-falsy-string|positive-int} ? array : SearchResult)

Return values
SearchResult|array<string|int, mixed>

show()

public show() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|null

stats()

public stats() : array<string|int, mixed>
Return values
array<string|int, mixed>

swapIndexes()

public swapIndexes(array<string|int, array{indexes: mixed}> $indexes) : Task
Parameters
$indexes : array<string|int, array{indexes: mixed}>
Return values
Task

update()

public update(array<string|int, mixed> $body) : Task
Parameters
$body : array<string|int, mixed>
Return values
Task

updateChat()

public updateChat(array<string|int, mixed> $chatSettings) : Task
Parameters
$chatSettings : array<string|int, mixed>
Tags
since

Meilisearch v1.15.1

Return values
Task

updateDictionary()

public updateDictionary(array<int, non-empty-string> $wordDictionary) : Task
Parameters
$wordDictionary : array<int, non-empty-string>
Return values
Task

updateDisplayedAttributes()

public updateDisplayedAttributes(array<int, non-empty-string> $displayedAttributes) : Task
Parameters
$displayedAttributes : array<int, non-empty-string>
Return values
Task

updateDistinctAttribute()

public updateDistinctAttribute(non-empty-string $distinctAttribute) : Task
Parameters
$distinctAttribute : non-empty-string
Return values
Task

updateDocuments()

public updateDocuments(array<string|int, mixed> $documents[, string|null $primaryKey = null ]) : Task
Parameters
$documents : array<string|int, mixed>
$primaryKey : string|null = null
Return values
Task

updateDocumentsByFunction()

This is an EXPERIMENTAL feature, which may break without a major version.

public updateDocumentsByFunction(non-empty-string $function[, array{filter?: non-empty-string|list|null, context?: array$options = [] ]) : Task

It's available after Meilisearch v1.10.

More info about the feature: https://github.com/orgs/meilisearch/discussions/762 More info about experimental features in general: https://www.meilisearch.com/docs/reference/api/experimental-features

Parameters
$function : non-empty-string
$options : array{filter?: non-empty-string|list|null, context?: array} = []
Return values
Task

updateDocumentsCsv()

public updateDocumentsCsv(string $documents[, string|null $primaryKey = null ][, string|null $delimiter = null ]) : Task
Parameters
$documents : string
$primaryKey : string|null = null
$delimiter : string|null = null
Return values
Task

updateDocumentsCsvInBatches()

public updateDocumentsCsvInBatches(string $documents[, int|null $batchSize = 1000 ][, string|null $primaryKey = null ][, string|null $delimiter = null ]) : array<int, Task>
Parameters
$documents : string
$batchSize : int|null = 1000
$primaryKey : string|null = null
$delimiter : string|null = null
Return values
array<int, Task>

updateDocumentsInBatches()

public updateDocumentsInBatches(array<string|int, mixed> $documents[, int|null $batchSize = 1000 ][, string|null $primaryKey = null ]) : array<int, Task>
Parameters
$documents : array<string|int, mixed>
$batchSize : int|null = 1000
$primaryKey : string|null = null
Return values
array<int, Task>

updateDocumentsJson()

public updateDocumentsJson(string $documents[, string|null $primaryKey = null ]) : Task
Parameters
$documents : string
$primaryKey : string|null = null
Return values
Task

updateDocumentsNdjson()

public updateDocumentsNdjson(string $documents[, string|null $primaryKey = null ]) : Task
Parameters
$documents : string
$primaryKey : string|null = null
Return values
Task

updateDocumentsNdjsonInBatches()

public updateDocumentsNdjsonInBatches(string $documents[, int|null $batchSize = 1000 ][, string|null $primaryKey = null ]) : array<int, Task>
Parameters
$documents : string
$batchSize : int|null = 1000
$primaryKey : string|null = null
Return values
array<int, Task>

updateEmbedders()

public updateEmbedders(array<string|int, mixed> $embedders) : Task
Parameters
$embedders : array<string|int, mixed>
Tags
since

Meilisearch v1.13.0

Return values
Task

updateFaceting()

public updateFaceting(array{maxValuesPerFacet?: int, sortFacetValuesBy?: array$faceting) : Task
Parameters
$faceting : array{maxValuesPerFacet?: int, sortFacetValuesBy?: array}
Return values
Task

updateFacetSearch()

public updateFacetSearch(bool $facetSearch) : Task
Parameters
$facetSearch : bool
Tags
since

Meilisearch v1.12.0

Return values
Task

updateFilterableAttributes()

public updateFilterableAttributes(array<int, non-empty-string|array{attributePatterns: list, features?: array{facetSearch: bool, filter: array{equality: bool, comparison: bool}}}> $filterableAttributes) : Task
Parameters
$filterableAttributes : array<int, non-empty-string|array{attributePatterns: list, features?: array{facetSearch: bool, filter: array{equality: bool, comparison: bool}}}>

Note: When attributePatterns contains '_geo', the features field is ignored

Return values
Task

updateLocalizedAttributes()

public updateLocalizedAttributes(array<int, array{attributePatterns: list, locales: list}> $localizedAttributes) : Task
Parameters
$localizedAttributes : array<int, array{attributePatterns: list, locales: list}>
Return values
Task

updateNonSeparatorTokens()

public updateNonSeparatorTokens(array<int, non-empty-string> $nonSeparatorTokens) : Task
Parameters
$nonSeparatorTokens : array<int, non-empty-string>
Return values
Task

updatePagination()

public updatePagination(array{maxTotalHits: positive-int} $pagination) : Task
Parameters
$pagination : array{maxTotalHits: positive-int}
Return values
Task

updatePrefixSearch()

public updatePrefixSearch("indexingTime"|"disabled" $prefixSearch) : Task
Parameters
$prefixSearch : "indexingTime"|"disabled"
Tags
since

Meilisearch v1.12.0

Return values
Task

updateProximityPrecision()

public updateProximityPrecision("byWord"|"byAttribute" $type) : Task
Parameters
$type : "byWord"|"byAttribute"
Return values
Task

updateRankingRules()

public updateRankingRules(array<int, non-empty-string> $rankingRules) : Task
Parameters
$rankingRules : array<int, non-empty-string>
Return values
Task

updateSearchableAttributes()

public updateSearchableAttributes(array<int, non-empty-string> $searchableAttributes) : Task
Parameters
$searchableAttributes : array<int, non-empty-string>
Return values
Task

updateSearchCutoffMs()

public updateSearchCutoffMs(int $value) : Task
Parameters
$value : int
Return values
Task

updateSeparatorTokens()

public updateSeparatorTokens(array<int, non-empty-string> $separatorTokens) : Task
Parameters
$separatorTokens : array<int, non-empty-string>
Return values
Task

updateSettings()

public updateSettings(mixed $settings) : Task
Parameters
$settings : mixed
Return values
Task

updateSortableAttributes()

public updateSortableAttributes(array<int, non-empty-string> $sortableAttributes) : Task
Parameters
$sortableAttributes : array<int, non-empty-string>
Return values
Task

updateStopWords()

public updateStopWords(array<int, non-empty-string> $stopWords) : Task
Parameters
$stopWords : array<int, non-empty-string>
Return values
Task

updateSynonyms()

public updateSynonyms(array<non-empty-string, array<int, non-empty-string>> $synonyms) : Task
Parameters
$synonyms : array<non-empty-string, array<int, non-empty-string>>
Return values
Task

updateTypoTolerance()

public updateTypoTolerance(array{enabled: bool, minWordSizeForTypos: array{oneTypo: int, twoTypos: int}, disableOnWords: list, disableOnAttributes: list, disableOnNumbers: bool} $typoTolerance) : Task
Parameters
$typoTolerance : array{enabled: bool, minWordSizeForTypos: array{oneTypo: int, twoTypos: int}, disableOnWords: list, disableOnAttributes: list, disableOnNumbers: bool}
Return values
Task

fill()

protected fill(array<string|int, mixed> $attributes) : $this
Parameters
$attributes : array<string|int, mixed>
Return values
$this

newInstance()

protected newInstance(array<string|int, mixed> $attributes) : self
Parameters
$attributes : array<string|int, mixed>
Return values
self

batch()

private static batch(array<string|int, mixed> $documents, int $batchSize) : Generator
Parameters
$documents : array<string|int, mixed>
$batchSize : int
Return values
Generator

batchCsvString()

private static batchCsvString(string $documents, int $batchSize) : Generator
Parameters
$documents : string
$batchSize : int
Return values
Generator

batchNdjsonString()

private static batchNdjsonString(string $documents, int $batchSize) : Generator
Parameters
$documents : string
$batchSize : int
Return values
Generator

        
On this page

Search results