PHP Класс AlgoliaSearch\Index

Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$indexName string

Открытые методы

Метод Описание
__call ( string $name, array $arguments ) : mixed
__construct ( ClientContext $context, Client $client, string $indexName ) Index initialization (You should not instantiate this yourself).
addObject ( array $content, string | null $objectID = null ) : mixed Add an object in this index.
addObjects ( array $objects, string $objectIDKey = 'objectID' ) : mixed Add several objects.
addUserKey ( array $obj, integer $validity, integer $maxQueriesPerIPPerHour, integer $maxHitsPerQuery ) : mixed Create a new user key associated to this index.
batch ( array $requests ) : mixed Send a batch request.
batchObjects ( array $objects, string $objectIDKey = 'objectID', string $objectActionKey = 'objectAction' ) : mixed Perform batch operation on several objects.
batchSynonyms ( $objects, boolean $forwardToReplicas = false, boolean $replaceExistingSynonyms = false ) : mixed
browseFrom ( string $query, array | null $params = null, $cursor = null ) : mixed
clearIndex ( ) : mixed This function deletes the index content. Settings and index specific API keys are kept untouched.
clearSynonyms ( boolean $forwardToReplicas = false ) : mixed
deleteByQuery ( string $query, array $args = [], boolean $waitLastCall = true ) : integer Delete all objects matching a query.
deleteObject ( integer | string $objectID ) : mixed Delete an object from the index.
deleteObjects ( array $objects ) : mixed Delete several objects.
deleteSynonym ( $objectID, $forwardToReplicas = false ) : mixed
deleteUserKey ( string $key ) : mixed Delete an existing user key associated to this index.
getObject ( $objectID, $attributesToRetrieve = null ) : mixed Get an object from this index.
getObjects ( array $objectIDs ) : mixed Get several objects from this index.
getSettings ( ) : mixed Get settings of this index.
getSynonym ( $objectID ) : mixed
getTaskStatus ( string $taskID ) : mixed get the status of a task on the server.
getUserKeyACL ( string $key ) : mixed Get ACL of a user key associated to this index.
listUserKeys ( ) : mixed List all existing user keys associated to this index with their associated ACLs.
partialUpdateObject ( array $partialObject, boolean $createIfNotExists = true ) : mixed Update partially an object (only update attributes passed in argument).
partialUpdateObjects ( array $objects, string $objectIDKey = 'objectID', boolean $createIfNotExists = true ) : mixed Partially Override the content of several objects.
saveObject ( array $object, string $objectIDKey = 'objectID' ) : mixed Override the content of object.
saveObjects ( array $objects, string $objectIDKey = 'objectID' ) : mixed Override the content of several objects.
saveSynonym ( $objectID, $content, boolean $forwardToReplicas = false ) : mixed
search ( string $query, mixed $args = null ) : mixed Search inside the index.
searchDisjunctiveFaceting ( string $query, array $disjunctive_facets, array $params = [], array $refinements = [] ) : mixed Perform a search with disjunctive facets generating as many queries as number of disjunctive facets.
searchFacet ( $facetName, $facetQuery, array $query = [] ) : mixed Perform a search inside facets.
searchSynonyms ( $query, array $synonymType = [], null $page = null, null $hitsPerPage = null ) : mixed
setSettings ( mixed $settings, boolean $forwardToReplicas = false ) : mixed Set settings for this index.
updateUserKey ( string $key, array $obj, integer $validity, integer $maxQueriesPerIPPerHour, integer $maxHitsPerQuery ) : mixed Update a user key associated to this index.
waitTask ( string $taskID, integer $timeBeforeRetry = 100 ) : mixed Wait the publication of a task on the server.

Приватные методы

Метод Описание
buildBatch ( string $action, array $objects, string $withObjectID, string $objectIDKey = 'objectID' ) : array Build a batch request.
doBcBrowse ( integer $page, integer $hitsPerPage = 1000 ) : mixed Browse all index content.
doBrowse ( string $query, array | null $params = null ) : IndexBrowser

Описание методов

__call() публичный Метод

public __call ( string $name, array $arguments ) : mixed
$name string
$arguments array
Результат mixed

__construct() публичный Метод

Index initialization (You should not instantiate this yourself).
public __construct ( ClientContext $context, Client $client, string $indexName )
$context ClientContext
$client Client
$indexName string

addObject() публичный Метод

Add an object in this index.
public addObject ( array $content, string | null $objectID = null ) : mixed
$content array contains the object to add inside the index. The object is represented by an associative array
$objectID string | null (optional) an objectID you want to attribute to this object (if the attribute already exist the old object will be overwrite)
Результат mixed

addObjects() публичный Метод

Add several objects.
public addObjects ( array $objects, string $objectIDKey = 'objectID' ) : mixed
$objects array contains an array of objects to add. If the object contains an objectID
$objectIDKey string
Результат mixed

addUserKey() публичный Метод

Create a new user key associated to this index.
public addUserKey ( array $obj, integer $validity, integer $maxQueriesPerIPPerHour, integer $maxHitsPerQuery ) : mixed
$obj array can be two different parameters: The list of parameters for this key. Defined by a array that can contains the following values: - acl: array of string - indices: array of string - validity: int - referers: array of string - description: string - maxHitsPerQuery: integer - queryParameters: string - maxQueriesPerIPPerHour: integer Or the list of ACL for this key. Defined by an array of NSString that can contains the following values: - search: allow to search (https and http) - addObject: allows to add/update an object in the index (https only) - deleteObject : allows to delete an existing object (https only) - deleteIndex : allows to delete index content (https only) - settings : allows to get index settings (https only) - editSettings : allows to change index settings (https only)
$validity integer the number of seconds after which the key will be automatically removed (0 means no time limit for this key)
$maxQueriesPerIPPerHour integer Specify the maximum number of API calls allowed from an IP address per hour. Defaults to 0 (no rate limit).
$maxHitsPerQuery integer Specify the maximum number of hits this API key can retrieve in one call. Defaults to 0 (unlimited)
Результат mixed

batch() публичный Метод

Send a batch request.
public batch ( array $requests ) : mixed
$requests array an associative array defining the batch request body
Результат mixed

batchObjects() публичный Метод

Perform batch operation on several objects.
public batchObjects ( array $objects, string $objectIDKey = 'objectID', string $objectActionKey = 'objectAction' ) : mixed
$objects array contains an array of objects to update (each object must contains an objectID attribute)
$objectIDKey string the key in each object that contains the objectID
$objectActionKey string the key in each object that contains the action to perform (addObject, updateObject, deleteObject or partialUpdateObject)
Результат mixed

batchSynonyms() публичный Метод

public batchSynonyms ( $objects, boolean $forwardToReplicas = false, boolean $replaceExistingSynonyms = false ) : mixed
$objects
$forwardToReplicas boolean
$replaceExistingSynonyms boolean
Результат mixed

browseFrom() публичный Метод

public browseFrom ( string $query, array | null $params = null, $cursor = null ) : mixed
$query string
$params array | null
$cursor
Результат mixed

clearIndex() публичный Метод

This function deletes the index content. Settings and index specific API keys are kept untouched.
public clearIndex ( ) : mixed
Результат mixed

clearSynonyms() публичный Метод

public clearSynonyms ( boolean $forwardToReplicas = false ) : mixed
$forwardToReplicas boolean
Результат mixed

deleteByQuery() публичный Метод

Delete all objects matching a query.
public deleteByQuery ( string $query, array $args = [], boolean $waitLastCall = true ) : integer
$query string the query string
$args array the optional query parameters
$waitLastCall boolean /!\ Be safe with "waitLastCall" In really rare cases you can have the number of hits smaller than the hitsPerPage param if you trigger the timeout of the search, in that case you won't remove all the records
Результат integer the number of delete operations

deleteObject() публичный Метод

Delete an object from the index.
public deleteObject ( integer | string $objectID ) : mixed
$objectID integer | string the unique identifier of object to delete
Результат mixed

deleteObjects() публичный Метод

Delete several objects.
public deleteObjects ( array $objects ) : mixed
$objects array contains an array of objectIDs to delete. If the object contains an objectID
Результат mixed

deleteSynonym() публичный Метод

public deleteSynonym ( $objectID, $forwardToReplicas = false ) : mixed
$objectID
$forwardToReplicas
Результат mixed

deleteUserKey() публичный Метод

Delete an existing user key associated to this index.
public deleteUserKey ( string $key ) : mixed
$key string
Результат mixed

getObject() публичный Метод

Get an object from this index.
public getObject ( $objectID, $attributesToRetrieve = null ) : mixed
$objectID the unique identifier of the object to retrieve
$attributesToRetrieve (optional) if set, contains the list of attributes to retrieve as a string separated by ","
Результат mixed

getObjects() публичный Метод

Get several objects from this index.
public getObjects ( array $objectIDs ) : mixed
$objectIDs array the array of unique identifier of objects to retrieve
Результат mixed

getSettings() публичный Метод

Get settings of this index.
public getSettings ( ) : mixed
Результат mixed

getSynonym() публичный Метод

public getSynonym ( $objectID ) : mixed
$objectID
Результат mixed

getTaskStatus() публичный Метод

All server task are asynchronous and you can check with this method that the task is published or not.
public getTaskStatus ( string $taskID ) : mixed
$taskID string the id of the task returned by server
Результат mixed

getUserKeyACL() публичный Метод

Get ACL of a user key associated to this index.
public getUserKeyACL ( string $key ) : mixed
$key string
Результат mixed

listUserKeys() публичный Метод

List all existing user keys associated to this index with their associated ACLs.
public listUserKeys ( ) : mixed
Результат mixed

partialUpdateObject() публичный Метод

Update partially an object (only update attributes passed in argument).
public partialUpdateObject ( array $partialObject, boolean $createIfNotExists = true ) : mixed
$partialObject array contains the object attributes to override, the object must contains an objectID attribute
$createIfNotExists boolean
Результат mixed

partialUpdateObjects() публичный Метод

Partially Override the content of several objects.
public partialUpdateObjects ( array $objects, string $objectIDKey = 'objectID', boolean $createIfNotExists = true ) : mixed
$objects array contains an array of objects to update (each object must contains a objectID attribute)
$objectIDKey string
$createIfNotExists boolean
Результат mixed

saveObject() публичный Метод

Override the content of object.
public saveObject ( array $object, string $objectIDKey = 'objectID' ) : mixed
$object array contains the object to save, the object must contains an objectID attribute or attribute specified in $objectIDKey considered as objectID
$objectIDKey string
Результат mixed

saveObjects() публичный Метод

Override the content of several objects.
public saveObjects ( array $objects, string $objectIDKey = 'objectID' ) : mixed
$objects array contains an array of objects to update (each object must contains a objectID attribute)
$objectIDKey string
Результат mixed

saveSynonym() публичный Метод

public saveSynonym ( $objectID, $content, boolean $forwardToReplicas = false ) : mixed
$objectID
$content
$forwardToReplicas boolean
Результат mixed

searchDisjunctiveFaceting() публичный Метод

Perform a search with disjunctive facets generating as many queries as number of disjunctive facets.
public searchDisjunctiveFaceting ( string $query, array $disjunctive_facets, array $params = [], array $refinements = [] ) : mixed
$query string the query
$disjunctive_facets array the array of disjunctive facets
$params array a hash representing the regular query parameters
$refinements array a hash ("string" -> ["array", "of", "refined", "values"]) representing the current refinements ex: { "my_facet1" => ["my_value1", ["my_value2"], "my_disjunctive_facet1" => ["my_value1", "my_value2"] }
Результат mixed

searchFacet() публичный Метод

Perform a search inside facets.
public searchFacet ( $facetName, $facetQuery, array $query = [] ) : mixed
$facetName
$facetQuery
$query array
Результат mixed

searchSynonyms() публичный Метод

public searchSynonyms ( $query, array $synonymType = [], null $page = null, null $hitsPerPage = null ) : mixed
$query
$synonymType array
$page null
$hitsPerPage null
Результат mixed

setSettings() публичный Метод

Set settings for this index.
public setSettings ( mixed $settings, boolean $forwardToReplicas = false ) : mixed
$settings mixed the settings object that can contains : - minWordSizefor1Typo: (integer) the minimum number of characters to accept one typo (default = 3). - minWordSizefor2Typos: (integer) the minimum number of characters to accept two typos (default = 7). - hitsPerPage: (integer) the number of hits per page (default = 10). - attributesToRetrieve: (array of strings) default list of attributes to retrieve in objects. If set to null, all attributes are retrieved. - attributesToHighlight: (array of strings) default list of attributes to highlight. If set to null, all indexed attributes are highlighted. - attributesToSnippet**: (array of strings) default list of attributes to snippet alongside the number of words to return (syntax is attributeName:nbWords). By default no snippet is computed. If set to null, no snippet is computed. - searchableAttributes (formerly named attributesToIndex): (array of strings) the list of fields you want to index. If set to null, all textual and numerical attributes of your objects are indexed, but you should update it to get optimal results. This parameter has two important uses: - Limit the attributes to index: For example if you store a binary image in base64, you want to store it and be able to retrieve it but you don't want to search in the base64 string. - Control part of the ranking*: (see the ranking parameter for full explanation) Matches in attributes at the beginning of the list will be considered more important than matches in attributes further down the list. In one attribute, matching text at the beginning of the attribute will be considered more important than text after, you can disable this behavior if you add your attribute inside `unordered(AttributeName)`, for example searchableAttributes: ["title", "unordered(text)"]. - attributesForFaceting: (array of strings) The list of fields you want to use for faceting. All strings in the attribute selected for faceting are extracted and added as a facet. If set to null, no attribute is used for faceting. - attributeForDistinct: (string) The attribute name used for the Distinct feature. This feature is similar to the SQL "distinct" keyword: when enabled in query with the distinct=1 parameter, all hits containing a duplicate value for this attribute are removed from results. For example, if the chosen attribute is show_name and several hits have the same value for show_name, then only the best one is kept and others are removed. - ranking: (array of strings) controls the way results are sorted. We have six available criteria: - typo: sort according to number of typos, - geo: sort according to decreassing distance when performing a geo-location based search, - proximity: sort according to the proximity of query words in hits, - attribute: sort according to the order of attributes defined by searchableAttributes, - exact: - if the user query contains one word: sort objects having an attribute that is exactly the query word before others. For example if you search for the "V" TV show, you want to find it with the "V" query and avoid to have all popular TV show starting by the v letter before it. - if the user query contains multiple words: sort according to the number of words that matched exactly (and not as a prefix). - custom: sort according to a user defined formula set in **customRanking** attribute. The standard order is ["typo", "geo", "proximity", "attribute", "exact", "custom"] - customRanking: (array of strings) lets you specify part of the ranking. The syntax of this condition is an array of strings containing attributes prefixed by asc (ascending order) or desc (descending order) operator. For example `"customRanking" => ["desc(population)", "asc(name)"]` - queryType: Select how the query words are interpreted, it can be one of the following value: - prefixAll: all query words are interpreted as prefixes, - prefixLast: only the last word is interpreted as a prefix (default behavior), - prefixNone: no query word is interpreted as a prefix. This option is not recommended. - highlightPreTag: (string) Specify the string that is inserted before the highlighted parts in the query result (default to ""). - highlightPostTag: (string) Specify the string that is inserted after the highlighted parts in the query result (default to ""). - optionalWords: (array of strings) Specify a list of words that should be considered as optional when found in the query.
$forwardToReplicas boolean
Результат mixed

updateUserKey() публичный Метод

Update a user key associated to this index.
public updateUserKey ( string $key, array $obj, integer $validity, integer $maxQueriesPerIPPerHour, integer $maxHitsPerQuery ) : mixed
$key string
$obj array can be two different parameters: The list of parameters for this key. Defined by a array that can contains the following values: - acl: array of string - indices: array of string - validity: int - referers: array of string - description: string - maxHitsPerQuery: integer - queryParameters: string - maxQueriesPerIPPerHour: integer Or the list of ACL for this key. Defined by an array of NSString that can contains the following values: - search: allow to search (https and http) - addObject: allows to add/update an object in the index (https only) - deleteObject : allows to delete an existing object (https only) - deleteIndex : allows to delete index content (https only) - settings : allows to get index settings (https only) - editSettings : allows to change index settings (https only)
$validity integer the number of seconds after which the key will be automatically removed (0 means no time limit for this key)
$maxQueriesPerIPPerHour integer Specify the maximum number of API calls allowed from an IP address per hour. Defaults to 0 (no rate limit).
$maxHitsPerQuery integer Specify the maximum number of hits this API key can retrieve in one call. Defaults to 0 (unlimited)
Результат mixed

waitTask() публичный Метод

All server task are asynchronous and you can check with this method that the task is published.
public waitTask ( string $taskID, integer $timeBeforeRetry = 100 ) : mixed
$taskID string the id of the task returned by server
$timeBeforeRetry integer the time in milliseconds before retry (default = 100ms)
Результат mixed

Описание свойств

$indexName публичное свойство

public string $indexName
Результат string