Edit this topic

Query part

: request

: query-part

: query-part-handler

: /modules/core/search/services/query-part.js

: https://github.com/DecentCMS/DecentCMS/blob/master/modules/core/search/services/query-part.js


A content part that can query a query index and present the results.

Kind: global variable

QueryPart.handle(context, done)

Adds a search-results shape to context.shapes that has the aggregated result for the search on its result property.

If pagination is used, a second paginationshape is also added.

The search to perform is specified on context.part.

The part has the following properties:

Property Type Description
indexName string The name of the index to use or create.
[idFilter] string A filter regular expression to apply to item ids before they are handed to the indexing process.
map string A mapping expression for the index. It can refer to the passed-in content item as item. It can evaluate as null, an object, or an array of objects.
orderBy string An ordering expression for the index. It can refer to the passed-in index entry as entry. It can evaluate as an object, or an array.
[where] string A where expression. It can refer to the index entry to filter as entry and to the parsed query string as query. It evaluates as a Boolean.
[reduce] string A reduce expression. It can refer to the previous value as val, the index entry as entry, and the index of the entry as i. It evaluates as the new value. The part will pass null as the first initial value, so the function should create what it needs if it sees null. If not specified, an array of index entries is the result.
[page] number The 0-based page number to display. The default is 0. The page number will be overwritten with the value from the querystring if there is one.
[pageSize] number The size of the page. If zero, all results are shown. The default value is 10.
[pageParameter] string The name for the pagination parameter that will be added to the querystring on pagination. The default is 'p'. Using different page parameter names enables multiple search results to have independent pagination.
[displayPages] Boolean True if page numbers should be displayed in pagination.
[displayNextPrevious] Boolean True if pagination should have next and previous buttons.
[displayFirstLast] Boolean True if buttons to go to the first and last pages should be displayed by pagination.

Kind: static method of QueryPart

Param Type Description
context object The context object.
context.part object The query part to handle.
context.partName string The name of the part.
context.displayType string The display type.
context.item object A reference to the content item.
context.shapes Array The shapes array to which new shapes must be pushed.
context.scope object The scope.
done function The callback.