Edit this topic

Search part

: request

: search-part

: search-part-handler

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

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


A content part that can query a full-text search index and present the results.

Kind: global constant

SearchPart.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.
[where] string A where expression. It can refer to the index entry to filter as entry. It evaluates as a Boolean.
[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.
[queryParameter] string The name for the querystring parameter for the query. The default is 'q'. Using different query parameter names enables multiple search results on the same page to have independent queries.
[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 SearchPart

Param Type Description
context object The context object.
context.part object The text 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.