From f93ae14f399fc38a72bbfd9240836f4be932453f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Vannicatte?= <20689156+shortcuts@users.noreply.github.com> Date: Tue, 28 Dec 2021 15:05:40 +0100 Subject: [PATCH] feat(specs): add `search` endpoints (#50) --- .../com/algolia/model/BaseBrowseResponse.java | 76 ++ .../com/algolia/model/BrowseRequest.java | 104 ++ .../com/algolia/model/BrowseResponse.java | 937 ++++++++++++++++++ .../com/algolia/model/IndexSettings.java | 6 +- .../model/IndexSettingsAsSearchParams.java | 6 +- .../model/SearchForFacetValuesRequest.java | 139 +++ .../model/SearchForFacetValuesResponse.java | 89 ++ ...SearchForFacetValuesResponseFacetHits.java | 142 +++ .../com/algolia/model/SearchParams.java | 6 +- .../com/algolia/model/SnippetResult.java | 2 +- .../com/algolia/search/SearchApi.java | 418 ++++++++ .../client-search/model/baseBrowseResponse.ts | 6 + .../client-search/model/browseRequest.ts | 10 + .../client-search/model/browseResponse.ts | 7 + .../model/indexSettingsAsSearchParams.ts | 2 +- .../client-search/model/models.ts | 6 + .../model/searchForFacetValuesRequest.ts | 14 + .../model/searchForFacetValuesResponse.ts | 5 + .../searchForFacetValuesResponseFacetHits.ts | 14 + .../model/searchParamsAsString.ts | 3 + .../client-search/src/searchApi.ts | 100 ++ specs/search/common/schemas/IndexSettings.yml | 10 +- specs/search/common/schemas/Record.yml | 13 +- specs/search/common/schemas/SearchParams.yml | 12 +- .../search/common/schemas/SearchResponse.yml | 15 + specs/search/paths/search/browse.yml | 40 + .../paths/search/searchForFacetValues.yml | 68 ++ specs/search/spec.yml | 8 +- 28 files changed, 2236 insertions(+), 22 deletions(-) create mode 100644 clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/BaseBrowseResponse.java create mode 100644 clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/BrowseRequest.java create mode 100644 clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/BrowseResponse.java create mode 100644 clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/SearchForFacetValuesRequest.java create mode 100644 clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/SearchForFacetValuesResponse.java create mode 100644 clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/SearchForFacetValuesResponseFacetHits.java create mode 100644 clients/algoliasearch-client-javascript/client-search/model/baseBrowseResponse.ts create mode 100644 clients/algoliasearch-client-javascript/client-search/model/browseRequest.ts create mode 100644 clients/algoliasearch-client-javascript/client-search/model/browseResponse.ts create mode 100644 clients/algoliasearch-client-javascript/client-search/model/searchForFacetValuesRequest.ts create mode 100644 clients/algoliasearch-client-javascript/client-search/model/searchForFacetValuesResponse.ts create mode 100644 clients/algoliasearch-client-javascript/client-search/model/searchForFacetValuesResponseFacetHits.ts diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/BaseBrowseResponse.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/BaseBrowseResponse.java new file mode 100644 index 0000000000..0bff9b6836 --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/BaseBrowseResponse.java @@ -0,0 +1,76 @@ +package com.algolia.model; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; +import java.util.Objects; + +/** BaseBrowseResponse */ +public class BaseBrowseResponse { + + public static final String SERIALIZED_NAME_CURSOR = "cursor"; + + @SerializedName(SERIALIZED_NAME_CURSOR) + private String cursor; + + public BaseBrowseResponse cursor(String cursor) { + this.cursor = cursor; + return this; + } + + /** + * Cursor indicating the location to resume browsing from. Must match the value returned by the + * previous call. + * + * @return cursor + */ + @javax.annotation.Nonnull + @ApiModelProperty( + example = "jMDY3M2MwM2QwMWUxMmQwYWI0ZTN", + required = true, + value = "Cursor indicating the location to resume browsing from. Must match the value returned by" + + " the previous call." + ) + public String getCursor() { + return cursor; + } + + public void setCursor(String cursor) { + this.cursor = cursor; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + BaseBrowseResponse baseBrowseResponse = (BaseBrowseResponse) o; + return Objects.equals(this.cursor, baseBrowseResponse.cursor); + } + + @Override + public int hashCode() { + return Objects.hash(cursor); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class BaseBrowseResponse {\n"); + sb.append(" cursor: ").append(toIndentedString(cursor)).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/com/algolia/model/BrowseRequest.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/BrowseRequest.java new file mode 100644 index 0000000000..573f32c146 --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/BrowseRequest.java @@ -0,0 +1,104 @@ +package com.algolia.model; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; +import java.util.Objects; + +/** BrowseRequest */ +public class BrowseRequest { + + public static final String SERIALIZED_NAME_PARAMS = "params"; + + @SerializedName(SERIALIZED_NAME_PARAMS) + private String params = ""; + + public static final String SERIALIZED_NAME_CURSOR = "cursor"; + + @SerializedName(SERIALIZED_NAME_CURSOR) + private String cursor; + + public BrowseRequest params(String params) { + this.params = params; + return this; + } + + /** + * Search parameters as URL-encoded query string. + * + * @return params + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Search parameters as URL-encoded query string.") + public String getParams() { + return params; + } + + public void setParams(String params) { + this.params = params; + } + + public BrowseRequest cursor(String cursor) { + this.cursor = cursor; + return this; + } + + /** + * Cursor indicating the location to resume browsing from. Must match the value returned by the + * previous call. + * + * @return cursor + */ + @javax.annotation.Nullable + @ApiModelProperty( + example = "jMDY3M2MwM2QwMWUxMmQwYWI0ZTN", + value = "Cursor indicating the location to resume browsing from. Must match the value returned by" + + " the previous call." + ) + public String getCursor() { + return cursor; + } + + public void setCursor(String cursor) { + this.cursor = cursor; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + BrowseRequest browseRequest = (BrowseRequest) o; + return ( + Objects.equals(this.params, browseRequest.params) && + Objects.equals(this.cursor, browseRequest.cursor) + ); + } + + @Override + public int hashCode() { + return Objects.hash(params, cursor); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class BrowseRequest {\n"); + sb.append(" params: ").append(toIndentedString(params)).append("\n"); + sb.append(" cursor: ").append(toIndentedString(cursor)).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/com/algolia/model/BrowseResponse.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/BrowseResponse.java new file mode 100644 index 0000000000..8f51f3ff92 --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/BrowseResponse.java @@ -0,0 +1,937 @@ +package com.algolia.model; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** BrowseResponse */ +public class BrowseResponse { + + public static final String SERIALIZED_NAME_AB_TEST_I_D = "abTestID"; + + @SerializedName(SERIALIZED_NAME_AB_TEST_I_D) + private Integer abTestID; + + public static final String SERIALIZED_NAME_AB_TEST_VARIANT_I_D = + "abTestVariantID"; + + @SerializedName(SERIALIZED_NAME_AB_TEST_VARIANT_I_D) + private Integer abTestVariantID; + + public static final String SERIALIZED_NAME_AROUND_LAT_LNG = "aroundLatLng"; + + @SerializedName(SERIALIZED_NAME_AROUND_LAT_LNG) + private String aroundLatLng; + + public static final String SERIALIZED_NAME_AUTOMATIC_RADIUS = + "automaticRadius"; + + @SerializedName(SERIALIZED_NAME_AUTOMATIC_RADIUS) + private String automaticRadius; + + public static final String SERIALIZED_NAME_EXHAUSTIVE_FACETS_COUNT = + "exhaustiveFacetsCount"; + + @SerializedName(SERIALIZED_NAME_EXHAUSTIVE_FACETS_COUNT) + private Boolean exhaustiveFacetsCount; + + public static final String SERIALIZED_NAME_EXHAUSTIVE_NB_HITS = + "exhaustiveNbHits"; + + @SerializedName(SERIALIZED_NAME_EXHAUSTIVE_NB_HITS) + private Boolean exhaustiveNbHits; + + public static final String SERIALIZED_NAME_EXHAUSTIVE_TYPO = "exhaustiveTypo"; + + @SerializedName(SERIALIZED_NAME_EXHAUSTIVE_TYPO) + private Boolean exhaustiveTypo; + + public static final String SERIALIZED_NAME_FACETS = "facets"; + + @SerializedName(SERIALIZED_NAME_FACETS) + private Map> facets = null; + + public static final String SERIALIZED_NAME_FACETS_STATS = "facets_stats"; + + @SerializedName(SERIALIZED_NAME_FACETS_STATS) + private Map facetsStats = null; + + public static final String SERIALIZED_NAME_HITS_PER_PAGE = "hitsPerPage"; + + @SerializedName(SERIALIZED_NAME_HITS_PER_PAGE) + private Integer hitsPerPage = 20; + + public static final String SERIALIZED_NAME_INDEX = "index"; + + @SerializedName(SERIALIZED_NAME_INDEX) + private String index; + + public static final String SERIALIZED_NAME_INDEX_USED = "indexUsed"; + + @SerializedName(SERIALIZED_NAME_INDEX_USED) + private String indexUsed; + + public static final String SERIALIZED_NAME_MESSAGE = "message"; + + @SerializedName(SERIALIZED_NAME_MESSAGE) + private String message; + + public static final String SERIALIZED_NAME_NB_HITS = "nbHits"; + + @SerializedName(SERIALIZED_NAME_NB_HITS) + private Integer nbHits; + + public static final String SERIALIZED_NAME_NB_PAGES = "nbPages"; + + @SerializedName(SERIALIZED_NAME_NB_PAGES) + private Integer nbPages; + + public static final String SERIALIZED_NAME_NB_SORTED_HITS = "nbSortedHits"; + + @SerializedName(SERIALIZED_NAME_NB_SORTED_HITS) + private Integer nbSortedHits; + + public static final String SERIALIZED_NAME_PAGE = "page"; + + @SerializedName(SERIALIZED_NAME_PAGE) + private Integer page = 0; + + public static final String SERIALIZED_NAME_PARAMS = "params"; + + @SerializedName(SERIALIZED_NAME_PARAMS) + private String params; + + public static final String SERIALIZED_NAME_PARSED_QUERY = "parsedQuery"; + + @SerializedName(SERIALIZED_NAME_PARSED_QUERY) + private String parsedQuery; + + public static final String SERIALIZED_NAME_PROCESSING_TIME_M_S = + "processingTimeMS"; + + @SerializedName(SERIALIZED_NAME_PROCESSING_TIME_M_S) + private Integer processingTimeMS; + + public static final String SERIALIZED_NAME_QUERY = "query"; + + @SerializedName(SERIALIZED_NAME_QUERY) + private String query = ""; + + public static final String SERIALIZED_NAME_QUERY_AFTER_REMOVAL = + "queryAfterRemoval"; + + @SerializedName(SERIALIZED_NAME_QUERY_AFTER_REMOVAL) + private String queryAfterRemoval; + + public static final String SERIALIZED_NAME_SERVER_USED = "serverUsed"; + + @SerializedName(SERIALIZED_NAME_SERVER_USED) + private String serverUsed; + + public static final String SERIALIZED_NAME_USER_DATA = "userData"; + + @SerializedName(SERIALIZED_NAME_USER_DATA) + private Map userData = null; + + public static final String SERIALIZED_NAME_HITS = "hits"; + + @SerializedName(SERIALIZED_NAME_HITS) + private List hits = new ArrayList<>(); + + public static final String SERIALIZED_NAME_CURSOR = "cursor"; + + @SerializedName(SERIALIZED_NAME_CURSOR) + private String cursor; + + public BrowseResponse abTestID(Integer abTestID) { + this.abTestID = abTestID; + return this; + } + + /** + * If a search encounters an index that is being A/B tested, abTestID reports the ongoing A/B test + * ID. + * + * @return abTestID + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "If a search encounters an index that is being A/B tested, abTestID reports the ongoing" + + " A/B test ID." + ) + public Integer getAbTestID() { + return abTestID; + } + + public void setAbTestID(Integer abTestID) { + this.abTestID = abTestID; + } + + public BrowseResponse abTestVariantID(Integer abTestVariantID) { + this.abTestVariantID = abTestVariantID; + return this; + } + + /** + * If a search encounters an index that is being A/B tested, abTestVariantID reports the variant + * ID of the index used. + * + * @return abTestVariantID + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "If a search encounters an index that is being A/B tested, abTestVariantID reports the" + + " variant ID of the index used." + ) + public Integer getAbTestVariantID() { + return abTestVariantID; + } + + public void setAbTestVariantID(Integer abTestVariantID) { + this.abTestVariantID = abTestVariantID; + } + + public BrowseResponse aroundLatLng(String aroundLatLng) { + this.aroundLatLng = aroundLatLng; + return this; + } + + /** + * The computed geo location. + * + * @return aroundLatLng + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "The computed geo location.") + public String getAroundLatLng() { + return aroundLatLng; + } + + public void setAroundLatLng(String aroundLatLng) { + this.aroundLatLng = aroundLatLng; + } + + public BrowseResponse automaticRadius(String automaticRadius) { + this.automaticRadius = automaticRadius; + return this; + } + + /** + * The automatically computed radius. For legacy reasons, this parameter is a string and not an + * integer. + * + * @return automaticRadius + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "The automatically computed radius. For legacy reasons, this parameter is a string and" + + " not an integer." + ) + public String getAutomaticRadius() { + return automaticRadius; + } + + public void setAutomaticRadius(String automaticRadius) { + this.automaticRadius = automaticRadius; + } + + public BrowseResponse exhaustiveFacetsCount(Boolean exhaustiveFacetsCount) { + this.exhaustiveFacetsCount = exhaustiveFacetsCount; + return this; + } + + /** + * Whether the facet count is exhaustive or approximate. + * + * @return exhaustiveFacetsCount + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Whether the facet count is exhaustive or approximate." + ) + public Boolean getExhaustiveFacetsCount() { + return exhaustiveFacetsCount; + } + + public void setExhaustiveFacetsCount(Boolean exhaustiveFacetsCount) { + this.exhaustiveFacetsCount = exhaustiveFacetsCount; + } + + public BrowseResponse exhaustiveNbHits(Boolean exhaustiveNbHits) { + this.exhaustiveNbHits = exhaustiveNbHits; + return this; + } + + /** + * Indicate if the nbHits count was exhaustive or approximate + * + * @return exhaustiveNbHits + */ + @javax.annotation.Nonnull + @ApiModelProperty( + required = true, + value = "Indicate if the nbHits count was exhaustive or approximate" + ) + public Boolean getExhaustiveNbHits() { + return exhaustiveNbHits; + } + + public void setExhaustiveNbHits(Boolean exhaustiveNbHits) { + this.exhaustiveNbHits = exhaustiveNbHits; + } + + public BrowseResponse exhaustiveTypo(Boolean exhaustiveTypo) { + this.exhaustiveTypo = exhaustiveTypo; + return this; + } + + /** + * Indicate if the typo-tolerence search was exhaustive or approximate (only included when + * typo-tolerance is enabled) + * + * @return exhaustiveTypo + */ + @javax.annotation.Nonnull + @ApiModelProperty( + required = true, + value = "Indicate if the typo-tolerence search was exhaustive or approximate (only included when" + + " typo-tolerance is enabled)" + ) + public Boolean getExhaustiveTypo() { + return exhaustiveTypo; + } + + public void setExhaustiveTypo(Boolean exhaustiveTypo) { + this.exhaustiveTypo = exhaustiveTypo; + } + + public BrowseResponse facets(Map> facets) { + this.facets = facets; + return this; + } + + public BrowseResponse putFacetsItem( + String key, + Map facetsItem + ) { + if (this.facets == null) { + this.facets = new HashMap<>(); + } + this.facets.put(key, facetsItem); + return this; + } + + /** + * A mapping of each facet name to the corresponding facet counts. + * + * @return facets + */ + @javax.annotation.Nullable + @ApiModelProperty( + example = "{\"category\":{\"food\":1,\"tech\":42}}", + value = "A mapping of each facet name to the corresponding facet counts." + ) + public Map> getFacets() { + return facets; + } + + public void setFacets(Map> facets) { + this.facets = facets; + } + + public BrowseResponse facetsStats( + Map facetsStats + ) { + this.facetsStats = facetsStats; + return this; + } + + public BrowseResponse putFacetsStatsItem( + String key, + BaseSearchResponseFacetsStats facetsStatsItem + ) { + if (this.facetsStats == null) { + this.facetsStats = new HashMap<>(); + } + this.facetsStats.put(key, facetsStatsItem); + return this; + } + + /** + * Statistics for numerical facets. + * + * @return facetsStats + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Statistics for numerical facets.") + public Map getFacetsStats() { + return facetsStats; + } + + public void setFacetsStats( + Map facetsStats + ) { + this.facetsStats = facetsStats; + } + + public BrowseResponse hitsPerPage(Integer hitsPerPage) { + this.hitsPerPage = hitsPerPage; + return this; + } + + /** + * Set the number of hits per page. + * + * @return hitsPerPage + */ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "Set the number of hits per page.") + public Integer getHitsPerPage() { + return hitsPerPage; + } + + public void setHitsPerPage(Integer hitsPerPage) { + this.hitsPerPage = hitsPerPage; + } + + public BrowseResponse index(String index) { + this.index = index; + return this; + } + + /** + * Index name used for the query. + * + * @return index + */ + @javax.annotation.Nullable + @ApiModelProperty( + example = "indexName", + value = "Index name used for the query." + ) + public String getIndex() { + return index; + } + + public void setIndex(String index) { + this.index = index; + } + + public BrowseResponse indexUsed(String indexUsed) { + this.indexUsed = indexUsed; + return this; + } + + /** + * Index name used for the query. In the case of an A/B test, the targeted index isn't always the + * index used by the query. + * + * @return indexUsed + */ + @javax.annotation.Nullable + @ApiModelProperty( + example = "indexNameAlt", + value = "Index name used for the query. In the case of an A/B test, the targeted index isn't" + + " always the index used by the query." + ) + public String getIndexUsed() { + return indexUsed; + } + + public void setIndexUsed(String indexUsed) { + this.indexUsed = indexUsed; + } + + public BrowseResponse message(String message) { + this.message = message; + return this; + } + + /** + * Used to return warnings about the query. + * + * @return message + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Used to return warnings about the query.") + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public BrowseResponse nbHits(Integer nbHits) { + this.nbHits = nbHits; + return this; + } + + /** + * Number of hits that the search query matched. + * + * @return nbHits + */ + @javax.annotation.Nonnull + @ApiModelProperty( + example = "20", + required = true, + value = "Number of hits that the search query matched." + ) + public Integer getNbHits() { + return nbHits; + } + + public void setNbHits(Integer nbHits) { + this.nbHits = nbHits; + } + + public BrowseResponse nbPages(Integer nbPages) { + this.nbPages = nbPages; + return this; + } + + /** + * Number of pages available for the current query + * + * @return nbPages + */ + @javax.annotation.Nonnull + @ApiModelProperty( + example = "1", + required = true, + value = "Number of pages available for the current query" + ) + public Integer getNbPages() { + return nbPages; + } + + public void setNbPages(Integer nbPages) { + this.nbPages = nbPages; + } + + public BrowseResponse nbSortedHits(Integer nbSortedHits) { + this.nbSortedHits = nbSortedHits; + return this; + } + + /** + * The number of hits selected and sorted by the relevant sort algorithm + * + * @return nbSortedHits + */ + @javax.annotation.Nullable + @ApiModelProperty( + example = "20", + value = "The number of hits selected and sorted by the relevant sort algorithm" + ) + public Integer getNbSortedHits() { + return nbSortedHits; + } + + public void setNbSortedHits(Integer nbSortedHits) { + this.nbSortedHits = nbSortedHits; + } + + public BrowseResponse page(Integer page) { + this.page = page; + return this; + } + + /** + * Specify the page to retrieve. + * + * @return page + */ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "Specify the page to retrieve.") + public Integer getPage() { + return page; + } + + public void setPage(Integer page) { + this.page = page; + } + + public BrowseResponse params(String params) { + this.params = params; + return this; + } + + /** + * A url-encoded string of all search parameters. + * + * @return params + */ + @javax.annotation.Nonnull + @ApiModelProperty( + example = "query=a&hitsPerPage=20", + required = true, + value = "A url-encoded string of all search parameters." + ) + public String getParams() { + return params; + } + + public void setParams(String params) { + this.params = params; + } + + public BrowseResponse parsedQuery(String parsedQuery) { + this.parsedQuery = parsedQuery; + return this; + } + + /** + * The query string that will be searched, after normalization. + * + * @return parsedQuery + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "The query string that will be searched, after normalization." + ) + public String getParsedQuery() { + return parsedQuery; + } + + public void setParsedQuery(String parsedQuery) { + this.parsedQuery = parsedQuery; + } + + public BrowseResponse processingTimeMS(Integer processingTimeMS) { + this.processingTimeMS = processingTimeMS; + return this; + } + + /** + * Time the server took to process the request, in milliseconds. + * + * @return processingTimeMS + */ + @javax.annotation.Nonnull + @ApiModelProperty( + example = "20", + required = true, + value = "Time the server took to process the request, in milliseconds." + ) + public Integer getProcessingTimeMS() { + return processingTimeMS; + } + + public void setProcessingTimeMS(Integer processingTimeMS) { + this.processingTimeMS = processingTimeMS; + } + + public BrowseResponse query(String query) { + this.query = query; + return this; + } + + /** + * The text to search in the index. + * + * @return query + */ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "The text to search in the index.") + public String getQuery() { + return query; + } + + public void setQuery(String query) { + this.query = query; + } + + public BrowseResponse queryAfterRemoval(String queryAfterRemoval) { + this.queryAfterRemoval = queryAfterRemoval; + return this; + } + + /** + * A markup text indicating which parts of the original query have been removed in order to + * retrieve a non-empty result set. + * + * @return queryAfterRemoval + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "A markup text indicating which parts of the original query have been removed in order to" + + " retrieve a non-empty result set." + ) + public String getQueryAfterRemoval() { + return queryAfterRemoval; + } + + public void setQueryAfterRemoval(String queryAfterRemoval) { + this.queryAfterRemoval = queryAfterRemoval; + } + + public BrowseResponse serverUsed(String serverUsed) { + this.serverUsed = serverUsed; + return this; + } + + /** + * Actual host name of the server that processed the request. + * + * @return serverUsed + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Actual host name of the server that processed the request." + ) + public String getServerUsed() { + return serverUsed; + } + + public void setServerUsed(String serverUsed) { + this.serverUsed = serverUsed; + } + + public BrowseResponse userData(Map userData) { + this.userData = userData; + return this; + } + + public BrowseResponse putUserDataItem(String key, Object userDataItem) { + if (this.userData == null) { + this.userData = new HashMap<>(); + } + this.userData.put(key, userDataItem); + return this; + } + + /** + * Lets you store custom data in your indices. + * + * @return userData + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Lets you store custom data in your indices.") + public Map getUserData() { + return userData; + } + + public void setUserData(Map userData) { + this.userData = userData; + } + + public BrowseResponse hits(List hits) { + this.hits = hits; + return this; + } + + public BrowseResponse addHitsItem(Record hitsItem) { + this.hits.add(hitsItem); + return this; + } + + /** + * Get hits + * + * @return hits + */ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "") + public List getHits() { + return hits; + } + + public void setHits(List hits) { + this.hits = hits; + } + + public BrowseResponse cursor(String cursor) { + this.cursor = cursor; + return this; + } + + /** + * Cursor indicating the location to resume browsing from. Must match the value returned by the + * previous call. + * + * @return cursor + */ + @javax.annotation.Nonnull + @ApiModelProperty( + example = "jMDY3M2MwM2QwMWUxMmQwYWI0ZTN", + required = true, + value = "Cursor indicating the location to resume browsing from. Must match the value returned by" + + " the previous call." + ) + public String getCursor() { + return cursor; + } + + public void setCursor(String cursor) { + this.cursor = cursor; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + BrowseResponse browseResponse = (BrowseResponse) o; + return ( + Objects.equals(this.abTestID, browseResponse.abTestID) && + Objects.equals(this.abTestVariantID, browseResponse.abTestVariantID) && + Objects.equals(this.aroundLatLng, browseResponse.aroundLatLng) && + Objects.equals(this.automaticRadius, browseResponse.automaticRadius) && + Objects.equals( + this.exhaustiveFacetsCount, + browseResponse.exhaustiveFacetsCount + ) && + Objects.equals(this.exhaustiveNbHits, browseResponse.exhaustiveNbHits) && + Objects.equals(this.exhaustiveTypo, browseResponse.exhaustiveTypo) && + Objects.equals(this.facets, browseResponse.facets) && + Objects.equals(this.facetsStats, browseResponse.facetsStats) && + Objects.equals(this.hitsPerPage, browseResponse.hitsPerPage) && + Objects.equals(this.index, browseResponse.index) && + Objects.equals(this.indexUsed, browseResponse.indexUsed) && + Objects.equals(this.message, browseResponse.message) && + Objects.equals(this.nbHits, browseResponse.nbHits) && + Objects.equals(this.nbPages, browseResponse.nbPages) && + Objects.equals(this.nbSortedHits, browseResponse.nbSortedHits) && + Objects.equals(this.page, browseResponse.page) && + Objects.equals(this.params, browseResponse.params) && + Objects.equals(this.parsedQuery, browseResponse.parsedQuery) && + Objects.equals(this.processingTimeMS, browseResponse.processingTimeMS) && + Objects.equals(this.query, browseResponse.query) && + Objects.equals( + this.queryAfterRemoval, + browseResponse.queryAfterRemoval + ) && + Objects.equals(this.serverUsed, browseResponse.serverUsed) && + Objects.equals(this.userData, browseResponse.userData) && + Objects.equals(this.hits, browseResponse.hits) && + Objects.equals(this.cursor, browseResponse.cursor) + ); + } + + @Override + public int hashCode() { + return Objects.hash( + abTestID, + abTestVariantID, + aroundLatLng, + automaticRadius, + exhaustiveFacetsCount, + exhaustiveNbHits, + exhaustiveTypo, + facets, + facetsStats, + hitsPerPage, + index, + indexUsed, + message, + nbHits, + nbPages, + nbSortedHits, + page, + params, + parsedQuery, + processingTimeMS, + query, + queryAfterRemoval, + serverUsed, + userData, + hits, + cursor + ); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class BrowseResponse {\n"); + sb.append(" abTestID: ").append(toIndentedString(abTestID)).append("\n"); + sb + .append(" abTestVariantID: ") + .append(toIndentedString(abTestVariantID)) + .append("\n"); + sb + .append(" aroundLatLng: ") + .append(toIndentedString(aroundLatLng)) + .append("\n"); + sb + .append(" automaticRadius: ") + .append(toIndentedString(automaticRadius)) + .append("\n"); + sb + .append(" exhaustiveFacetsCount: ") + .append(toIndentedString(exhaustiveFacetsCount)) + .append("\n"); + sb + .append(" exhaustiveNbHits: ") + .append(toIndentedString(exhaustiveNbHits)) + .append("\n"); + sb + .append(" exhaustiveTypo: ") + .append(toIndentedString(exhaustiveTypo)) + .append("\n"); + sb.append(" facets: ").append(toIndentedString(facets)).append("\n"); + sb + .append(" facetsStats: ") + .append(toIndentedString(facetsStats)) + .append("\n"); + sb + .append(" hitsPerPage: ") + .append(toIndentedString(hitsPerPage)) + .append("\n"); + sb.append(" index: ").append(toIndentedString(index)).append("\n"); + sb + .append(" indexUsed: ") + .append(toIndentedString(indexUsed)) + .append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append(" nbHits: ").append(toIndentedString(nbHits)).append("\n"); + sb.append(" nbPages: ").append(toIndentedString(nbPages)).append("\n"); + sb + .append(" nbSortedHits: ") + .append(toIndentedString(nbSortedHits)) + .append("\n"); + sb.append(" page: ").append(toIndentedString(page)).append("\n"); + sb.append(" params: ").append(toIndentedString(params)).append("\n"); + sb + .append(" parsedQuery: ") + .append(toIndentedString(parsedQuery)) + .append("\n"); + sb + .append(" processingTimeMS: ") + .append(toIndentedString(processingTimeMS)) + .append("\n"); + sb.append(" query: ").append(toIndentedString(query)).append("\n"); + sb + .append(" queryAfterRemoval: ") + .append(toIndentedString(queryAfterRemoval)) + .append("\n"); + sb + .append(" serverUsed: ") + .append(toIndentedString(serverUsed)) + .append("\n"); + sb.append(" userData: ").append(toIndentedString(userData)).append("\n"); + sb.append(" hits: ").append(toIndentedString(hits)).append("\n"); + sb.append(" cursor: ").append(toIndentedString(cursor)).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/com/algolia/model/IndexSettings.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/IndexSettings.java index 528a67d915..abc33070ae 100644 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/IndexSettings.java +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/IndexSettings.java @@ -2131,13 +2131,15 @@ public IndexSettings maxFacetHits(Integer maxFacetHits) { } /** - * Maximum number of facet hits to return during a search for facet values. + * Maximum number of facet hits to return during a search for facet values. For performance + * reasons, the maximum allowed number of returned values is 100. maximum: 100 * * @return maxFacetHits */ @javax.annotation.Nullable @ApiModelProperty( - value = "Maximum number of facet hits to return during a search for facet values." + value = "Maximum number of facet hits to return during a search for facet values. For performance" + + " reasons, the maximum allowed number of returned values is 100." ) public Integer getMaxFacetHits() { return maxFacetHits; diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/IndexSettingsAsSearchParams.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/IndexSettingsAsSearchParams.java index 600b28a777..c2c2e90f36 100644 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/IndexSettingsAsSearchParams.java +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/IndexSettingsAsSearchParams.java @@ -1718,13 +1718,15 @@ public IndexSettingsAsSearchParams maxFacetHits(Integer maxFacetHits) { } /** - * Maximum number of facet hits to return during a search for facet values. + * Maximum number of facet hits to return during a search for facet values. For performance + * reasons, the maximum allowed number of returned values is 100. maximum: 100 * * @return maxFacetHits */ @javax.annotation.Nullable @ApiModelProperty( - value = "Maximum number of facet hits to return during a search for facet values." + value = "Maximum number of facet hits to return during a search for facet values. For performance" + + " reasons, the maximum allowed number of returned values is 100." ) public Integer getMaxFacetHits() { return maxFacetHits; diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/SearchForFacetValuesRequest.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/SearchForFacetValuesRequest.java new file mode 100644 index 0000000000..a394c8f3cc --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/SearchForFacetValuesRequest.java @@ -0,0 +1,139 @@ +package com.algolia.model; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; +import java.util.Objects; + +/** SearchForFacetValuesRequest */ +public class SearchForFacetValuesRequest { + + public static final String SERIALIZED_NAME_PARAMS = "params"; + + @SerializedName(SERIALIZED_NAME_PARAMS) + private String params = ""; + + public static final String SERIALIZED_NAME_FACET_QUERY = "facetQuery"; + + @SerializedName(SERIALIZED_NAME_FACET_QUERY) + private String facetQuery = ""; + + public static final String SERIALIZED_NAME_MAX_FACET_HITS = "maxFacetHits"; + + @SerializedName(SERIALIZED_NAME_MAX_FACET_HITS) + private Integer maxFacetHits = 10; + + public SearchForFacetValuesRequest params(String params) { + this.params = params; + return this; + } + + /** + * Search parameters as URL-encoded query string. + * + * @return params + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Search parameters as URL-encoded query string.") + public String getParams() { + return params; + } + + public void setParams(String params) { + this.params = params; + } + + public SearchForFacetValuesRequest facetQuery(String facetQuery) { + this.facetQuery = facetQuery; + return this; + } + + /** + * Text to search inside the facet's values. + * + * @return facetQuery + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Text to search inside the facet's values.") + public String getFacetQuery() { + return facetQuery; + } + + public void setFacetQuery(String facetQuery) { + this.facetQuery = facetQuery; + } + + public SearchForFacetValuesRequest maxFacetHits(Integer maxFacetHits) { + this.maxFacetHits = maxFacetHits; + return this; + } + + /** + * Maximum number of facet hits to return during a search for facet values. For performance + * reasons, the maximum allowed number of returned values is 100. maximum: 100 + * + * @return maxFacetHits + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Maximum number of facet hits to return during a search for facet values. For performance" + + " reasons, the maximum allowed number of returned values is 100." + ) + public Integer getMaxFacetHits() { + return maxFacetHits; + } + + public void setMaxFacetHits(Integer maxFacetHits) { + this.maxFacetHits = maxFacetHits; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SearchForFacetValuesRequest searchForFacetValuesRequest = (SearchForFacetValuesRequest) o; + return ( + Objects.equals(this.params, searchForFacetValuesRequest.params) && + Objects.equals(this.facetQuery, searchForFacetValuesRequest.facetQuery) && + Objects.equals( + this.maxFacetHits, + searchForFacetValuesRequest.maxFacetHits + ) + ); + } + + @Override + public int hashCode() { + return Objects.hash(params, facetQuery, maxFacetHits); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SearchForFacetValuesRequest {\n"); + sb.append(" params: ").append(toIndentedString(params)).append("\n"); + sb + .append(" facetQuery: ") + .append(toIndentedString(facetQuery)) + .append("\n"); + sb + .append(" maxFacetHits: ") + .append(toIndentedString(maxFacetHits)) + .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/com/algolia/model/SearchForFacetValuesResponse.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/SearchForFacetValuesResponse.java new file mode 100644 index 0000000000..6840a9611f --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/SearchForFacetValuesResponse.java @@ -0,0 +1,89 @@ +package com.algolia.model; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** SearchForFacetValuesResponse */ +public class SearchForFacetValuesResponse { + + public static final String SERIALIZED_NAME_FACET_HITS = "facetHits"; + + @SerializedName(SERIALIZED_NAME_FACET_HITS) + private List facetHits = new ArrayList<>(); + + public SearchForFacetValuesResponse facetHits( + List facetHits + ) { + this.facetHits = facetHits; + return this; + } + + public SearchForFacetValuesResponse addFacetHitsItem( + SearchForFacetValuesResponseFacetHits facetHitsItem + ) { + this.facetHits.add(facetHitsItem); + return this; + } + + /** + * Get facetHits + * + * @return facetHits + */ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "") + public List getFacetHits() { + return facetHits; + } + + public void setFacetHits( + List facetHits + ) { + this.facetHits = facetHits; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SearchForFacetValuesResponse searchForFacetValuesResponse = (SearchForFacetValuesResponse) o; + return Objects.equals( + this.facetHits, + searchForFacetValuesResponse.facetHits + ); + } + + @Override + public int hashCode() { + return Objects.hash(facetHits); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SearchForFacetValuesResponse {\n"); + sb + .append(" facetHits: ") + .append(toIndentedString(facetHits)) + .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/com/algolia/model/SearchForFacetValuesResponseFacetHits.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/SearchForFacetValuesResponseFacetHits.java new file mode 100644 index 0000000000..2fbc1252fe --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/SearchForFacetValuesResponseFacetHits.java @@ -0,0 +1,142 @@ +package com.algolia.model; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; +import java.util.Objects; + +/** SearchForFacetValuesResponseFacetHits */ +public class SearchForFacetValuesResponseFacetHits { + + public static final String SERIALIZED_NAME_VALUE = "value"; + + @SerializedName(SERIALIZED_NAME_VALUE) + private String value; + + public static final String SERIALIZED_NAME_HIGHLIGHTED = "highlighted"; + + @SerializedName(SERIALIZED_NAME_HIGHLIGHTED) + private String highlighted; + + public static final String SERIALIZED_NAME_COUNT = "count"; + + @SerializedName(SERIALIZED_NAME_COUNT) + private Integer count; + + public SearchForFacetValuesResponseFacetHits value(String value) { + this.value = value; + return this; + } + + /** + * Raw value of the facet. + * + * @return value + */ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "Raw value of the facet.") + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public SearchForFacetValuesResponseFacetHits highlighted(String highlighted) { + this.highlighted = highlighted; + return this; + } + + /** + * Markup text with occurrences highlighted. + * + * @return highlighted + */ + @javax.annotation.Nonnull + @ApiModelProperty( + example = "George Clooney", + required = true, + value = "Markup text with occurrences highlighted." + ) + public String getHighlighted() { + return highlighted; + } + + public void setHighlighted(String highlighted) { + this.highlighted = highlighted; + } + + public SearchForFacetValuesResponseFacetHits count(Integer count) { + this.count = count; + return this; + } + + /** + * How many objects contain this facet value. This takes into account the extra search parameters + * specified in the query. Like for a regular search query, the counts may not be exhaustive. + * + * @return count + */ + @javax.annotation.Nonnull + @ApiModelProperty( + required = true, + value = "How many objects contain this facet value. This takes into account the extra search" + + " parameters specified in the query. Like for a regular search query, the counts" + + " may not be exhaustive." + ) + public Integer getCount() { + return count; + } + + public void setCount(Integer count) { + this.count = count; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SearchForFacetValuesResponseFacetHits searchForFacetValuesResponseFacetHits = (SearchForFacetValuesResponseFacetHits) o; + return ( + Objects.equals(this.value, searchForFacetValuesResponseFacetHits.value) && + Objects.equals( + this.highlighted, + searchForFacetValuesResponseFacetHits.highlighted + ) && + Objects.equals(this.count, searchForFacetValuesResponseFacetHits.count) + ); + } + + @Override + public int hashCode() { + return Objects.hash(value, highlighted, count); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SearchForFacetValuesResponseFacetHits {\n"); + sb.append(" value: ").append(toIndentedString(value)).append("\n"); + sb + .append(" highlighted: ") + .append(toIndentedString(highlighted)) + .append("\n"); + sb.append(" count: ").append(toIndentedString(count)).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/com/algolia/model/SearchParams.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/SearchParams.java index 6a5e583dc0..29b8d018fb 100644 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/SearchParams.java +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/SearchParams.java @@ -2664,13 +2664,15 @@ public SearchParams maxFacetHits(Integer maxFacetHits) { } /** - * Maximum number of facet hits to return during a search for facet values. + * Maximum number of facet hits to return during a search for facet values. For performance + * reasons, the maximum allowed number of returned values is 100. maximum: 100 * * @return maxFacetHits */ @javax.annotation.Nullable @ApiModelProperty( - value = "Maximum number of facet hits to return during a search for facet values." + value = "Maximum number of facet hits to return during a search for facet values. For performance" + + " reasons, the maximum allowed number of returned values is 100." ) public Integer getMaxFacetHits() { return maxFacetHits; diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/SnippetResult.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/SnippetResult.java index f117c58767..e74c37c60c 100644 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/SnippetResult.java +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/SnippetResult.java @@ -86,7 +86,7 @@ public SnippetResult value(String value) { */ @javax.annotation.Nullable @ApiModelProperty( - example = "George Clooney...", + example = "George Clooney", value = "Markup text with occurrences highlighted." ) public String getValue() { diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/search/SearchApi.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/search/SearchApi.java index ca42de8621..f149bdc3d7 100644 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/search/SearchApi.java +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/search/SearchApi.java @@ -15,6 +15,8 @@ import com.algolia.model.BatchDictionaryEntries; import com.algolia.model.BatchObject; import com.algolia.model.BatchResponse; +import com.algolia.model.BrowseRequest; +import com.algolia.model.BrowseResponse; import com.algolia.model.ClearAllSynonymsResponse; import com.algolia.model.DeleteApiKeyResponse; import com.algolia.model.DeleteIndexResponse; @@ -45,6 +47,8 @@ import com.algolia.model.SaveSynonymResponse; import com.algolia.model.SaveSynonymsResponse; import com.algolia.model.SearchDictionaryEntries; +import com.algolia.model.SearchForFacetValuesRequest; +import com.algolia.model.SearchForFacetValuesResponse; import com.algolia.model.SearchParams; import com.algolia.model.SearchResponse; import com.algolia.model.SearchRulesParams; @@ -1352,6 +1356,204 @@ public okhttp3.Call batchRulesAsync( return localVarCall; } + /** + * Build call for browse + * + * @param indexName The index in which to perform the request. (required) + * @param browseRequest (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + * + * + * + * + * + * + * + *
Status Code Description Response Headers
200 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public okhttp3.Call browseCall( + String indexName, + BrowseRequest browseRequest, + final ApiCallback _callback + ) throws ApiException { + Object localVarPostBody = browseRequest; + + // create path and map variables + String localVarPath = + "/1/indexes/{indexName}/browse".replaceAll( + "\\{" + "indexName" + "\\}", + this.escapeString(indexName.toString()) + ); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { "application/json" }; + final String localVarAccept = this.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { "application/json" }; + final String localVarContentType = + this.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + String[] localVarAuthNames = new String[] { "apiKey", "appId" }; + return this.buildCall( + localVarPath, + "POST", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback + ); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call browseValidateBeforeCall( + String indexName, + BrowseRequest browseRequest, + final ApiCallback _callback + ) throws ApiException { + // verify the required parameter 'indexName' is set + if (indexName == null) { + throw new ApiException( + "Missing the required parameter 'indexName' when calling browse(Async)" + ); + } + + // verify the required parameter 'browseRequest' is set + if (browseRequest == null) { + throw new ApiException( + "Missing the required parameter 'browseRequest' when calling browse(Async)" + ); + } + + okhttp3.Call localVarCall = browseCall(indexName, browseRequest, _callback); + return localVarCall; + } + + /** + * Retrieve all index content. This method allows you to retrieve all index content. It can + * retrieve up to 1,000 records per call and supports full text search and filters. For + * performance reasons, some features are not supported, including `distinct`, sorting + * by `typos`, `words` or `geo distance`. When there is more content + * to be browsed, the response contains a cursor field. This cursor has to be passed to the + * subsequent call to browse in order to get the next page of results. When the end of the index + * has been reached, the cursor field is absent from the response. + * + * @param indexName The index in which to perform the request. (required) + * @param browseRequest (required) + * @return BrowseResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + *
Status Code Description Response Headers
200 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public BrowseResponse browse(String indexName, BrowseRequest browseRequest) + throws ApiException { + ApiResponse localVarResp = browseWithHttpInfo( + indexName, + browseRequest + ); + return localVarResp.getData(); + } + + /** + * Retrieve all index content. This method allows you to retrieve all index content. It can + * retrieve up to 1,000 records per call and supports full text search and filters. For + * performance reasons, some features are not supported, including `distinct`, sorting + * by `typos`, `words` or `geo distance`. When there is more content + * to be browsed, the response contains a cursor field. This cursor has to be passed to the + * subsequent call to browse in order to get the next page of results. When the end of the index + * has been reached, the cursor field is absent from the response. + * + * @param indexName The index in which to perform the request. (required) + * @param browseRequest (required) + * @return ApiResponse<BrowseResponse> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + *
Status Code Description Response Headers
200 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public ApiResponse browseWithHttpInfo( + String indexName, + BrowseRequest browseRequest + ) throws ApiException { + okhttp3.Call localVarCall = browseValidateBeforeCall( + indexName, + browseRequest, + null + ); + Type localVarReturnType = new TypeToken() {}.getType(); + return this.execute(localVarCall, localVarReturnType); + } + + /** + * Retrieve all index content. (asynchronously) This method allows you to retrieve all index + * content. It can retrieve up to 1,000 records per call and supports full text search and + * filters. For performance reasons, some features are not supported, including + * `distinct`, sorting by `typos`, `words` or `geo + * distance`. When there is more content to be browsed, the response contains a cursor field. + * This cursor has to be passed to the subsequent call to browse in order to get the next page of + * results. When the end of the index has been reached, the cursor field is absent from the + * response. + * + * @param indexName The index in which to perform the request. (required) + * @param browseRequest (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + * + * + * + * + * + * + * + *
Status Code Description Response Headers
200 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public okhttp3.Call browseAsync( + String indexName, + BrowseRequest browseRequest, + final ApiCallback _callback + ) throws ApiException { + okhttp3.Call localVarCall = browseValidateBeforeCall( + indexName, + browseRequest, + _callback + ); + Type localVarReturnType = new TypeToken() {}.getType(); + this.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** * Build call for clearAllSynonyms * @@ -7255,6 +7457,222 @@ public okhttp3.Call searchDictionaryEntriesAsync( return localVarCall; } + /** + * Build call for searchForFacetValues + * + * @param indexName The index in which to perform the request. (required) + * @param facetName The facet name. (required) + * @param searchForFacetValuesRequest (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + * + * + * + * + * + * + * + *
Status Code Description Response Headers
200 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public okhttp3.Call searchForFacetValuesCall( + String indexName, + String facetName, + SearchForFacetValuesRequest searchForFacetValuesRequest, + final ApiCallback _callback + ) throws ApiException { + Object localVarPostBody = searchForFacetValuesRequest; + + // create path and map variables + String localVarPath = + "/1/indexes/{indexName}/facets/{facetName}/query".replaceAll( + "\\{" + "indexName" + "\\}", + this.escapeString(indexName.toString()) + ) + .replaceAll( + "\\{" + "facetName" + "\\}", + this.escapeString(facetName.toString()) + ); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { "application/json" }; + final String localVarAccept = this.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { "application/json" }; + final String localVarContentType = + this.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + String[] localVarAuthNames = new String[] { "apiKey", "appId" }; + return this.buildCall( + localVarPath, + "POST", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback + ); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call searchForFacetValuesValidateBeforeCall( + String indexName, + String facetName, + SearchForFacetValuesRequest searchForFacetValuesRequest, + final ApiCallback _callback + ) throws ApiException { + // verify the required parameter 'indexName' is set + if (indexName == null) { + throw new ApiException( + "Missing the required parameter 'indexName' when calling searchForFacetValues(Async)" + ); + } + + // verify the required parameter 'facetName' is set + if (facetName == null) { + throw new ApiException( + "Missing the required parameter 'facetName' when calling searchForFacetValues(Async)" + ); + } + + // verify the required parameter 'searchForFacetValuesRequest' is set + if (searchForFacetValuesRequest == null) { + throw new ApiException( + "Missing the required parameter 'searchForFacetValuesRequest' when calling" + + " searchForFacetValues(Async)" + ); + } + + okhttp3.Call localVarCall = searchForFacetValuesCall( + indexName, + facetName, + searchForFacetValuesRequest, + _callback + ); + return localVarCall; + } + + /** + * Search for values of a given facet Search for values of a given facet, optionally restricting + * the returned values to those contained in objects matching other search criteria. + * + * @param indexName The index in which to perform the request. (required) + * @param facetName The facet name. (required) + * @param searchForFacetValuesRequest (required) + * @return SearchForFacetValuesResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + *
Status Code Description Response Headers
200 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public SearchForFacetValuesResponse searchForFacetValues( + String indexName, + String facetName, + SearchForFacetValuesRequest searchForFacetValuesRequest + ) throws ApiException { + ApiResponse localVarResp = searchForFacetValuesWithHttpInfo( + indexName, + facetName, + searchForFacetValuesRequest + ); + return localVarResp.getData(); + } + + /** + * Search for values of a given facet Search for values of a given facet, optionally restricting + * the returned values to those contained in objects matching other search criteria. + * + * @param indexName The index in which to perform the request. (required) + * @param facetName The facet name. (required) + * @param searchForFacetValuesRequest (required) + * @return ApiResponse<SearchForFacetValuesResponse> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + *
Status Code Description Response Headers
200 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public ApiResponse searchForFacetValuesWithHttpInfo( + String indexName, + String facetName, + SearchForFacetValuesRequest searchForFacetValuesRequest + ) throws ApiException { + okhttp3.Call localVarCall = searchForFacetValuesValidateBeforeCall( + indexName, + facetName, + searchForFacetValuesRequest, + null + ); + Type localVarReturnType = new TypeToken() {} + .getType(); + return this.execute(localVarCall, localVarReturnType); + } + + /** + * Search for values of a given facet (asynchronously) Search for values of a given facet, + * optionally restricting the returned values to those contained in objects matching other search + * criteria. + * + * @param indexName The index in which to perform the request. (required) + * @param facetName The facet name. (required) + * @param searchForFacetValuesRequest (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + * + * + * + * + * + * + * + *
Status Code Description Response Headers
200 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public okhttp3.Call searchForFacetValuesAsync( + String indexName, + String facetName, + SearchForFacetValuesRequest searchForFacetValuesRequest, + final ApiCallback _callback + ) throws ApiException { + okhttp3.Call localVarCall = searchForFacetValuesValidateBeforeCall( + indexName, + facetName, + searchForFacetValuesRequest, + _callback + ); + Type localVarReturnType = new TypeToken() {} + .getType(); + this.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** * Build call for searchRules * diff --git a/clients/algoliasearch-client-javascript/client-search/model/baseBrowseResponse.ts b/clients/algoliasearch-client-javascript/client-search/model/baseBrowseResponse.ts new file mode 100644 index 0000000000..206e1dc700 --- /dev/null +++ b/clients/algoliasearch-client-javascript/client-search/model/baseBrowseResponse.ts @@ -0,0 +1,6 @@ +export type BaseBrowseResponse = { + /** + * Cursor indicating the location to resume browsing from. Must match the value returned by the previous call. + */ + cursor: string; +}; diff --git a/clients/algoliasearch-client-javascript/client-search/model/browseRequest.ts b/clients/algoliasearch-client-javascript/client-search/model/browseRequest.ts new file mode 100644 index 0000000000..8296b9eaff --- /dev/null +++ b/clients/algoliasearch-client-javascript/client-search/model/browseRequest.ts @@ -0,0 +1,10 @@ +export type BrowseRequest = { + /** + * Search parameters as URL-encoded query string. + */ + params?: string; + /** + * Cursor indicating the location to resume browsing from. Must match the value returned by the previous call. + */ + cursor?: string; +}; diff --git a/clients/algoliasearch-client-javascript/client-search/model/browseResponse.ts b/clients/algoliasearch-client-javascript/client-search/model/browseResponse.ts new file mode 100644 index 0000000000..16cf063b37 --- /dev/null +++ b/clients/algoliasearch-client-javascript/client-search/model/browseResponse.ts @@ -0,0 +1,7 @@ +import type { BaseBrowseResponse } from './baseBrowseResponse'; +import type { BaseSearchResponse } from './baseSearchResponse'; +import type { SearchHits } from './searchHits'; + +export type BrowseResponse = BaseBrowseResponse & + BaseSearchResponse & + SearchHits; diff --git a/clients/algoliasearch-client-javascript/client-search/model/indexSettingsAsSearchParams.ts b/clients/algoliasearch-client-javascript/client-search/model/indexSettingsAsSearchParams.ts index 51062cd2fd..85cea282b5 100644 --- a/clients/algoliasearch-client-javascript/client-search/model/indexSettingsAsSearchParams.ts +++ b/clients/algoliasearch-client-javascript/client-search/model/indexSettingsAsSearchParams.ts @@ -164,7 +164,7 @@ export type IndexSettingsAsSearchParams = { */ responseFields?: string[]; /** - * Maximum number of facet hits to return during a search for facet values. + * Maximum number of facet hits to return during a search for facet values. For performance reasons, the maximum allowed number of returned values is 100. */ maxFacetHits?: number; /** diff --git a/clients/algoliasearch-client-javascript/client-search/model/models.ts b/clients/algoliasearch-client-javascript/client-search/model/models.ts index d54c395d29..fd324f9246 100644 --- a/clients/algoliasearch-client-javascript/client-search/model/models.ts +++ b/clients/algoliasearch-client-javascript/client-search/model/models.ts @@ -8,6 +8,7 @@ export * from './appendSourceResponse'; export * from './assignUserIdObject'; export * from './assignUserIdResponse'; export * from './automaticFacetFilter'; +export * from './baseBrowseResponse'; export * from './baseIndexSettings'; export * from './baseSearchParams'; export * from './baseSearchResponse'; @@ -18,6 +19,8 @@ export * from './batchDictionaryEntries'; export * from './batchDictionaryEntriesRequest'; export * from './batchObject'; export * from './batchResponse'; +export * from './browseRequest'; +export * from './browseResponse'; export * from './clearAllSynonymsResponse'; export * from './condition'; export * from './consequence'; @@ -67,6 +70,9 @@ export * from './saveObjectResponse'; export * from './saveSynonymResponse'; export * from './saveSynonymsResponse'; export * from './searchDictionaryEntries'; +export * from './searchForFacetValuesRequest'; +export * from './searchForFacetValuesResponse'; +export * from './searchForFacetValuesResponseFacetHits'; export * from './searchHits'; export * from './searchParams'; export * from './searchParamsAsString'; diff --git a/clients/algoliasearch-client-javascript/client-search/model/searchForFacetValuesRequest.ts b/clients/algoliasearch-client-javascript/client-search/model/searchForFacetValuesRequest.ts new file mode 100644 index 0000000000..f7147f3d3e --- /dev/null +++ b/clients/algoliasearch-client-javascript/client-search/model/searchForFacetValuesRequest.ts @@ -0,0 +1,14 @@ +export type SearchForFacetValuesRequest = { + /** + * Search parameters as URL-encoded query string. + */ + params?: string; + /** + * Text to search inside the facet\'s values. + */ + facetQuery?: string; + /** + * Maximum number of facet hits to return during a search for facet values. For performance reasons, the maximum allowed number of returned values is 100. + */ + maxFacetHits?: number; +}; diff --git a/clients/algoliasearch-client-javascript/client-search/model/searchForFacetValuesResponse.ts b/clients/algoliasearch-client-javascript/client-search/model/searchForFacetValuesResponse.ts new file mode 100644 index 0000000000..971b0f6b56 --- /dev/null +++ b/clients/algoliasearch-client-javascript/client-search/model/searchForFacetValuesResponse.ts @@ -0,0 +1,5 @@ +import type { SearchForFacetValuesResponseFacetHits } from './searchForFacetValuesResponseFacetHits'; + +export type SearchForFacetValuesResponse = { + facetHits: SearchForFacetValuesResponseFacetHits[]; +}; diff --git a/clients/algoliasearch-client-javascript/client-search/model/searchForFacetValuesResponseFacetHits.ts b/clients/algoliasearch-client-javascript/client-search/model/searchForFacetValuesResponseFacetHits.ts new file mode 100644 index 0000000000..08b3ae166a --- /dev/null +++ b/clients/algoliasearch-client-javascript/client-search/model/searchForFacetValuesResponseFacetHits.ts @@ -0,0 +1,14 @@ +export type SearchForFacetValuesResponseFacetHits = { + /** + * Raw value of the facet. + */ + value: string; + /** + * Markup text with occurrences highlighted. + */ + highlighted: string; + /** + * How many objects contain this facet value. This takes into account the extra search parameters specified in the query. Like for a regular search query, the counts may not be exhaustive. + */ + count: number; +}; diff --git a/clients/algoliasearch-client-javascript/client-search/model/searchParamsAsString.ts b/clients/algoliasearch-client-javascript/client-search/model/searchParamsAsString.ts index 5840104127..ce49eec40e 100644 --- a/clients/algoliasearch-client-javascript/client-search/model/searchParamsAsString.ts +++ b/clients/algoliasearch-client-javascript/client-search/model/searchParamsAsString.ts @@ -1,3 +1,6 @@ export type SearchParamsAsString = { + /** + * Search parameters as URL-encoded query string. + */ params?: string; }; diff --git a/clients/algoliasearch-client-javascript/client-search/src/searchApi.ts b/clients/algoliasearch-client-javascript/client-search/src/searchApi.ts index e4974d95b4..3402c747f0 100644 --- a/clients/algoliasearch-client-javascript/client-search/src/searchApi.ts +++ b/clients/algoliasearch-client-javascript/client-search/src/searchApi.ts @@ -8,6 +8,8 @@ import type { BatchAssignUserIdsResponse } from '../model/batchAssignUserIdsResp import type { BatchDictionaryEntries } from '../model/batchDictionaryEntries'; import type { BatchObject } from '../model/batchObject'; import type { BatchResponse } from '../model/batchResponse'; +import type { BrowseRequest } from '../model/browseRequest'; +import type { BrowseResponse } from '../model/browseResponse'; import type { ClearAllSynonymsResponse } from '../model/clearAllSynonymsResponse'; import type { DeleteApiKeyResponse } from '../model/deleteApiKeyResponse'; import type { DeleteIndexResponse } from '../model/deleteIndexResponse'; @@ -39,6 +41,8 @@ import type { SaveObjectResponse } from '../model/saveObjectResponse'; import type { SaveSynonymResponse } from '../model/saveSynonymResponse'; import type { SaveSynonymsResponse } from '../model/saveSynonymsResponse'; import type { SearchDictionaryEntries } from '../model/searchDictionaryEntries'; +import type { SearchForFacetValuesRequest } from '../model/searchForFacetValuesRequest'; +import type { SearchForFacetValuesResponse } from '../model/searchForFacetValuesResponse'; import type { SearchParams } from '../model/searchParams'; import type { SearchParamsAsString } from '../model/searchParamsAsString'; import type { SearchResponse } from '../model/searchResponse'; @@ -439,6 +443,49 @@ export class SearchApi { return this.sendRequest(request, requestOptions); } + /** + * This method allows you to retrieve all index content. It can retrieve up to 1,000 records per call and supports full text search and filters. For performance reasons, some features are not supported, including `distinct`, sorting by `typos`, `words` or `geo distance`. When there is more content to be browsed, the response contains a cursor field. This cursor has to be passed to the subsequent call to browse in order to get the next page of results. When the end of the index has been reached, the cursor field is absent from the response. + * + * @summary Retrieve all index content. + * @param indexName - The index in which to perform the request. + * @param browseRequest - The browseRequest. + */ + browse( + indexName: string, + browseRequest: BrowseRequest + ): Promise { + const path = '/1/indexes/{indexName}/browse'.replace( + '{indexName}', + encodeURIComponent(String(indexName)) + ); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (indexName === null || indexName === undefined) { + throw new Error( + 'Required parameter indexName was null or undefined when calling browse.' + ); + } + + if (browseRequest === null || browseRequest === undefined) { + throw new Error( + 'Required parameter browseRequest was null or undefined when calling browse.' + ); + } + + const request: Request = { + method: 'POST', + path, + data: browseRequest, + }; + + const requestOptions: RequestOptions = { + headers, + queryParameters, + }; + + return this.sendRequest(request, requestOptions); + } /** * Remove all synonyms from an index. * @@ -1651,6 +1698,59 @@ export class SearchApi { return this.sendRequest(request, requestOptions); } + /** + * Search for values of a given facet, optionally restricting the returned values to those contained in objects matching other search criteria. + * + * @summary Search for values of a given facet. + * @param indexName - The index in which to perform the request. + * @param facetName - The facet name. + * @param searchForFacetValuesRequest - The searchForFacetValuesRequest. + */ + searchForFacetValues( + indexName: string, + facetName: string, + searchForFacetValuesRequest: SearchForFacetValuesRequest + ): Promise { + const path = '/1/indexes/{indexName}/facets/{facetName}/query' + .replace('{indexName}', encodeURIComponent(String(indexName))) + .replace('{facetName}', encodeURIComponent(String(facetName))); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (indexName === null || indexName === undefined) { + throw new Error( + 'Required parameter indexName was null or undefined when calling searchForFacetValues.' + ); + } + + if (facetName === null || facetName === undefined) { + throw new Error( + 'Required parameter facetName was null or undefined when calling searchForFacetValues.' + ); + } + + if ( + searchForFacetValuesRequest === null || + searchForFacetValuesRequest === undefined + ) { + throw new Error( + 'Required parameter searchForFacetValuesRequest was null or undefined when calling searchForFacetValues.' + ); + } + + const request: Request = { + method: 'POST', + path, + data: searchForFacetValuesRequest, + }; + + const requestOptions: RequestOptions = { + headers, + queryParameters, + }; + + return this.sendRequest(request, requestOptions); + } /** * Search for rules matching various criteria. * diff --git a/specs/search/common/schemas/IndexSettings.yml b/specs/search/common/schemas/IndexSettings.yml index 932ea967e0..58843183da 100644 --- a/specs/search/common/schemas/IndexSettings.yml +++ b/specs/search/common/schemas/IndexSettings.yml @@ -288,9 +288,7 @@ indexSettingsAsSearchParams: description: Choose which fields to return in the API response. This parameters applies to search and browse queries. default: [] maxFacetHits: - type: integer - description: Maximum number of facet hits to return during a search for facet values. - default: 10 + $ref: '#/maxFacetHits' attributeCriteriaComputedByMinProximity: type: boolean description: When attribute is ranked above proximity in your ranking formula, proximity is used to select which searchable attribute is matched in the attribute ranking stage. @@ -300,6 +298,12 @@ indexSettingsAsSearchParams: description: Content defining how the search interface should be rendered. Can be set via the settings for a default value and can be overridden via rules. default: {} +maxFacetHits: + type: integer + description: Maximum number of facet hits to return during a search for facet values. For performance reasons, the maximum allowed number of returned values is 100. + maximum: 100 + default: 10 + hitsPerPage: type: integer description: Set the number of hits per page. diff --git a/specs/search/common/schemas/Record.yml b/specs/search/common/schemas/Record.yml index 184b3f7adf..7c6cf6d953 100644 --- a/specs/search/common/schemas/Record.yml +++ b/specs/search/common/schemas/Record.yml @@ -23,9 +23,7 @@ highlightResult: additionalProperties: false properties: value: - type: string - description: Markup text with occurrences highlighted. - example: 'George Clooney' + $ref: '#/highlightedValue' matchLevel: type: string description: Indicates how well the attribute matched the search query. @@ -44,9 +42,7 @@ snippetResult: additionalProperties: false properties: value: - type: string - description: Markup text with occurrences highlighted. - example: 'George Clooney...' + $ref: '#/highlightedValue' matchLevel: type: string description: Indicates how well the attribute matched the search query. @@ -103,3 +99,8 @@ rankingInfo: word: type: integer description: Number of matched words, including prefixes and typos. + +highlightedValue: + type: string + description: Markup text with occurrences highlighted. + example: 'George Clooney' diff --git a/specs/search/common/schemas/SearchParams.yml b/specs/search/common/schemas/SearchParams.yml index 860769bb8f..8f283e9505 100644 --- a/specs/search/common/schemas/SearchParams.yml +++ b/specs/search/common/schemas/SearchParams.yml @@ -164,7 +164,12 @@ searchParamsAsString: additionalProperties: false properties: params: - type: string + $ref: '#/paramsAsString' + +paramsAsString: + description: Search parameters as URL-encoded query string. + type: string + default: '' query: type: string @@ -175,3 +180,8 @@ page: type: integer description: Specify the page to retrieve. default: 0 + +cursor: + type: string + description: Cursor indicating the location to resume browsing from. Must match the value returned by the previous call. + example: 'jMDY3M2MwM2QwMWUxMmQwYWI0ZTN' diff --git a/specs/search/common/schemas/SearchResponse.yml b/specs/search/common/schemas/SearchResponse.yml index 16ea43684f..08cb55a399 100644 --- a/specs/search/common/schemas/SearchResponse.yml +++ b/specs/search/common/schemas/SearchResponse.yml @@ -3,6 +3,21 @@ searchResponse: - $ref: '#/baseSearchResponse' - $ref: '#/searchHits' +browseResponse: + allOf: + - $ref: '#/baseSearchResponse' + - $ref: '#/searchHits' + - $ref: '#/baseBrowseResponse' + +baseBrowseResponse: + type: object + additionalProperties: false + required: + - cursor + properties: + cursor: + $ref: 'SearchParams.yml#/cursor' + searchHits: type: object additionalProperties: false diff --git a/specs/search/paths/search/browse.yml b/specs/search/paths/search/browse.yml index 6adb517bf4..b6672fbcd1 100644 --- a/specs/search/paths/search/browse.yml +++ b/specs/search/paths/search/browse.yml @@ -1 +1,41 @@ post: + tags: + - search + operationId: browse + summary: Retrieve all index content. + description: > + This method allows you to retrieve all index content. It can retrieve up to 1,000 records per call and supports full text search and filters. + + For performance reasons, some features are not supported, including `distinct`, sorting by `typos`, `words` or `geo distance`. + + When there is more content to be browsed, the response contains a cursor field. This cursor has to be passed to the subsequent call to browse in order to get the next page of results. When the end of the index has been reached, the cursor field is absent from the response. + parameters: + - $ref: '../../../common/parameters.yml#/IndexName' + requestBody: + required: true + content: + application/json: + schema: + title: browseRequest + type: object + additionalProperties: false + properties: + params: + $ref: '../../common/schemas/SearchParams.yml#/paramsAsString' + cursor: + $ref: '../../common/schemas/SearchParams.yml#/cursor' + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '../../common/schemas/SearchResponse.yml#/browseResponse' + '400': + $ref: '../../../common/responses/BadRequest.yml' + '402': + $ref: '../../../common/responses/FeatureNotEnabled.yml' + '403': + $ref: '../../../common/responses/MethodNotAllowed.yml' + '404': + $ref: '../../../common/responses/IndexNotFound.yml' diff --git a/specs/search/paths/search/searchForFacetValues.yml b/specs/search/paths/search/searchForFacetValues.yml index 6adb517bf4..4ef701b33c 100644 --- a/specs/search/paths/search/searchForFacetValues.yml +++ b/specs/search/paths/search/searchForFacetValues.yml @@ -1 +1,69 @@ post: + tags: + - search + operationId: searchForFacetValues + summary: Search for values of a given facet + description: Search for values of a given facet, optionally restricting the returned values to those contained in objects matching other search criteria. + parameters: + - $ref: '../../../common/parameters.yml#/IndexName' + - name: facetName + description: The facet name. + in: path + required: true + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + title: searchForFacetValuesRequest + type: object + additionalProperties: false + properties: + params: + $ref: '../../common/schemas/SearchParams.yml#/paramsAsString' + facetQuery: + type: string + description: Text to search inside the facet's values. + default: '' + maxFacetHits: + $ref: '../../common/schemas/IndexSettings.yml#/maxFacetHits' + responses: + '200': + description: OK + content: + application/json: + schema: + title: searchForFacetValuesResponse + type: object + additionalProperties: false + required: + - facetHits + properties: + facetHits: + type: array + items: + type: object + additionalProperties: false + required: + - value + - highlighted + - count + properties: + value: + description: Raw value of the facet. + type: string + highlighted: + $ref: '../../common/schemas/Record.yml#/highlightedValue' + count: + description: How many objects contain this facet value. This takes into account the extra search parameters specified in the query. Like for a regular search query, the counts may not be exhaustive. + type: integer + '400': + $ref: '../../../common/responses/BadRequest.yml' + '402': + $ref: '../../../common/responses/FeatureNotEnabled.yml' + '403': + $ref: '../../../common/responses/MethodNotAllowed.yml' + '404': + $ref: '../../../common/responses/IndexNotFound.yml' diff --git a/specs/search/spec.yml b/specs/search/spec.yml index c32a59ab47..2a88f06c14 100644 --- a/specs/search/spec.yml +++ b/specs/search/spec.yml @@ -20,10 +20,10 @@ paths: $ref: './paths/search/search.yml' /1/indexes/*/queries: $ref: './paths/search/multipleQueries.yml' - # /1/indexes/{indexName}/facets/{facetName}/query: - # $ref: './paths/search/searchForFacetValues.yml' - # /1/indexes/{indexName}/browse: - # $ref: './paths/search/browse.yml' + /1/indexes/{indexName}/facets/{facetName}/query: + $ref: './paths/search/searchForFacetValues.yml' + /1/indexes/{indexName}/browse: + $ref: './paths/search/browse.yml' # ######################### # ### Objects Endpoints ###