PHP 클래스 AlgoliaSearch\Index

파일 보기 프로젝트 열기: algolia/algoliasearch-client-php 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$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