diff --git a/website/docs/api-clients/guides/filtering-your-search.mdx b/website/docs/api-clients/guides/filtering-your-search.mdx index 0d5b1a4251..180aff3fed 100644 --- a/website/docs/api-clients/guides/filtering-your-search.mdx +++ b/website/docs/api-clients/guides/filtering-your-search.mdx @@ -17,7 +17,8 @@ Initially, filter attributes must be defined as facets, using the `attributesFor groupId="language" defaultValue="js" values={[ - { label: 'JavaScript', value: 'js', } + { label: 'JavaScript', value: 'js', }, + { label: 'PHP', value: 'php', } ] }> @@ -35,6 +36,15 @@ await client.setSettings({ }); ``` + + + +```php +$client->setSettings( + '', + ['attributesForFaceting' => ['actor', 'filterOnly(category)', 'searchable(publisher)']] +); +``` @@ -48,7 +58,8 @@ The actual filtering of records is performed at query time, not at indexing time groupId="language" defaultValue="js" values={[ - { label: 'JavaScript', value: 'js', } + { label: 'JavaScript', value: 'js', }, + { label: 'PHP', value: 'php', } ] }> @@ -82,6 +93,38 @@ await client.search({ }); ``` + + + +```php +// Only "Scarlett Johansson" actor +$client->search( + '', + [ + 'query' => '', + 'filters' => 'actor:Scarlett Johansson', + ] +); + +// Only "Tom Cruise" or "Scarlett Johansson" actor +$client->search( + '', + [ + 'query' => '', + 'filters' => 'actor:Tom Cruise OR actor:Scarlett Johansson', + ] +); + +// Everything but "Nicolas Cage" actor +$client->search( + '', + [ + 'query' => '', + 'filters' => 'NOT actor:Nicolas Cage', + ] +); + +``` @@ -91,7 +134,8 @@ await client.search({ groupId="language" defaultValue="js" values={[ - { label: 'JavaScript', value: 'js', } + { label: 'JavaScript', value: 'js', }, + { label: 'PHP', value: 'php', } ] }> @@ -116,5 +160,27 @@ await client.search({ }); ``` + + + +```php +// Only "Scarlett Johansson" actor +$client->search( + '', + [ + 'query' => '', + 'facetFilters' => ['actor:Scarlett Johansson'], + ] +); + +// Only "Tom Cruise" or "Scarlett Johansson" actor +$client->search( + '', + [ + 'query' => '', + 'facetFilters' => ['actor:Tom Cruise', 'actor:Scarlett Johansson'], + ] +); +``` diff --git a/website/docs/api-clients/guides/retrieving-facets.mdx b/website/docs/api-clients/guides/retrieving-facets.mdx index 4a56798f51..6b54580c84 100644 --- a/website/docs/api-clients/guides/retrieving-facets.mdx +++ b/website/docs/api-clients/guides/retrieving-facets.mdx @@ -15,7 +15,8 @@ For example, you can retrieve your books' facets with the `search` method, and t groupId="language" defaultValue="js" values={[ - { label: 'JavaScript', value: 'js', } + { label: 'JavaScript', value: 'js', }, + { label: 'PHP', value: 'php', } ] }> @@ -42,5 +43,31 @@ await client.search({ }); ``` + + + + +```php +$client->search( + '', + [ + 'query' => '', + 'facets' => ['author', 'genre'], + ] +); +``` + +To extract all facet information, you can use a wildcard (`*`). + +```php +$client->search( + '', + [ + 'query' => '', + 'facets' => ['*'], + ] +); +``` + diff --git a/website/docs/api-clients/guides/send-data-to-algolia.mdx b/website/docs/api-clients/guides/send-data-to-algolia.mdx index 8a29fa77d8..8901912964 100644 --- a/website/docs/api-clients/guides/send-data-to-algolia.mdx +++ b/website/docs/api-clients/guides/send-data-to-algolia.mdx @@ -21,7 +21,8 @@ To push data to Algolia, you need an Application ID and a valid API key with the groupId="language" defaultValue="js" values={[ - { label: 'JavaScript', value: 'js', } + { label: 'JavaScript', value: 'js', }, + { label: 'PHP', value: 'php', } ] }> @@ -36,6 +37,16 @@ import { algoliasearch } from '@experimental-api-clients-automation/algoliasearc const client = algoliasearch('', ''); ``` + + + + ```php + ', + '' + ); + ``` @@ -47,7 +58,8 @@ Before sending anything to Algolia, you need to retrieve your data. You can do t groupId="language" defaultValue="js" values={[ - { label: 'JavaScript', value: 'js', } + { label: 'JavaScript', value: 'js', }, + { label: 'PHP', value: 'php', } ] }> @@ -55,11 +67,32 @@ Before sending anything to Algolia, you need to retrieve your data. You can do t ```js const records = [{ name: 'Tom Cruise' }, { name: 'Scarlett Johansson' }]; -client.saveObject({ - indexName: '', - // Accepts a free form `Record` object. - body: records, -}); +for (const record of records) { + client.saveObject({ + indexName: '', + // Accepts a free form `Record` object. + body: record, + }); +} + +``` + + + + +```php +$records = [ + ['name' => 'Tom Cruise'], + ['name' => 'Scarlett Johansson'] +]; + +foreach ($records as $record) { + $client->saveObject( + '', + $record + ); +} + ```