alfresco-ng2-components/docs/content-services/search-query-builder.service.md
Andy Stark 1079361c2c [ADF-3745] Updates for doc review (#4291)
* [ADF-3745] Updates for doc review

* [ADF-3745] Fixed bad links to Content node selector page

* [ADF-3745] Updated index files
2019-02-08 21:21:06 +00:00

4.9 KiB

Title, Added, Status, Last reviewed
Title Added Status Last reviewed
Search Query Builder service 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)
    Adds a filter query to the current query.
    • query: string - Query string to add
  • addUserFacetBucket(field: FacetField, bucket: FacetFieldBucket)
    Adds a facet bucket to a field.
  • buildQuery(): QueryBody
    Builds the current query.
    • Returns QueryBody - The finished query
  • execute()
    Builds and executes the current query.
  • getFacetField(label: string): FacetField
    Gets a facet field by label.
    • label: string - Label of the facet field
    • Returns FacetField - Facet field data
  • getFacetQuery(label: string): FacetQuery
    Gets a facet query by label.
    • label: string - Label of the query
    • Returns FacetQuery - Facet query data
  • getPrimarySorting(): SearchSortingDefinition
    Gets the primary sorting definition.
  • getQueryGroup(query: any): any
    Gets the query group.
    • query: any - Target query
    • Returns any - Query group
  • getSortingOptions(): SearchSortingDefinition[]
    Gets all pre-configured sorting options that users can choose from.
  • getUserFacetBuckets(field: string): FacetFieldBucket[]
    Gets the buckets currently added to a field
  • removeFilterQuery(query: string)
    Removes an existing filter query.
    • query: string - The query to remove
  • removeUserFacetBucket(field: FacetField, bucket: FacetFieldBucket)
    Removes an existing bucket from a field.
  • resetToDefaults()
    Resets the query to the defaults specified in the app config.
  • update()
    Builds the current query and triggers the updated event.

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);
    });

}

Note: Since ADF 3.0.0, the query contains the "facetFormat": "V2" parameter so that all the responses have the same structure even if coming from search queries containing facetFields, facetQueries, grouped facetQueries or facetIntervals.

See also