initIndex
Methods previously available at the initIndex level are now available at the root level of the API client. The indexName parameter is now required when calling those methods. | js import { algoliasearch } from 'algoliasearch'; const client = algoliasearch('<YOUR_APP_ID>', '<YOUR_API_KEY>'); const searchResults2 = await client.search({ requests: [ { indexName: '<YOUR_INDEX_NAME>', query: '<YOUR_QUERY>', attributesToRetrieve: ['firstname', 'lastname'], hitsPerPage: 50, }, ], });
js import { algoliasearch } from 'algoliasearch'; const client = algoliasearch('<YOUR_APP_ID>', '<YOUR_API_KEY>'); const searchResults2 = await client.search({ requests: [ { indexName: '<YOUR_INDEX_NAME>', query: '<YOUR_QUERY>', attributesToRetrieve: ['firstname', 'lastname'], hitsPerPage: 50, }, ], });
php $client = Algolia\AlgoliaSearch\Api\SearchClient::create( '<YOUR_APP_ID>', '<YOUR_API_KEY>' ); $client->search([ 'requests' => [ [ 'indexName' => '<YOUR_INDEX_NAME>', 'query' => '<YOUR_QUERY>', 'attributesToRetrieve' => ['firstname', 'lastname'], 'hitsPerPage': 50, ], ], ]);
php $client = Algolia\AlgoliaSearch\Api\SearchClient::create( '<YOUR_APP_ID>', '<YOUR_API_KEY>' ); $client->search([ 'requests' => [ [ 'indexName' => '<YOUR_INDEX_NAME>', 'query' => '<YOUR_QUERY>', 'attributesToRetrieve' => ['firstname', 'lastname'], 'hitsPerPage': 50, ], ], ]);
java import com.algolia.model.search.*; SearchClient client = new SearchClient( "<YOUR_APP_ID>", "<YOUR_API_KEY>" ); client.search( new SearchMethodParams() .addRequests(SearchQuery.of( new SearchForHits() .setIndexName("<YOUR_INDEX_NAME>") .setQuery("<YOUR_QUERY>") .addAttributesToRetrieve("firstname") .addAttributesToRetrieve("lastname") .setHitsPerPage(50) ) ) );
java import com.algolia.model.search.*; SearchClient client = new SearchClient( "<YOUR_APP_ID>", "<YOUR_API_KEY>" ); client.search( new SearchMethodParams() .addRequests(SearchQuery.of( new SearchForHits() .setIndexName("<YOUR_INDEX_NAME>") .setQuery("<YOUR_QUERY>") .addAttributesToRetrieve("firstname") .addAttributesToRetrieve("lastname") .setHitsPerPage(50) ) ) );
|