diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/SearchQueries.java b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/SearchQueries.java deleted file mode 100644 index 12e9f3117b..0000000000 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/SearchQueries.java +++ /dev/null @@ -1,147 +0,0 @@ -package com.algolia.model.search; - -import com.google.gson.annotations.SerializedName; -import java.util.Objects; - -/** SearchQueries */ -public class SearchQueries { - - @SerializedName("indexName") - private String indexName; - - @SerializedName("query") - private String query = ""; - - @SerializedName("type") - private SearchType type = SearchType.DEFAULT; - - @SerializedName("facet") - private String facet; - - @SerializedName("params") - private SearchParams params; - - public SearchQueries setIndexName(String indexName) { - this.indexName = indexName; - return this; - } - - /** - * The Algolia index name. - * - * @return indexName - */ - @javax.annotation.Nonnull - public String getIndexName() { - return indexName; - } - - public SearchQueries setQuery(String query) { - this.query = query; - return this; - } - - /** - * The text to search in the index. - * - * @return query - */ - @javax.annotation.Nullable - public String getQuery() { - return query; - } - - public SearchQueries setType(SearchType type) { - this.type = type; - return this; - } - - /** - * Get type - * - * @return type - */ - @javax.annotation.Nullable - public SearchType getType() { - return type; - } - - public SearchQueries setFacet(String facet) { - this.facet = facet; - return this; - } - - /** - * The `facet` name. - * - * @return facet - */ - @javax.annotation.Nullable - public String getFacet() { - return facet; - } - - public SearchQueries setParams(SearchParams params) { - this.params = params; - return this; - } - - /** - * Get params - * - * @return params - */ - @javax.annotation.Nullable - public SearchParams getParams() { - return params; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - SearchQueries searchQueries = (SearchQueries) o; - return ( - Objects.equals(this.indexName, searchQueries.indexName) && - Objects.equals(this.query, searchQueries.query) && - Objects.equals(this.type, searchQueries.type) && - Objects.equals(this.facet, searchQueries.facet) && - Objects.equals(this.params, searchQueries.params) - ); - } - - @Override - public int hashCode() { - return Objects.hash(indexName, query, type, facet, params); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class SearchQueries {\n"); - sb - .append(" indexName: ") - .append(toIndentedString(indexName)) - .append("\n"); - sb.append(" query: ").append(toIndentedString(query)).append("\n"); - sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" facet: ").append(toIndentedString(facet)).append("\n"); - sb.append(" params: ").append(toIndentedString(params)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/SearchType.java b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/SearchType.java deleted file mode 100644 index 3f41b53b88..0000000000 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/SearchType.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.algolia.model.search; - -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; - -/** Perform a search query with `default`, will search for facet values if `facet` is given. */ -@JsonAdapter(SearchType.Adapter.class) -public enum SearchType { - DEFAULT("default"), - - FACET("facet"); - - private final String value; - - SearchType(String value) { - this.value = value; - } - - public String getValue() { - return value; - } - - @Override - public String toString() { - return String.valueOf(value); - } - - public static SearchType fromValue(String value) { - for (SearchType b : SearchType.values()) { - if (b.value.equals(value)) { - return b; - } - } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); - } - - public static class Adapter extends TypeAdapter { - - @Override - public void write( - final JsonWriter jsonWriter, - final SearchType enumeration - ) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public SearchType read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return SearchType.fromValue(value); - } - } -} diff --git a/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/searchQueries.ts b/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/searchQueries.ts deleted file mode 100644 index ffcc3805f7..0000000000 --- a/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/searchQueries.ts +++ /dev/null @@ -1,19 +0,0 @@ -import type { SearchParams } from './searchParams'; -import type { SearchType } from './searchType'; - -export type SearchQueries = { - /** - * The Algolia index name. - */ - indexName: string; - /** - * The text to search in the index. - */ - query?: string; - type?: SearchType; - /** - * The `facet` name. - */ - facet?: string; - params?: SearchParams; -}; diff --git a/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/searchType.ts b/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/searchType.ts deleted file mode 100644 index a6fb7e84f3..0000000000 --- a/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/searchType.ts +++ /dev/null @@ -1,4 +0,0 @@ -/** - * Perform a search query with `default`, will search for facet values if `facet` is given. - */ -export type SearchType = 'default' | 'facet'; diff --git a/clients/algoliasearch-client-javascript/packages/client-search/model/searchQueries.ts b/clients/algoliasearch-client-javascript/packages/client-search/model/searchQueries.ts deleted file mode 100644 index ffcc3805f7..0000000000 --- a/clients/algoliasearch-client-javascript/packages/client-search/model/searchQueries.ts +++ /dev/null @@ -1,19 +0,0 @@ -import type { SearchParams } from './searchParams'; -import type { SearchType } from './searchType'; - -export type SearchQueries = { - /** - * The Algolia index name. - */ - indexName: string; - /** - * The text to search in the index. - */ - query?: string; - type?: SearchType; - /** - * The `facet` name. - */ - facet?: string; - params?: SearchParams; -}; diff --git a/clients/algoliasearch-client-javascript/packages/client-search/model/searchType.ts b/clients/algoliasearch-client-javascript/packages/client-search/model/searchType.ts deleted file mode 100644 index a6fb7e84f3..0000000000 --- a/clients/algoliasearch-client-javascript/packages/client-search/model/searchType.ts +++ /dev/null @@ -1,4 +0,0 @@ -/** - * Perform a search query with `default`, will search for facet values if `facet` is given. - */ -export type SearchType = 'default' | 'facet'; diff --git a/clients/algoliasearch-client-php/lib/Model/Search/SearchQueries.php b/clients/algoliasearch-client-php/lib/Model/Search/SearchQueries.php deleted file mode 100644 index faf4009fc2..0000000000 --- a/clients/algoliasearch-client-php/lib/Model/Search/SearchQueries.php +++ /dev/null @@ -1,340 +0,0 @@ - 'string', - 'query' => 'string', - 'type' => '\Algolia\AlgoliaSearch\Model\Search\SearchType', - 'facet' => 'string', - 'params' => '\Algolia\AlgoliaSearch\Model\Search\SearchParams', - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $modelFormats = [ - 'indexName' => null, - 'query' => null, - 'type' => null, - 'facet' => null, - 'params' => null, - ]; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function modelTypes() - { - return self::$modelTypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function modelFormats() - { - return self::$modelFormats; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'indexName' => 'setIndexName', - 'query' => 'setQuery', - 'type' => 'setType', - 'facet' => 'setFacet', - 'params' => 'setParams', - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'indexName' => 'getIndexName', - 'query' => 'getQuery', - 'type' => 'getType', - 'facet' => 'getFacet', - 'params' => 'getParams', - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - */ - public function __construct(array $data = null) - { - if (isset($data['indexName'])) { - $this->container['indexName'] = $data['indexName']; - } - if (isset($data['query'])) { - $this->container['query'] = $data['query']; - } - if (isset($data['type'])) { - $this->container['type'] = $data['type']; - } - if (isset($data['facet'])) { - $this->container['facet'] = $data['facet']; - } - if (isset($data['params'])) { - $this->container['params'] = $data['params']; - } - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - if ( - !isset($this->container['indexName']) || - $this->container['indexName'] === null - ) { - $invalidProperties[] = "'indexName' can't be null"; - } - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - /** - * Gets indexName - * - * @return string - */ - public function getIndexName() - { - return $this->container['indexName'] ?? null; - } - - /** - * Sets indexName - * - * @param string $indexName the Algolia index name - * - * @return self - */ - public function setIndexName($indexName) - { - $this->container['indexName'] = $indexName; - - return $this; - } - - /** - * Gets query - * - * @return string|null - */ - public function getQuery() - { - return $this->container['query'] ?? null; - } - - /** - * Sets query - * - * @param string|null $query the text to search in the index - * - * @return self - */ - public function setQuery($query) - { - $this->container['query'] = $query; - - return $this; - } - - /** - * Gets type - * - * @return \Algolia\AlgoliaSearch\Model\Search\SearchType|null - */ - public function getType() - { - return $this->container['type'] ?? null; - } - - /** - * Sets type - * - * @param \Algolia\AlgoliaSearch\Model\Search\SearchType|null $type type - * - * @return self - */ - public function setType($type) - { - $this->container['type'] = $type; - - return $this; - } - - /** - * Gets facet - * - * @return string|null - */ - public function getFacet() - { - return $this->container['facet'] ?? null; - } - - /** - * Sets facet - * - * @param string|null $facet the `facet` name - * - * @return self - */ - public function setFacet($facet) - { - $this->container['facet'] = $facet; - - return $this; - } - - /** - * Gets params - * - * @return \Algolia\AlgoliaSearch\Model\Search\SearchParams|null - */ - public function getParams() - { - return $this->container['params'] ?? null; - } - - /** - * Sets params - * - * @param \Algolia\AlgoliaSearch\Model\Search\SearchParams|null $params params - * - * @return self - */ - public function setParams($params) - { - $this->container['params'] = $params; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param int $offset Offset - * - * @return bool - */ - public function offsetExists($offset) - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param int $offset Offset - * - * @return mixed|null - */ - public function offsetGet($offset) - { - return $this->container[$offset] ?? null; - } - - /** - * Sets value based on offset. - * - * @param int|null $offset Offset - * @param mixed $value Value to be set - * - * @return void - */ - public function offsetSet($offset, $value) - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param int $offset Offset - * - * @return void - */ - public function offsetUnset($offset) - { - unset($this->container[$offset]); - } -} diff --git a/clients/algoliasearch-client-php/lib/Model/Search/SearchType.php b/clients/algoliasearch-client-php/lib/Model/Search/SearchType.php deleted file mode 100644 index a1da86464b..0000000000 --- a/clients/algoliasearch-client-php/lib/Model/Search/SearchType.php +++ /dev/null @@ -1,31 +0,0 @@ - { - const results = await client.search({ - indexName: 'docsearch', - searchParams: { - query: 'docsearch', - }, + const { results } = await client.search({ + requests: [ + { + indexName: 'docsearch', + query: 'docsearch', + hitsPerPage: 50, + }, + ], }); const parent = document.querySelector('#results'); - results.hits?.forEach(({ objectID }) => { + results[0].hits?.forEach(({ objectID }) => { const children = document.createElement('p'); children.innerHTML = objectID; diff --git a/playground/javascript/node/search.ts b/playground/javascript/node/search.ts index 433c475de0..616c1dacc8 100644 --- a/playground/javascript/node/search.ts +++ b/playground/javascript/node/search.ts @@ -22,6 +22,7 @@ async function testSearch() { { indexName: searchIndex, query: searchQuery, + hitsPerPage: 50, }, ], }); diff --git a/specs/search/common/enums.yml b/specs/search/common/enums.yml index 8ed8cbcdec..fcb60bde9f 100644 --- a/specs/search/common/enums.yml +++ b/specs/search/common/enums.yml @@ -1,9 +1,3 @@ -searchType: - type: string - enum: [default, facet] - default: default - description: Perform a search query with `default`, will search for facet values if `facet` is given. - searchStrategy: type: string enum: [none, stopIfEnoughMatches] diff --git a/specs/search/common/schemas/SearchQuery.yml b/specs/search/common/schemas/SearchQuery.yml new file mode 100644 index 0000000000..139f2e766d --- /dev/null +++ b/specs/search/common/schemas/SearchQuery.yml @@ -0,0 +1,59 @@ +SearchQuery: + oneOf: + - $ref: '#/SearchForHits' + - $ref: '#/SearchForFacets' + +SearchForHits: + allOf: + - $ref: '../../../common/schemas/SearchParams.yml#/searchParams' + - $ref: '#/searchForHitsOptions' + +SearchForFacets: + allOf: + - $ref: '../../../common/schemas/SearchParams.yml#/searchParams' + - $ref: '#/searchForFacetsOptions' + +searchForFacetsOptions: + type: object + properties: + facet: + type: string + description: The `facet` name. + indexName: + $ref: '../../../common/parameters.yml#/indexName' + facetQuery: + type: string + description: Text to search inside the facet's values. + default: '' + maxFacetHits: + $ref: '../../../common/schemas/IndexSettings.yml#/maxFacetHits' + type: + $ref: '#/searchTypeFacet' + required: + - indexName + - type + +searchForHitsOptions: + # We provide this option because TypeScript can't distinguish union with optional keys + # if they are not completely the same, see usage in `templates/javascript/model.mustache` + x-is-SearchForHitsOptions: true + type: object + properties: + indexName: + $ref: '../../../common/parameters.yml#/indexName' + type: + $ref: '#/searchTypeDefault' + required: + - indexName + +searchTypeFacet: + type: string + enum: [facet] + default: facet + description: Perform a search query with `default`, will search for facet values if `facet` is given. + +searchTypeDefault: + type: string + enum: [default] + default: default + description: Perform a search query with `default`, will search for facet values if `facet` is given. diff --git a/specs/search/paths/search/search.yml b/specs/search/paths/search/search.yml index 7aac6b594a..43d5f0bc37 100644 --- a/specs/search/paths/search/search.yml +++ b/specs/search/paths/search/search.yml @@ -17,23 +17,7 @@ post: requests: type: array items: - title: searchQueries - type: object - additionalProperties: false - properties: - indexName: - $ref: '../../../common/parameters.yml#/indexName' - query: - $ref: '../../../common/schemas/SearchParams.yml#/query' - type: - $ref: '../../common/enums.yml#/searchType' - facet: - type: string - description: The `facet` name. - params: - $ref: '../../../common/schemas/SearchParams.yml#/searchParams' - required: - - indexName + $ref: '../../common/schemas/SearchQuery.yml#/SearchQuery' strategy: $ref: '../../common/enums.yml#/searchStrategy' required: @@ -52,6 +36,8 @@ post: type: array items: $ref: '../../common/schemas/SearchResponse.yml#/SearchResponse' + required: + - results '400': $ref: '../../../common/responses/BadRequest.yml' '402': diff --git a/templates/javascript/model.mustache b/templates/javascript/model.mustache index 4e965c3987..e17ba49544 100644 --- a/templates/javascript/model.mustache +++ b/templates/javascript/model.mustache @@ -21,7 +21,7 @@ export type {{classname}} = {{#parent}} {{{.}}} & {{/parent}} { * {{{description}}} */{{/description}} {{name}}{{^required}}?{{/required}}: {{#isEnum}}{{classname}}{{{nameInCamelCase}}}{{#isArray}}[]{{/isArray}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{#isNullable}} | null{{/isNullable}}{{/isEnum}};{{/vars}} -} +} {{#vendorExtensions.x-is-SearchForHitsOptions}} & { facet?: never; maxFacetHits?: never; facetQuery?: never }; {{/vendorExtensions.x-is-SearchForHitsOptions}} {{/isEnum}} {{#hasEnums}}{{#vars}}{{#isEnum}}export type {{classname}}{{nameInCamelCase}} = {{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}}|{{/-last}}{{/enumVars}}{{/allowableValues}}{{/isEnum}}{{/vars}}{{/hasEnums}} {{#isEnum}}export type {{classname}} = {{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}}|{{/-last}}{{/enumVars}}{{/allowableValues}}{{/isEnum}} diff --git a/tests/CTS/methods/requests/search/search.json b/tests/CTS/methods/requests/search/search.json index 57eb132fb8..51027624a8 100644 --- a/tests/CTS/methods/requests/search/search.json +++ b/tests/CTS/methods/requests/search/search.json @@ -1,6 +1,6 @@ [ { - "testName": "search for a single request with minimal parameters", + "testName": "search for a single hits request with minimal parameters", "parameters": { "requests": [ { @@ -21,17 +21,13 @@ } }, { - "testName": "search for a single request with all parameters", + "testName": "search for a single facet request with minimal parameters", "parameters": { "requests": [ { "indexName": "theIndexName", - "query": "test", "type": "facet", - "facet": "theFacet", - "params": { - "hitsPerPage": 50 - } + "facet": "theFacet" } ], "strategy": "stopIfEnoughMatches" @@ -43,12 +39,8 @@ "requests": [ { "indexName": "theIndexName", - "query": "test", "type": "facet", - "facet": "theFacet", - "params": { - "hitsPerPage": 50 - } + "facet": "theFacet" } ], "strategy": "stopIfEnoughMatches" @@ -56,25 +48,123 @@ } }, { - "testName": "search for multiple requests in multiple indices with all parameters", + "testName": "search for a single hits request with all parameters", + "parameters": { + "requests": [ + { + "indexName": "theIndexName", + "query": "myQuery", + "hitsPerPage": 50, + "type": "default" + } + ] + }, + "request": { + "path": "/1/indexes/*/queries", + "method": "POST", + "body": { + "requests": [ + { + "indexName": "theIndexName", + "query": "myQuery", + "hitsPerPage": 50, + "type": "default" + } + ] + } + } + }, + { + "testName": "search for a single facet request with all parameters", "parameters": { "requests": [ { "indexName": "theIndexName", - "query": "test", "type": "facet", "facet": "theFacet", - "params": { - "hitsPerPage": 50 + "facetQuery": "theFacetQuery", + "query": "theQuery", + "maxFacetHits": 50 + } + ], + "strategy": "stopIfEnoughMatches" + }, + "request": { + "path": "/1/indexes/*/queries", + "method": "POST", + "body": { + "requests": [ + { + "indexName": "theIndexName", + "type": "facet", + "facet": "theFacet", + "facetQuery": "theFacetQuery", + "query": "theQuery", + "maxFacetHits": 50 } + ], + "strategy": "stopIfEnoughMatches" + } + } + }, + { + "testName": "search for multiple mixed requests in multiple indices with minimal parameters", + "parameters": { + "requests": [ + { + "indexName": "theIndexName" }, { "indexName": "theIndexName2", - "query": "test", - "type": "default", - "params": { - "hitsPerPage": 100 + "type": "facet", + "facet": "theFacet" + }, + { + "indexName": "theIndexName", + "type": "default" + } + ], + "strategy": "stopIfEnoughMatches" + }, + "request": { + "path": "/1/indexes/*/queries", + "method": "POST", + "body": { + "requests": [ + { + "indexName": "theIndexName" + }, + { + "indexName": "theIndexName2", + "type": "facet", + "facet": "theFacet" + }, + { + "indexName": "theIndexName", + "type": "default" } + ], + "strategy": "stopIfEnoughMatches" + } + } + }, + { + "testName": "search for multiple mixed requests in multiple indices with all parameters", + "parameters": { + "requests": [ + { + "indexName": "theIndexName", + "type": "facet", + "facet": "theFacet", + "facetQuery": "theFacetQuery", + "query": "theQuery", + "maxFacetHits": 50 + }, + { + "indexName": "theIndexName", + "query": "myQuery", + "hitsPerPage": 50, + "type": "default" } ], "strategy": "stopIfEnoughMatches" @@ -86,20 +176,17 @@ "requests": [ { "indexName": "theIndexName", - "query": "test", "type": "facet", "facet": "theFacet", - "params": { - "hitsPerPage": 50 - } + "facetQuery": "theFacetQuery", + "query": "theQuery", + "maxFacetHits": 50 }, { - "indexName": "theIndexName2", - "query": "test", - "type": "default", - "params": { - "hitsPerPage": 100 - } + "indexName": "theIndexName", + "query": "myQuery", + "hitsPerPage": 50, + "type": "default" } ], "strategy": "stopIfEnoughMatches" diff --git a/website/docs/api-clients/guides/filtering-your-search.mdx b/website/docs/api-clients/guides/filtering-your-search.mdx index be3bfdaf31..eaa7e75bd3 100644 --- a/website/docs/api-clients/guides/filtering-your-search.mdx +++ b/website/docs/api-clients/guides/filtering-your-search.mdx @@ -72,9 +72,7 @@ await client.search({ { indexName: '', query: '', - params: { - filters: 'actor:Scarlett Johansson', - }, + filters: 'actor:Scarlett Johansson', }, ], }); @@ -85,9 +83,7 @@ await client.search({ { indexName: '', query: '', - params: { - filters: 'actor:Tom Cruise OR actor:Scarlett Johansson', - }, + filters: 'actor:Tom Cruise OR actor:Scarlett Johansson', }, ], }); @@ -98,9 +94,7 @@ await client.search({ { indexName: '', query: '', - params: { - filters: 'NOT actor:Nicolas Cage', - }, + filters: 'NOT actor:Nicolas Cage', }, ], }); @@ -116,7 +110,7 @@ $client->search([ [ 'indexName' => '', 'query' => '', - 'params' => ['filters' => 'actor:Scarlett Johansson'], + 'filters' => 'actor:Scarlett Johansson', ], ], ]); @@ -127,7 +121,7 @@ $client->search([ [ 'indexName' => '', 'query' => '', - 'params' => ['filters' => 'actor:Tom Cruise OR actor:Scarlett Johansson'], + 'filters' => 'actor:Tom Cruise OR actor:Scarlett Johansson', ], ], ]); @@ -138,7 +132,7 @@ $client->search([ [ 'indexName' => '', 'query' => '', - 'params' => ['filters' => 'NOT actor:Nicolas Cage'], + 'filters' => 'NOT actor:Nicolas Cage', ], ], ]); @@ -162,20 +156,24 @@ $client->search([ ```js // Only "Scarlett Johansson" actor await client.search({ - indexName: '', - searchParams: { - query: '', - facetFilters: ['actor:Scarlett Johansson'], - }, + requests: [ + { + indexName: '', + query: '', + facetFilters: ['actor:Scarlett Johansson'], + }, + ], }); // Only "Tom Cruise" or "Scarlett Johansson" actor await client.search({ - indexName: '', - searchParams: { - query: '', - facetFilters: ['actor:Tom Cruise', 'actor:Scarlett Johansson'], - }, + requests: [ + { + indexName: '', + query: '', + facetFilters: ['actor:Tom Cruise', 'actor:Scarlett Johansson'], + }, + ], }); ``` @@ -189,7 +187,7 @@ $client->search([ [ 'indexName' => '', 'query' => '', - 'params' => ['facetFilters' => ['actor:Scarlett Johansson']], + 'facetFilters' => ['actor:Scarlett Johansson'], ], ], ]); @@ -200,7 +198,7 @@ $client->search([ [ 'indexName' => '', 'query' => '', - 'params' => ['facetFilters' => ['actor:Tom Cruise', 'actor:Scarlett Johansson']], + '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 a69293e799..d10ea8a4c7 100644 --- a/website/docs/api-clients/guides/retrieving-facets.mdx +++ b/website/docs/api-clients/guides/retrieving-facets.mdx @@ -27,9 +27,7 @@ await client.search({ { indexName: '', query: '', - params: { - facets: ['author', 'genre'], - }, + facets: ['author', 'genre'], }, ], }); @@ -43,9 +41,7 @@ await client.search({ { indexName: '', query: '', - params: { - facets: ['*'], - }, + facets: ['*'], }, ], }); @@ -61,7 +57,7 @@ $client->search([ [ 'indexName' => '', 'query' => '', - 'params' => ['facets' => ['author', 'genre']], + 'facets' => ['author', 'genre'], ], ], ]); @@ -75,7 +71,7 @@ $client->search([ [ 'indexName' => '', 'query' => '', - 'params' => ['facets' => ['*']], + 'facets' => ['*'], ], ], ]); diff --git a/website/docs/api-clients/migration-guide.mdx b/website/docs/api-clients/migration-guide.mdx index 0f652533b4..0ce0e7ac89 100644 --- a/website/docs/api-clients/migration-guide.mdx +++ b/website/docs/api-clients/migration-guide.mdx @@ -125,10 +125,8 @@ const searchResults2 = await client.search({ { indexName: '', query: '', - params: { - attributesToRetrieve: ['firstname', 'lastname'], - hitsPerPage: 50, - }, + attributesToRetrieve: ['firstname', 'lastname'], + hitsPerPage: 50, }, ], });