Files
alfresco-ng2-components/docs/content-services/services/search-query-builder.service.md
Eugenio Romano 4043d55fc4 [AAE-10778] Refactor Viewer (#7992)
* refactor version 1 many todo

* split render from viewer
move alfresco render in content pack

* refactor part 2

* test fixed

* fix doc

* [AAE-10778] Fix lint issues

* [AAE-10778] Fix lint issue: remove duplicated declaration

* [AAE-10778] Fix lint issue: use flex shorthand rule

* [AAE-10778] Fix FormService and WidgetComponent imports

* [AAE-10778] Fix import FormModel, FormService, FormFieldModel from adf-core

* [AAE-10778] Implement missing oninit, onchanges and ondestroy

* [AAE-10778] Replace adf-viewer with adf-alfresco-viewer, update escape command to close the viewer

* [AAE-10778] Fix unit test: fix the class name to match the 'adf-viewer-render.image-viewer-scaling' get from the appConfigService

* [AAE-10778] Fix image-viewer unit tests: replace ContentService with UrlService

* [AAE-10778] Fix unit test 'should if the extension change extension Change event be fired': emit file extension when the filename extension change

* [AAE-10778] Fix unit test: expect for internalFileName value instead of display-name id because the display name logic has been moved to the alfresco-viewer.component

* [AAE-10778] Fix unit test: remove display name it because the unknown display name value is no longer handled after refactoring

* [AAE-10778] Fix e2e: [C260096] Should the Viewer able to accept a customToolbar

* [AAE-10778] Update selector to fix e2e: '[C362265] Should the Viewer be able to download a previous version of a file'

* [AAE-10778] Update selector to fix e2e: '[C260038] Should display first page, toolbar and pagination when opening a .pdf file'

* fix aftrer rebase

* fix unit test

* [AAE-10778] Add adf viewer component that is node agnostic, show adf-alfresco-viewer or adf-viewer into file-view-component if blob or node are set

* [AAE-10778] Update viewer export path

* [AAE-10778] Update selectors since have been updated in the viewer component

* [AAE-10778] Call adf-viewer from alfresco-viewer, project adf-alfresco-viewer content to adf-viewer

* [AAE-10778] Remove full screen unit tests from alfresco-viewer component becase that logic is handled in the viewer.component

* [AAE-10778] Export toolbar custom actions component

* [AAE-10778] Pass mimeType as input to adf-viewer to update mime icon

* [AAE-10778] Remove e2e because the custom name behaviour has been removed from the file-view.component (9f21b6dc69\#diff-4b438dc59784dce9eb7634cfeca6d8db61362966343bd3d6895a3edafdf4cfd5L129)

* [AAE-10778] Use two-way binding for showViewer change to fix C260100

* [AAE-10778] Update prefix css selectors to adf-viewer because are related to the adf-viewer component

* [AAE-10778] Update prefix css selectors to adf-viewer in the unit tests because are related to the adf-viewer component

* [AAE-10778] Update the output name to showViewerChange to navigate to primary url after closing the viewer

* [AAE-10778] Pass right and left sidebar template context to viewer component (fix C362242)

* [AAE-10778] Add allowFullScreen input to disable/enable full screen behaviour

* [AAE-10778] Handle loading visualization only inside the viewer-render component

* [AAE-10778] PDF viewer: fix mat-progress-bar is not showed during the pdf loading, center progress bar

* [AAE-10778] Remove isLoading from unit tests because no longer exists

* [AAE-10778] Remove viewerType input from adf-viewer, viewerType will be handled by viewer-render

* [AAE-10778] Remove console.log

* [AAE-10778] Remove check full screen button is not displayed on the media file because is not needed anymore, we don't need to check for the fullscreen button in the viewer component

* [AAE-10778] Check for node rendtion before to assign to urlFileContent and mimeType

* [AAE-10778] Process Services Cloud: register file-viewer widget that uses adf-alfresco-viewer component to display content from ACS

* [AAE-10778] Core: rename file-viewer widget into base-viewer, base-viewer no longer accept nodeId, but will accept urlFile and blobFile

* [AAE-10778] Process Services: register file-viewer widget that uses adf-alfresco-viewer component to display content from ACS

* [AAE-10778] Base viewer widget: show viewer only if there's a file input

* [AAE-10778] Viewer component: check for fileName when urlFile is provided as Input

* [AAE-10778] Viewer component documentation

* [AAE-10778] Update upgrade guide with viewer changes

* [AAE-10778] Fix double quote lint issue after rebase

---------

Co-authored-by: Amedeo Lepore <amedeo.lepore@hyland.com>
Co-authored-by: Amedeo Lepore <amedeo.lepore85@gmail.com>
2023-02-01 17:25:43 +01:00

147 lines
8.0 KiB
Markdown

---
Title: Search Query Builder service
Added: v2.3.0
Status: Active
Last reviewed: 2019-03-19
---
# [Search Query Builder service](../../../lib/content-services/src/lib/search/services/search-query-builder.service.ts "Defined in search-query-builder.service.ts")
Stores information from all the custom search and faceted search widgets, compiles and runs the final search query.
## Class members
### Methods
- **addFilterQuery**(query: `string`)<br/>
Adds a filter query to the current query.
- _query:_ `string` - Query string to add
- **addUserFacetBucket**(field: [`FacetField`](../../../lib/content-services/src/lib/search/models/facet-field.interface.ts), bucket: [`FacetFieldBucket`](../../../lib/content-services/src/lib/search/models/facet-field-bucket.interface.ts))<br/>
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/>
Builds the current query.
- **Returns** `QueryBody` - The finished query
- **execute**(queryBody?: `QueryBody`)<br/>
Builds and executes the current query.
- _queryBody:_ `QueryBody` - (Optional) (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` -
- **getFacetField**(label: `string`): [`FacetField`](../../../lib/content-services/src/lib/search/models/facet-field.interface.ts)<br/>
Gets a facet field by label.
- _label:_ `string` - Label of the facet field
- **Returns** [`FacetField`](../../../lib/content-services/src/lib/search/models/facet-field.interface.ts) - Facet field data
- **getFacetQuery**(label: `string`): [`FacetQuery`](../../../lib/content-services/src/lib/search/models/facet-query.interface.ts)<br/>
Gets a facet query by label.
- _label:_ `string` - Label of the query
- **Returns** [`FacetQuery`](../../../lib/content-services/src/lib/search/models/facet-query.interface.ts) - Facet query data
- **getPrimarySorting**(): [`SearchSortingDefinition`](../../../lib/content-services/src/lib/search/models/search-sorting-definition.interface.ts)<br/>
Gets the primary sorting definition.
- **Returns** [`SearchSortingDefinition`](../../../lib/content-services/src/lib/search/models/search-sorting-definition.interface.ts) - The primary sorting definition
- **getQueryGroup**(query: `any`): `any`<br/>
Gets the query group.
- _query:_ `any` - Target query
- **Returns** `any` - Query group
- **getScope**(): `RequestScope`<br/>
- **Returns** `RequestScope` -
- **getSearchFormDetails**(): [`SearchForm`](../../../lib/content-services/src/lib/search/models/search-form.interface.ts)`[]`<br/>
- **Returns** [`SearchForm`](../../../lib/content-services/src/lib/search/models/search-form.interface.ts)`[]` -
- **getSortingOptions**(): [`SearchSortingDefinition`](../../../lib/content-services/src/lib/search/models/search-sorting-definition.interface.ts)`[]`<br/>
Gets all pre-configured sorting options that users can choose from.
- **Returns** [`SearchSortingDefinition`](../../../lib/content-services/src/lib/search/models/search-sorting-definition.interface.ts)`[]` - Pre-configured sorting options
- **getSupportedLabel**(configLabel: `string`): `string`<br/>
Encloses a label name with double quotes if it contains whitespace characters.
- _configLabel:_ `string` - Original label text
- **Returns** `string` - Label, possibly with quotes if it contains spaces
- **getUserFacetBuckets**(field: `string`): [`FacetFieldBucket`](../../../lib/content-services/src/lib/search/models/facet-field-bucket.interface.ts)`[]`<br/>
Gets the buckets currently added to a field
- _field:_ `string` - The target fields
- **Returns** [`FacetFieldBucket`](../../../lib/content-services/src/lib/search/models/facet-field-bucket.interface.ts)`[]` - Bucket array
- **isFilterServiceActive**(): `boolean`<br/>
- **Returns** `boolean` -
- **loadConfiguration**(): [`SearchConfiguration`](../../../lib/content-services/src/lib/search/models/search-configuration.interface.ts)<br/>
- **Returns** [`SearchConfiguration`](../../../lib/content-services/src/lib/search/models/search-configuration.interface.ts) -
- **removeFilterQuery**(query: `string`)<br/>
Removes an existing filter query.
- _query:_ `string` - The query to remove
- **removeUserFacetBucket**(field: [`FacetField`](../../../lib/content-services/src/lib/search/models/facet-field.interface.ts), bucket: [`FacetFieldBucket`](../../../lib/content-services/src/lib/search/models/facet-field-bucket.interface.ts))<br/>
Removes an existing bucket from 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 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/>
- _queryBody:_ `QueryBody` -
- **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/>
Builds the current query and triggers the `updated` event.
- _queryBody:_ `QueryBody` - (Optional) (Optional)
- **updateSelectedConfiguration**(index: `number`)<br/>
- _index:_ `number` -
## Details
See the [Search filter component](../components/search-filter.component.md) page for full details about the format of queries,
facet fields, and sorting options.
The Query Builder is UI agnostic and does not rely on Angular components.
You can reuse it with multiple component implementations.
You can use custom widgets to populate and edit the following parts of the resulting query:
- categories
- query fragments that form a query expression
- include fields
- scope settings
- filter queries
- facet fields
- range queries
```ts
constructor(queryBuilder: SearchQueryBuilderService) {
queryBuilder.updated.subscribe(query => {
this.queryBuilder.execute();
});
queryBuilder.executed.subscribe(data => {
this.onDataLoaded(data);
});
}
```
> **Note:** From ADF 3.0.0, the query contains the `"facetFormat": "V2"` parameter so that all the responses have the same structure whether they come from search queries containing facetFields, facetQueries, grouped facetQueries or facetIntervals.
## See also
- [Search Configuration Guide](../../user-guide/search-configuration-guide.md)
- [Search filter component](../components/search-filter.component.md)
- [Search filter chips component](../components/search-filter-chips.component.md)
- [Search Form Component](../components/search-form.component.md)
- [Search Widget interface](../interfaces/search-widget.interface.md)
- [Search check list component](../components/search-check-list.component.md)
- [Search date range component](../components/search-date-range.component.md)
- [Search number range component](../components/search-number-range.component.md)
- [Search radio component](../components/search-radio.component.md)
- [Search slider component](../components/search-slider.component.md)
- [Search text component](../components/search-text.component.md)