alfresco-ng2-components/docs/content-services/search-query-builder.service.md
Andy Stark 992cd38216 [ADF-2824] Reviewed search docs for 2.4 (#3477)
* [ADF-2824] Moved search widget docs into separate pages

* [ADF-2824] Separated search widget page and added search filter service docs

* [ADF-2824] Updated new search docs with doc tools
2018-06-13 12:46:33 +01:00

3.3 KiB

Added, Status, Last reviewed
Added Status Last reviewed
v2.3.0 Active 2018-06-12

Search Query Builder service

Stores information from all the custom search and faceted search widgets, compiles and runs the final search query.

Class members

Methods

  • addFilterQuery(query: string = null)
    Adds a new filter query.

    • query: string - Text of the query to add
  • buildQuery(): QueryBody
    Builds a new query using the added elements.

    • Returns QueryBody - The resulting query
  • execute(): Promise<void>
    Executes the query.

    • Returns Promise<void> - Notification of query completion
  • getFacetField(label: string = null): FacetField
    Gets the details of a facet field.

    • label: string - Identifying label of the facet field
    • Returns FacetField - Facet field details
  • getFacetQuery(label: string = null): FacetQuery
    Gets the details of a facet query

    • label: string - Identifying label of the facet query
    • Returns FacetQuery - Details of the facet query
  • getPrimarySorting(): SearchSortingDefinition
    Returns primary sorting definition.

  • getSortingOptions(): SearchSortingDefinition[]
    Returns all pre-configured sorting options that users can choose from.

  • removeFilterQuery(query: string = null)
    Removes a previously added filter query.

    • query: string - The query to remove
  • update()
    Builds the query and notifies subscribers when complete.

Details

See the Search filter component 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
constructor(queryBuilder: SearchQueryBuilderService) {

    queryBuilder.updated.subscribe(query => {
        this.queryBuilder.execute();
    });

    queryBuilder.executed.subscribe(data => {
        this.onDataLoaded(data);
    });

}

See also