[ACS-5839] migrate from QueryBody to SearchResult type (#8861)

* [ci:force] migrate from QueryBody to SearchQuery

* [ci:force] migrate from QueryBody to SearchQuery

* [ci:force] migrate from QueryBody to SearchQuery

* [ci:force] update docs and variables as per code review
This commit is contained in:
Denys Vuika
2023-08-31 14:36:21 +01:00
committed by GitHub
parent c73e95c9bf
commit c83d92c539
18 changed files with 340 additions and 480 deletions

View File

@@ -30,7 +30,7 @@ This document lists all the deprecated ADF v2.x components that were removed for
This modification has enabled us to remove some code duplication between the two modules.
- [PR ADF-1873](https://github.com/Alfresco/alfresco-ng2-components/pull/4145):
- `adf-search-control`: The `QueryBody`, and
- `adf-search-control`: The `SearchRequest`, and
`customQueryBody` inputs of the [`SearchControlComponent`](../content-services/components/search-control.component.md) have been removed in favor of the
[custom search configuration interface](../core/interfaces/search-configuration.interface.md).
The inputs were deprecated in v2.1.0.

View File

@@ -151,8 +151,7 @@ By doing this, you can get the results as the user types into the input text.
### Custom search configuration
You can get finer control over the parameters of a search by defining them in a custom
[QueryBody](https://github.com/Alfresco/alfresco-js-api/blob/1.6.0/src/alfresco-search-rest-api/docs/QueryBody.md)
object. The recommended way to do this is with a custom implementation of the
**SearchRequest** object. The recommended way to do this is with a custom implementation of the
[Search Configuration interface](../../core/interfaces/search-configuration.interface.md). The ADF source provides a standard implementation of this
interface, [`SearchConfigurationService`](../../core/services/search-configuration.service.md) that you can use as a base to adapt to your needs. See the
[Search Configuration interface](../../core/interfaces/search-configuration.interface.md) page for full details of how to

View File

@@ -20,12 +20,12 @@ Stores information from all the custom search and faceted search widgets, compil
Adds a facet bucket to a field.
- _field:_ [`FacetField`](../../../lib/content-services/src/lib/search/models/facet-field.interface.ts) - The target field
- _bucket:_ [`FacetFieldBucket`](../../../lib/content-services/src/lib/search/models/facet-field-bucket.interface.ts) - Bucket to add
- **buildQuery**(): `QueryBody`<br/>
- **buildQuery**(): `SearchRequest`<br/>
Builds the current query.
- **Returns** `QueryBody` - The finished query
- **execute**(queryBody?: `QueryBody`)<br/>
- **Returns** `SearchRequest` - The finished query
- **execute**(queryBody?: `SearchRequest`)<br/>
Builds and executes the current query.
- _queryBody:_ `QueryBody` - (Optional)
- _queryBody:_ `SearchRequest` - (Optional)
- **getDefaultConfiguration**(): [`SearchConfiguration`](../../../lib/content-services/src/lib/search/models/search-configuration.interface.ts)`|undefined`<br/>
- **Returns** [`SearchConfiguration`](../../../lib/content-services/src/lib/search/models/search-configuration.interface.ts)`|undefined` -
@@ -81,18 +81,18 @@ Stores information from all the custom search and faceted search widgets, compil
- _bucket:_ [`FacetFieldBucket`](../../../lib/content-services/src/lib/search/models/facet-field-bucket.interface.ts) - Bucket to remove
- **resetToDefaults**()<br/>
- **search**(queryBody: `QueryBody`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`ResultSetPaging`](https://github.com/Alfresco/alfresco-js-api/blob/develop/src/api/search-rest-api/docs/ResultSetPaging.md)`>`<br/>
- **search**(queryBody: `SearchRequest`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`ResultSetPaging`](https://github.com/Alfresco/alfresco-js-api/blob/develop/src/api/search-rest-api/docs/ResultSetPaging.md)`>`<br/>
- _queryBody:_ `QueryBody` -
- _queryBody:_ `SearchRequest` -
- **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`ResultSetPaging`](https://github.com/Alfresco/alfresco-js-api/blob/develop/src/api/search-rest-api/docs/ResultSetPaging.md)`>` -
- **setScope**(scope: `RequestScope`)<br/>
- _scope:_ `RequestScope` -
- **update**(queryBody?: `QueryBody`)<br/>
- **update**(queryBody?: `SearchRequest`)<br/>
Builds the current query and triggers the `updated` event.
- _queryBody:_ `QueryBody` - (Optional)
- _queryBody:_ `SearchRequest` - (Optional)
- **updateSelectedConfiguration**(index: `number`)<br/>
- _index:_ `number` -

View File

@@ -10,14 +10,13 @@ Provides fine control of parameters to a search.
## Methods
`generateQueryBody(searchTerm: string, maxResults: string, skipCount: string): QueryBody`<br/>
Generates a QueryBody object with custom search parameters.
`generateQueryBody(searchTerm: string, maxResults: string, skipCount: string): SearchRequest`<br/>
Generates a request object with custom search parameters.
## Details
The interface defines a service that generates a custom
[QueryBody](https://github.com/Alfresco/alfresco-js-api/blob/1.6.0/src/alfresco-search-rest-api/docs/QueryBody.md)
object. This object can then be supplied to a search operation to refine the search parameters.
**SearchRequest** object. This object can then be supplied to a search operation to refine the search parameters.
A standard implementation, the
[Search Configuration service](../services/search-configuration.service.md) is provided in the ADF Core library
@@ -29,37 +28,30 @@ described below.
1. Implement the service class
Create your own service class to implement the [`SearchConfigurationInterface`](../../core/interfaces/search-configuration.interface.md). This defines the
the `generateQueryBody` method that returns the QueryBody object. See the
[QueryBody](https://github.com/Alfresco/alfresco-js-api/blob/1.6.0/src/alfresco-search-rest-api/docs/QueryBody.md)
page in the Alfresco JS API for further details about the options this object provides.
`generateQueryBody` method that returns the query object.
An example implementation is given below:
```ts
import { QueryBody } from '@alfresco/js-api';
import { SearchRequest } from '@alfresco/js-api';
import { SearchConfigurationInterface } from '@alfresco/adf-core';
export class TestSearchConfigurationService implements SearchConfigurationInterface {
constructor() {
}
public generateQueryBody(searchTerm: string, maxResults: string, skipCount: string): QueryBody {
const defaultQueryBody: QueryBody = {
generateQueryBody(searchTerm: string, maxItems: string, skipCount: string): SearchRequest {
return {
query: {
query: searchTerm ? `${searchTerm}* OR name:${searchTerm}*` : searchTerm
},
include: ['path', 'allowableOperations'],
paging: {
maxItems: maxResults,
skipCount: skipCount
maxItems,
skipCount
},
filterQueries: [
{ query: "TYPE:'cm:folder'" },
{ query: 'NOT cm:creator:System' }]
};
return defaultQueryBody;
}
}
```

View File

@@ -13,18 +13,17 @@ Provides fine control of parameters to a search.
### Methods
- **generateQueryBody**(searchTerm: `string`, maxResults: `number`, skipCount: `number`): `QueryBody`<br/>
Generates a QueryBody object with custom search parameters.
- **generateQueryBody**(searchTerm: `string`, maxResults: `number`, skipCount: `number`): `SearchRequest`<br/>
Generates a request object with custom search parameters.
- _searchTerm:_ `string` - Term text to search for
- _maxResults:_ `number` - Maximum number of search results to show in a page
- _skipCount:_ `number` - The offset of the start of the page within the results list
- **Returns** `QueryBody` - Query body defined by the parameters
- **Returns** `SearchRequest` - Query body defined by the parameters
## Details
The `generateQueryBody` method returns a
[QueryBody](https://github.com/Alfresco/alfresco-js-api/blob/1.6.0/src/alfresco-search-rest-api/docs/QueryBody.md)
object. This configures the search to use `searchTerm` along with `maxResults` and `skipCount`
The `generateQueryBody` method returns a **SearchRequest** object.
This configures the search to use `searchTerm` along with `maxResults` and `skipCount`
specified for the paging of the search results.
This service is a standard implementation of the

View File

@@ -24,9 +24,9 @@ Accesses the Content Services Search API.
- _maxResults:_ `number` - Maximum number of items in the list of results
- _skipCount:_ `number` - Number of higher-ranked items to skip over in the list
- **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`ResultSetPaging`](https://github.com/Alfresco/alfresco-js-api/blob/develop/src/api/search-rest-api/docs/ResultSetPaging.md)`>` - List of search results
- **searchByQueryBody**(queryBody: `QueryBody`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`ResultSetPaging`](https://github.com/Alfresco/alfresco-js-api/blob/develop/src/api/search-rest-api/docs/ResultSetPaging.md)`>`<br/>
Performs a search with its parameters supplied by a QueryBody object.
- _queryBody:_ `QueryBody` - Object containing the search parameters
- **searchByQueryBody**(queryBody: `SearchRequest`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`ResultSetPaging`](https://github.com/Alfresco/alfresco-js-api/blob/develop/src/api/search-rest-api/docs/ResultSetPaging.md)`>`<br/>
Performs a search with its parameters supplied by a SearchRequest object.
- _queryBody:_ `SearchRequest` - Object containing the search parameters
- **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`ResultSetPaging`](https://github.com/Alfresco/alfresco-js-api/blob/develop/src/api/search-rest-api/docs/ResultSetPaging.md)`>` - List of search results
## Details