[ADF-2201] Search Configuration doc (#2876)

* [ADF-2201] Updated search component docs and tidied index page

* [ADF-2201] Fixed incorrect link

* [ADF-2201] Updated docs based on feedback

* [ADF-2201] Fixed broken relative link
This commit is contained in:
Andy Stark
2018-01-24 18:23:50 +00:00
committed by Vito
parent 8e4017ed19
commit 87101d4e85
7 changed files with 139 additions and 67 deletions

View File

@@ -129,7 +129,9 @@ for more information about installing and using the source code.
| [Page title service](page-title.service.md) | Sets the page title. | [Source](../lib/core/services/page-title.service.ts) | | [Page title service](page-title.service.md) | Sets the page title. | [Source](../lib/core/services/page-title.service.ts) |
| [People content service](people-content.service.md) | Gets information about a Content Services user. | [Source](../lib/core/services/people-content.service.ts) | | [People content service](people-content.service.md) | Gets information about a Content Services user. | [Source](../lib/core/services/people-content.service.ts) |
| [People process service](people-process.service.md) | Gets information about Process Services users. | [Source](../lib/core/services/people-process.service.ts) | | [People process service](people-process.service.md) | Gets information about Process Services users. | [Source](../lib/core/services/people-process.service.ts) |
| [Search configuration service](search-configuration.service.md) | Provides fine control of parameters to a search. | [Source](../lib/core/services/search-configuration.service.ts) |
| [Shared links api service](shared-links-api.service.md) | Finds shared links to Content Services items. | [Source](../lib/core/services/shared-links-api.service.ts) | | [Shared links api service](shared-links-api.service.md) | Finds shared links to Content Services items. | [Source](../lib/core/services/shared-links-api.service.ts) |
| [Sites service](sites.service.md) | Accesses and manipulates sites from a Content Services repository. | [Source](../lib/core/services/sites.service.ts) |
| [Storage service](storage.service.md) | Stores items in the form of key-value pairs. | [Source](../lib/core/services/storage.service.ts) | | [Storage service](storage.service.md) | Stores items in the form of key-value pairs. | [Source](../lib/core/services/storage.service.ts) |
| [Thumbnail service](thumbnail.service.md) | Retrieves an SVG thumbnail image to represent a document type. | [Source](../lib/core/services/thumbnail.service.ts) | | [Thumbnail service](thumbnail.service.md) | Retrieves an SVG thumbnail image to represent a document type. | [Source](../lib/core/services/thumbnail.service.ts) |
| [Translation service](translation.service.md) | Supports localisation. | [Source](../lib/core/services/translation.service.ts) | | [Translation service](translation.service.md) | Supports localisation. | [Source](../lib/core/services/translation.service.ts) |
@@ -138,8 +140,6 @@ for more information about installing and using the source code.
| [Bpm user service](bpm-user.service.md) | Gets information about the current Process Services user. | [Source](../lib/core/userinfo/services/bpm-user.service.ts) | | [Bpm user service](bpm-user.service.md) | Gets information about the current Process Services user. | [Source](../lib/core/userinfo/services/bpm-user.service.ts) |
| [Ecm user service](ecm-user.service.md) | Gets information about a Content Services user. | [Source](../lib/core/userinfo/services/ecm-user.service.ts) | | [Ecm user service](ecm-user.service.md) | Gets information about a Content Services user. | [Source](../lib/core/userinfo/services/ecm-user.service.ts) |
| _Renditions service_ | _Not currently documented_ | [Source](../lib/core/services/renditions.service.ts) | | _Renditions service_ | _Not currently documented_ | [Source](../lib/core/services/renditions.service.ts) |
| _Search configuration service_ | _Not currently documented_ | [Source](../lib/core/services/search-configuration.service.ts) |
| _Sites service_ | _Not currently documented_ | [Source](../lib/core/services/sites.service.ts) |
## Widgets ## Widgets
@@ -155,6 +155,7 @@ for more information about installing and using the source code.
| ---- | ----------- | ----------- | | ---- | ----------- | ----------- |
| [Data Table Adapter interface](DataTableAdapter.md) | Defines how table data is supplied to [DataTable](datatable.component.md) and [Tasklist](task-list.component.md) components. | [Source](../core/datatable/data/datatable-adapter.ts) | | [Data Table Adapter interface](DataTableAdapter.md) | Defines how table data is supplied to [DataTable](datatable.component.md) and [Tasklist](task-list.component.md) components. | [Source](../core/datatable/data/datatable-adapter.ts) |
| [Form Field Validator interface](FormFieldValidator.md) | Defines how the input fields of [ADF Form](form.component.md) and [ADF Task Details](task-details.component.md) components are validated. | [Source](../core/form/components/widgets/core/form-field-validator.ts) | | [Form Field Validator interface](FormFieldValidator.md) | Defines how the input fields of [ADF Form](form.component.md) and [ADF Task Details](task-details.component.md) components are validated. | [Source](../core/form/components/widgets/core/form-field-validator.ts) |
| [Search Configuration interface](search-configuration.interface.md) | Provides fine control of parameters to a search. | [Source](../core/services/search-configuration.service.ts) |
[(Back to Contents)](#contents) [(Back to Contents)](#contents)
@@ -192,7 +193,6 @@ for more information about installing and using the source code.
| [Version list component](version-list.component.md) | Displays the version history of a node in a [Version Manager component](version-manager.component.md) | [Source](../lib/content-services/version-manager/version-list.component.ts) | | [Version list component](version-list.component.md) | Displays the version history of a node in a [Version Manager component](version-manager.component.md) | [Source](../lib/content-services/version-manager/version-list.component.ts) |
| [Version manager component](version-manager.component.md) | Displays the version history of a node with the ability to upload a new version. | [Source](../lib/content-services/version-manager/version-manager.component.ts) | | [Version manager component](version-manager.component.md) | Displays the version history of a node with the ability to upload a new version. | [Source](../lib/content-services/version-manager/version-manager.component.ts) |
| [Webscript component](webscript.component.md) | Provides access to Webscript features. | [Source](../lib/content-services/webscript/webscript.component.ts) | | [Webscript component](webscript.component.md) | Provides access to Webscript features. | [Source](../lib/content-services/webscript/webscript.component.ts) |
| _Content metadata card component_ | _Not currently documented_ | [Source](../lib/content-services/content-metadata/components/content-metadata-card/content-metadata-card.component.ts) |
## Directives ## Directives
@@ -219,11 +219,6 @@ for more information about installing and using the source code.
| [Folder actions service](folder-actions.service.md) | Implements the folder menu actions for the Document List component. | [Source](../lib/content-services/document-list/services/folder-actions.service.ts) | | [Folder actions service](folder-actions.service.md) | Implements the folder menu actions for the Document List component. | [Source](../lib/content-services/document-list/services/folder-actions.service.ts) |
| [Rating service](rating.service.md) | Manages ratings for items in Content Services. | [Source](../lib/content-services/social/services/rating.service.ts) | | [Rating service](rating.service.md) | Manages ratings for items in Content Services. | [Source](../lib/content-services/social/services/rating.service.ts) |
| [Tag service](tag.service.md) | Manages tags in Content Services. | [Source](../lib/content-services/tag/services/tag.service.ts) | | [Tag service](tag.service.md) | Manages tags in Content Services. | [Source](../lib/content-services/tag/services/tag.service.ts) |
| _Aspect whitelist service_ | _Not currently documented_ | [Source](../lib/content-services/content-metadata/services/aspect-whitelist.service.ts) |
| _Basic properties service_ | _Not currently documented_ | [Source](../lib/content-services/content-metadata/services/basic-properties.service.ts) |
| _Content metadata service_ | _Not currently documented_ | [Source](../lib/content-services/content-metadata/services/content-metadata.service.ts) |
| _Properties loader service_ | _Not currently documented_ | [Source](../lib/content-services/content-metadata/services/properties-loader.service.ts) |
| _Property descriptors service_ | _Not currently documented_ | [Source](../lib/content-services/content-metadata/services/property-descriptors.service.ts) |
<!--content-services end--> <!--content-services end-->
@@ -265,8 +260,6 @@ for more information about installing and using the source code.
| [Task filters component](task-filters.component.md) | Shows all available filters. | [Source](../lib/process-services/task-list/components/task-filters.component.ts) | | [Task filters component](task-filters.component.md) | Shows all available filters. | [Source](../lib/process-services/task-list/components/task-filters.component.ts) |
| [Task header component](task-header.component.md) | Shows all the information related to a task. | [Source](../lib/process-services/task-list/components/task-header.component.ts) | | [Task header component](task-header.component.md) | Shows all the information related to a task. | [Source](../lib/process-services/task-list/components/task-header.component.ts) |
| [Task list component](task-list.component.md) | Renders a list containing all the tasks matched by the parameters specified. | [Source](../lib/process-services/task-list/components/task-list.component.ts) | | [Task list component](task-list.component.md) | Renders a list containing all the tasks matched by the parameters specified. | [Source](../lib/process-services/task-list/components/task-list.component.ts) |
| _Attach file widget component_ | _Not currently documented_ | [Source](../lib/process-services/content-widget/attach-file-widget.component.ts) |
| _Attach folder widget component_ | _Not currently documented_ | [Source](../lib/process-services/content-widget/attach-folder-widget.component.ts) |
## Directives ## Directives
@@ -289,7 +282,6 @@ for more information about installing and using the source code.
| [Process service](process.service.md) | Manage Process Instances, Process Variables, and Process Audit Log. | [Source](../lib/process-services/process-list/services/process.service.ts) | | [Process service](process.service.md) | Manage Process Instances, Process Variables, and Process Audit Log. | [Source](../lib/process-services/process-list/services/process.service.ts) |
| [Task filter service](task-filter.service.md) | Manage Task Filters, which are pre-configured Task Instance queries. | [Source](../lib/process-services/task-list/services/task-filter.service.ts) | | [Task filter service](task-filter.service.md) | Manage Task Filters, which are pre-configured Task Instance queries. | [Source](../lib/process-services/task-list/services/task-filter.service.ts) |
| [Tasklist service](tasklist.service.md) | Manage Task Instances. | [Source](../lib/process-services/task-list/services/tasklist.service.ts) | | [Tasklist service](tasklist.service.md) | Manage Task Instances. | [Source](../lib/process-services/task-list/services/tasklist.service.ts) |
| _Task upload service_ | _Not currently documented_ | [Source](../lib/process-services/task-list/services/task-upload.service.ts) |
<!--process-services end--> <!--process-services end-->

View File

@@ -0,0 +1,88 @@
# Search Configuration interface
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.
## 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.
A standard implementation, the
[Search Configuration service](search-configuration.service.md) is provided in the ADF Core library
source. This works fine in most cases but if you need to, you can implement your own service, as
described below.
### How to use the interface
1. Implement the service class
Create your own service class to implement the SearchConfigurationInterface. 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.
An example implementation is given below:
```ts
import { QueryBody } 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 = {
query: {
query: searchTerm ? `${searchTerm}* OR name:${searchTerm}*` : searchTerm
},
include: ['path', 'allowableOperations'],
paging: {
maxItems: maxResults,
skipCount: skipCount
},
filterQueries: [
{ query: "TYPE:'cm:folder'" },
{ query: 'NOT cm:creator:System' }]
};
return defaultQueryBody;
}
}
```
2. Provide your service class to the module
Once you have created your service class, you must inform the component to use it instead
of the default one. This is easily done using the component providers:
```ts
import { SearchService, SearchConfigurationService } from '@alfresco/adf-core';
import { TestSearchConfigurationService } from './search-config-test.service';
@Component({
selector: 'app-search-extended-component',
templateUrl: './search-extended.component.html',
styleUrls: ['./search-extended.component.scss'],
encapsulation: ViewEncapsulation.None,
providers: [
{ provide: SearchConfigurationService, useClass: TestSearchConfigurationService },
SearchService
]
})
```
You also need to add the SearchService as a provider to avoid overriding the module instance. This component will have his own instance of the SearchService that will use the class you have provided
as its configuration.
## See also
- [Search component](search.component.md)
- [Search configuration service](search-configuration.service.md)

View File

@@ -0,0 +1,26 @@
# Search Configuration service
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.
## 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`
specified for the paging of the search results.
This service is a standard implementation of the
[Search configuration interface](search-configuration.interface.md) that works well for many
common cases. However, you can also supply your own implementation if you need to. See the
[Search configuration interface](search-configuration.interface.md) page for full details and
example code.
## See also
- [Search component](search.component.md)
- [Search configuration interface](search-configuration.interface.md)

View File

@@ -19,7 +19,7 @@ Searches items for supplied search terms.
| maxResults | number | 20 | Maximum number of results to show in the search. | | maxResults | number | 20 | Maximum number of results to show in the search. |
| skipResults | number | 0 | Number of results to skip from the results pagination. | | skipResults | number | 0 | Number of results to skip from the results pagination. |
| displayWith | function | | Function that maps an option's value to its display value in the trigger | | displayWith | function | | Function that maps an option's value to its display value in the trigger |
| queryBody| [QueryBody](https://github.com/Alfresco/alfresco-js-api/blob/1.6.0/src/alfresco-search-rest-api/docs/QueryBody.md) | | object which allow you to perform more elaborated query from the search api. This input is deprecated, to use the extended query body function please refer to the suggested solution [here](./search.component.md#querybody) | | queryBody | [QueryBody](https://github.com/Alfresco/alfresco-js-api/blob/1.6.0/src/alfresco-search-rest-api/docs/QueryBody.md) | | object which allow you to perform more elaborated query from the search api. This input is deprecated, to use the extended query body function please refer to the suggested solution [here](./search.component.md#custom-search-configuration) |
### Events ### Events
@@ -114,59 +114,17 @@ Yuo can do this by exporting the adf-search panel instance into a local template
In this way it is possible to fetch the results from the word typed into the input text straight into the adf-search component via the custom template variable. In this way it is possible to fetch the results from the word typed into the input text straight into the adf-search component via the custom template variable.
## QueryBody ### Custom search configuration
This is an example on how you can provide your own class to generate your custom query body without giving it in input to the search component.
1. Service Class You can get finer control over the parameters of a search by defining them in a custom
You need to create your own service class which will implement the SearchConfigurationInterface this will force you to create the method generateQueryBody that is the one which needs to return the QueryBody object. [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
```ts [Search Configuration interface](search-configuration.interface.md) (the `queryBody` parameter of the `Search component` is now deprecated). The ADF source provides a standard implementation of this
import { QueryBody } from 'alfresco-js-api'; interface, `SearchConfigurationService` that you can use as a base to adapt to your needs. See the
import { SearchConfigurationInterface } from '@alfresco/adf-core'; [Search Configuration interface](search-configuration.interface.md) page for full details of how to
customize your search.
export class TestSearchConfigurationService implements SearchConfigurationInterface {
constructor() {
}
public generateQueryBody(searchTerm: string, maxResults: string, skipCount: string): QueryBody {
const defaultQueryBody: QueryBody = {
query: {
query: searchTerm ? `${searchTerm}* OR name:${searchTerm}*` : searchTerm
},
include: ['path', 'allowableOperations'],
paging: {
maxItems: maxResults,
skipCount: skipCount
},
filterQueries: [
{ query: "TYPE:'cm:folder'" },
{ query: 'NOT cm:creator:System' }]
};
return defaultQueryBody;
}
}
```
2. Provide your service class to the module
Once you have created your service class to provide your custom query body you need to inform the component to use your class instead of the default one. This can be easily achieved via your component providers :
```ts
import { SearchService, SearchConfigurationService } from '@alfresco/adf-core';
import { TestSearchConfigurationService } from './search-config-test.service';
@Component({
selector: 'app-search-extended-component',
templateUrl: './search-extended.component.html',
styleUrls: ['./search-extended.component.scss'],
encapsulation: ViewEncapsulation.None,
providers: [
{ provide: SearchConfigurationService, useClass: TestSearchConfigurationService },
SearchService
]
})
```
You need to add as provider even the SearchService to avoid the override of the module instance. So this component will have his own instance of the SearchService that will use as configuration the class you have provided.
## See Also
- [Search configuration interface](search-configuration.interface.md)
- [Search configuration service](search-configuration.service.md)

View File

@@ -42,4 +42,4 @@ class SiteMembersModel {
## See also ## See also
- [Sites api service](sites-api.service.md) - [Sites service](sites.service.md)

View File

@@ -38,5 +38,13 @@
"node-actions", "node-actions",
"content-node-selector.service", "content-node-selector.service",
"analytics", "analytics",
"process-upload" "process-upload",
"properties-loader",
"property-descriptors",
"attach-file",
"attach-folder",
"task-upload",
"aspect-whitelist",
"basic-properties",
"content-metadata"
] ]