setSettings() public method

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
return mixed
 /**
  * AlgoliaSearchEngine constructor.
  * @param \AlgoliaSearch\Client $client
  * @param $index
  */
 public function __construct(\AlgoliaSearch\Client $client, $index, $clearOnSync)
 {
     $this->client = $client;
     $this->index = $client->initIndex($index);
     $this->clearOnSync = $clearOnSync;
     $this->index->setSettings(array("attributesToIndex" => array("content", "title", "categories", "tags"), "attributesForFaceting" => array("categories", "tags")));
 }
Beispiel #2
0
 /**
  * Configure settings on the Algolia index.
  *
  * @return void
  */
 public function setSettings()
 {
     $this->index->setSettings(['attributesToIndex' => ['unordered(h1)', 'unordered(h2)', 'unordered(h3)', 'unordered(h4)', 'unordered(content)'], 'attributesToHighlight' => ['h1', 'h2', 'h3', 'h4', 'content'], 'attributesToRetrieve' => ['h1', 'h2', 'h3', 'h4', '_tags', 'link'], 'customRanking' => ['asc(importance)'], 'ranking' => ['words', 'typo', 'attribute', 'proximity', 'exact', 'custom'], 'minWordSizefor1Typo' => 3, 'minWordSizefor2Typos' => 7, 'allowTyposOnNumericTokens' => false, 'minProximity' => 2, 'ignorePlurals' => true, 'advancedSyntax' => true, 'removeWordsIfNoResults' => 'allOptional']);
 }
 /**
  * @param Client $client
  * @param string $indexName
  */
 public function __construct(Client $client, $indexName)
 {
     $this->index = $client->initIndex($indexName);
     $this->index->setSettings(array("attributesToIndex" => array("title", "tags", "unordered(body)"), 'attributesForFaceting' => array('tags')));
 }