[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

@@ -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