Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions sdk/search/azure-search-documents/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
- Removed `SearchServiceClientBuilder`.
- Renamed `SearchIndexClient` to `SearchClient` and `SearchIndexAsyncClient` to `SearchAsyncClient`.
- Put all models used `SearchIndexClient` and `SearchIndexerClient` (same for async clients) under `com.azure.search.documents.indexes`.
- Removed `select` parameter from list service resource APIs.
- Added list names APIs for each search service resource. (e.g. `listSearchIndexNames`, `listSearchIndexerNames`, `listDataSourceNames`, `listSkillsetNames`, `listSynonymMapNames`)

## 1.0.0-beta.3 (2020-05-05)
- Replaced `isRetrievable` API with `isHidden`, parameter name changed from `retrievable` to `hidden`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ public static PagedResponse<SearchIndexerDataSource> mappingPagingDataSource(
dataSourceMaps, null, null);
}

public static PagedResponse<String> mappingPagingDataSourceNames(
Response<ListDataSourcesResult> dataSourceResponse) {
List<String> dataSourceNames = dataSourceResponse.getValue().getDataSources().stream()
.map(SearchIndexerDataSourceConverter::map).map(SearchIndexerDataSource::getName).collect(toList());
return new PagedResponseBase<HttpHeaders, String>(
dataSourceResponse.getRequest(), dataSourceResponse.getStatusCode(), dataSourceResponse.getHeaders(),
dataSourceNames, null, null);
}

public static PagedResponse<SearchIndex> mappingPagingSearchIndex(
Response<ListIndexesResult> searchIndexResponse) {
List<SearchIndex> searchIndices = searchIndexResponse.getValue().getIndexes().stream()
Expand All @@ -70,6 +79,15 @@ public static PagedResponse<SearchIndex> mappingPagingSearchIndex(
searchIndices, null, null);
}

public static PagedResponse<String> mappingPagingSearchIndexNames(Response<ListIndexesResult>
searchIndexResponse) {
List<String> searchIndexNames = searchIndexResponse.getValue().getIndexes().stream()
.map(SearchIndexConverter::map).map(SearchIndex::getName).collect(toList());
return new PagedResponseBase<HttpHeaders, String>(
searchIndexResponse.getRequest(), searchIndexResponse.getStatusCode(), searchIndexResponse.getHeaders(),
searchIndexNames, null, null);
}

public static Response<SearchIndex> mappingExternalSearchIndex(
Response<com.azure.search.documents.indexes.implementation.models.SearchIndex> indexResponse) {
return new SimpleResponse<>(indexResponse, SearchIndexConverter.map(indexResponse.getValue()));
Expand All @@ -84,6 +102,15 @@ public static PagedResponse<SearchIndexer> mappingPagingSearchIndexer(
searchIndexerResponse.getHeaders(), searchIndexers, null, null);
}

public static PagedResponse<String> mappingPagingSearchIndexerNames(
Response<ListIndexersResult> searchIndexerResponse) {
List<String> searchIndexerNames = searchIndexerResponse.getValue().getIndexers().stream()
.map(SearchIndexerConverter::map).map(SearchIndexer::getName).collect(toList());
return new PagedResponseBase<HttpHeaders, String>(
searchIndexerResponse.getRequest(), searchIndexerResponse.getStatusCode(),
searchIndexerResponse.getHeaders(), searchIndexerNames, null, null);
}

public static Response<SearchIndexer> mappingExternalSearchIndexer(
Response<com.azure.search.documents.indexes.implementation.models.SearchIndexer> indexerResponse) {
return new SimpleResponse<>(indexerResponse, SearchIndexerConverter.map(indexerResponse.getValue()));
Expand All @@ -97,11 +124,20 @@ public static Response<SearchIndexerSkillset> mappingExternalSkillset(

public static PagedResponse<SearchIndexerSkillset> mappingPagingSkillset(
Response<ListSkillsetsResult> skillsetResponse) {
List<SearchIndexerSkillset> synonymMaps = skillsetResponse.getValue().getSkillsets().stream()
List<SearchIndexerSkillset> skillsets = skillsetResponse.getValue().getSkillsets().stream()
.map(SearchIndexerSkillsetConverter::map).collect(toList());
return new PagedResponseBase<HttpHeaders, SearchIndexerSkillset>(
skillsetResponse.getRequest(), skillsetResponse.getStatusCode(), skillsetResponse.getHeaders(),
synonymMaps, null, null);
skillsets, null, null);
}

public static PagedResponse<String> mappingPagingSkillsetNames(
Response<ListSkillsetsResult> skillsetResponse) {
List<String> skillsetNames = skillsetResponse.getValue().getSkillsets().stream()
.map(SearchIndexerSkillsetConverter::map).map(SearchIndexerSkillset::getName).collect(toList());
return new PagedResponseBase<HttpHeaders, String>(
skillsetResponse.getRequest(), skillsetResponse.getStatusCode(), skillsetResponse.getHeaders(),
skillsetNames, null, null);
}

public static Response<SynonymMap> mappingExternalSynonymMap(
Expand All @@ -118,6 +154,15 @@ public static PagedResponse<SynonymMap> mappingPagingSynonymMap(
synonymMaps, null, null);
}

public static PagedResponse<String> mappingPagingSynonymMapNames(
Response<ListSynonymMapsResult> synonymMapsResponse) {
List<String> synonymMapNames = synonymMapsResponse.getValue().getSynonymMaps().stream()
.map(SynonymMapConverter::map).map(SynonymMap::getName).collect(toList());
return new PagedResponseBase<HttpHeaders, String>(
synonymMapsResponse.getRequest(), synonymMapsResponse.getStatusCode(), synonymMapsResponse.getHeaders(),
synonymMapNames, null, null);
}

public static Response<ServiceStatistics> mappingExternalServiceStatistics(
Response<com.azure.search.documents.indexes.implementation.models.ServiceStatistics> statisticsResponse) {
return new SimpleResponse<>(statisticsResponse,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.azure.core.http.rest.PagedFlux;
import com.azure.core.http.rest.PagedResponse;
import com.azure.core.http.rest.Response;
import com.azure.core.http.rest.SimpleResponse;
import com.azure.core.util.Context;
import com.azure.core.util.FluxUtil;
import com.azure.core.util.logging.ClientLogger;
Expand All @@ -20,6 +21,8 @@
import com.azure.search.documents.implementation.util.MappingUtils;
import com.azure.search.documents.indexes.implementation.SearchServiceRestClientBuilder;
import com.azure.search.documents.indexes.implementation.SearchServiceRestClientImpl;
import com.azure.search.documents.indexes.implementation.models.ListIndexesResult;
import com.azure.search.documents.indexes.implementation.models.ListSynonymMapsResult;
import com.azure.search.documents.indexes.models.AnalyzeRequest;
import com.azure.search.documents.indexes.models.AnalyzedTokenInfo;
import com.azure.search.documents.indexes.models.GetIndexStatisticsResult;
Expand Down Expand Up @@ -242,35 +245,61 @@ public PagedFlux<SearchIndex> listIndexes() {
/**
* Lists all indexes available for an Azure Cognitive Search service.
*
* @param select selects which top-level properties of the index definitions to retrieve. Specified as a
* comma-separated list of JSON property names, or '*' for all properties. The default is all properties
* @param requestOptions additional parameters for the operation. Contains the tracking ID sent with the request to
* help with debugging
* @return a reactive response emitting the list of indexes.
*/
public PagedFlux<SearchIndex> listIndexes(String select, RequestOptions requestOptions) {
public PagedFlux<SearchIndex> listIndexes(RequestOptions requestOptions) {
try {
return new PagedFlux<>(() ->
withContext(context -> this.listIndexesWithResponse(select, requestOptions, context)));
withContext(context -> this.listIndexesWithResponse(null, requestOptions, context))
.map(MappingUtils::mappingPagingSearchIndex));
} catch (RuntimeException ex) {
return pagedFluxError(logger, ex);
}
}

PagedFlux<SearchIndex> listIndexes(String select, RequestOptions requestOptions, Context context) {
PagedFlux<SearchIndex> listIndexes(RequestOptions requestOptions, Context context) {
try {
return new PagedFlux<>(() -> this.listIndexesWithResponse(select, requestOptions, context));
return new PagedFlux<>(() -> this.listIndexesWithResponse(null, requestOptions, context)
.map(MappingUtils::mappingPagingSearchIndex));
} catch (RuntimeException ex) {
return pagedFluxError(logger, ex);
}
}

private Mono<PagedResponse<SearchIndex>> listIndexesWithResponse(String select, RequestOptions requestOptions,
Context context) {
/**
* Lists all indexes names for an Azure Cognitive Search service.
*
* @param requestOptions additional parameters for the operation. Contains the tracking ID sent with the request to
* help with debugging
* @return a reactive response emitting the list of index names.
*/
public PagedFlux<String> listIndexNames(RequestOptions requestOptions) {
try {
return new PagedFlux<>(() ->
withContext(context -> this.listIndexesWithResponse("name", requestOptions, context))
.map(MappingUtils::mappingPagingSearchIndexNames));
} catch (RuntimeException ex) {
return pagedFluxError(logger, ex);
}
}

PagedFlux<String> listIndexNames(RequestOptions requestOptions, Context context) {
try {
return new PagedFlux<>(() -> this.listIndexesWithResponse("name", requestOptions, context)
.map(MappingUtils::mappingPagingSearchIndexNames)
);
} catch (RuntimeException ex) {
return pagedFluxError(logger, ex);
}
}

private Mono<SimpleResponse<ListIndexesResult>> listIndexesWithResponse(String select,
RequestOptions requestOptions, Context context) {
return restClient.indexes()
.listWithRestResponseAsync(select, RequestOptionsIndexesConverter.map(requestOptions), context)
.onErrorMap(MappingUtils::exceptionMapper)
.map(MappingUtils::mappingPagingSearchIndex);
.onErrorMap(MappingUtils::exceptionMapper);
}

/**
Expand Down Expand Up @@ -484,41 +513,66 @@ Mono<Response<SynonymMap>> getSynonymMapWithResponse(String synonymMapName, Requ
* @return a reactive response emitting the list of synonym maps.
*/
public PagedFlux<SynonymMap> listSynonymMaps() {
return listSynonymMaps(null, null);
return listSynonymMaps(null);
}

/**
* Lists all synonym maps available for an Azure Cognitive Search service.
*
* @param select selects which top-level properties of the synonym maps to retrieve. Specified as a comma-separated
* list of JSON property names, or '*' for all properties. The default is all properties
* @param requestOptions additional parameters for the operation. Contains the tracking ID sent with the request to
* help with debugging
* @return a reactive response emitting the list of synonym maps.
*/
public PagedFlux<SynonymMap> listSynonymMaps(String select, RequestOptions requestOptions) {
public PagedFlux<SynonymMap> listSynonymMaps(RequestOptions requestOptions) {
try {
return new PagedFlux<>(() ->
withContext(context -> listSynonymMapsWithResponse(select, requestOptions, context)));
withContext(context -> listSynonymMapsWithResponse(null, requestOptions, context))
.map(MappingUtils::mappingPagingSynonymMap));
} catch (RuntimeException ex) {
return pagedFluxError(logger, ex);
}
}

PagedFlux<SynonymMap> listSynonymMaps(String select, RequestOptions requestOptions, Context context) {
PagedFlux<SynonymMap> listSynonymMaps(RequestOptions requestOptions, Context context) {
try {
return new PagedFlux<>(() -> listSynonymMapsWithResponse(select, requestOptions, context));
return new PagedFlux<>(() -> listSynonymMapsWithResponse(null, requestOptions, context)
.map(MappingUtils::mappingPagingSynonymMap));
} catch (RuntimeException ex) {
return pagedFluxError(logger, ex);
}
}

private Mono<PagedResponse<SynonymMap>> listSynonymMapsWithResponse(String select, RequestOptions requestOptions,
Context context) {
/**
* Lists all synonym map names for an Azure Cognitive Search service.
*
* @param requestOptions additional parameters for the operation. Contains the tracking ID sent with the request to
* help with debugging
* @return a reactive response emitting the list of synonym map names.
*/
public PagedFlux<String> listSynonymMapNames(RequestOptions requestOptions) {
try {
return new PagedFlux<>(() ->
withContext(context -> listSynonymMapsWithResponse("name", requestOptions, context))
.map(MappingUtils::mappingPagingSynonymMapNames));
} catch (RuntimeException ex) {
return pagedFluxError(logger, ex);
}
}

PagedFlux<String> listSynonymMapNames(RequestOptions requestOptions, Context context) {
try {
return new PagedFlux<>(() -> listSynonymMapsWithResponse("name", requestOptions, context)
.map(MappingUtils::mappingPagingSynonymMapNames));
} catch (RuntimeException ex) {
return pagedFluxError(logger, ex);
}
}

private Mono<SimpleResponse<ListSynonymMapsResult>> listSynonymMapsWithResponse(String select,
RequestOptions requestOptions, Context context) {
return restClient.synonymMaps()
.listWithRestResponseAsync(select, RequestOptionsIndexesConverter.map(requestOptions), context)
.onErrorMap(MappingUtils::exceptionMapper)
.map(MappingUtils::mappingPagingSynonymMap);
.onErrorMap(MappingUtils::exceptionMapper);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,21 +144,40 @@ public Response<GetIndexStatisticsResult> getIndexStatisticsWithResponse(String
* @return the list of indexes.
*/
public PagedIterable<SearchIndex> listIndexes() {
return listIndexes(null, null, Context.NONE);
return listIndexes(null, Context.NONE);
}

/**
* Lists all indexes available for an Azure Cognitive Search service.
*
* @param select selects which top-level properties of the index definitions to retrieve. Specified as a
* comma-separated list of JSON property names, or '*' for all properties. The default is all properties
* @param requestOptions additional parameters for the operation. Contains the tracking ID sent with the request to
* help with debugging
* @param context additional context that is passed through the HTTP pipeline during the service call
* @return the list of indexes.
*/
public PagedIterable<SearchIndex> listIndexes(String select, RequestOptions requestOptions, Context context) {
return new PagedIterable<>(asyncClient.listIndexes(select, requestOptions, context));
public PagedIterable<SearchIndex> listIndexes(RequestOptions requestOptions, Context context) {
return new PagedIterable<>(asyncClient.listIndexes(requestOptions, context));
}

/**
* Lists all index names for an Azure Cognitive Search service.
*
* @return the list of index names.
*/
public PagedIterable<String> listIndexNames() {
return listIndexNames(null, Context.NONE);
}

/**
* Lists all indexes names for an Azure Cognitive Search service.
*
* @param requestOptions additional parameters for the operation. Contains the tracking ID sent with the request to
* help with debugging
* @param context additional context that is passed through the HTTP pipeline during the service call
* @return the list of index names.
*/
public PagedIterable<String> listIndexNames(RequestOptions requestOptions, Context context) {
return new PagedIterable<>(asyncClient.listIndexNames(requestOptions, context));
}

/**
Expand Down Expand Up @@ -298,21 +317,40 @@ public Response<SynonymMap> getSynonymMapWithResponse(String synonymMapName, Req
* @return the list of synonym maps.
*/
public PagedIterable<SynonymMap> listSynonymMaps() {
return listSynonymMaps(null, null, Context.NONE);
return listSynonymMaps(null, Context.NONE);
}

/**
* Lists all synonym maps available for an Azure Cognitive Search service.
*
* @param select selects which top-level properties of the index definitions to retrieve. Specified as a
* comma-separated list of JSON property names, or '*' for all properties. The default is all properties
* @param requestOptions additional parameters for the operation. Contains the tracking ID sent with the request to
* help with debugging
* @param context additional context that is passed through the HTTP pipeline during the service call
* @return the list of synonym map names.
*/
public PagedIterable<SynonymMap> listSynonymMaps(RequestOptions requestOptions, Context context) {
return new PagedIterable<>(asyncClient.listSynonymMaps(requestOptions, context));
}

/**
* Lists all synonym maps names for an Azure Cognitive Search service.
*
* @return the list of synonym maps.
*/
public PagedIterable<SynonymMap> listSynonymMaps(String select, RequestOptions requestOptions, Context context) {
return new PagedIterable<>(asyncClient.listSynonymMaps(select, requestOptions, context));
public PagedIterable<String> listSynonymMapNames() {
return listSynonymMapNames(null, Context.NONE);
}

/**
* Lists all synonym maps names for an Azure Cognitive Search service.
*
* @param requestOptions additional parameters for the operation. Contains the tracking ID sent with the request to
* help with debugging
* @param context additional context that is passed through the HTTP pipeline during the service call
* @return the list of synonym map names.
*/
public PagedIterable<String> listSynonymMapNames(RequestOptions requestOptions, Context context) {
return new PagedIterable<>(asyncClient.listSynonymMapNames(requestOptions, context));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ public SearchIndexClient buildClient() {
*/
public SearchIndexAsyncClient buildAsyncClient() {
Objects.requireNonNull(endpoint, "'endpoint' cannot be null.");
Objects.requireNonNull(keyCredential, "'keyCredential' cannot be null.");

SearchServiceVersion buildVersion = (serviceVersion == null)
? SearchServiceVersion.getLatest()
Expand Down
Loading