执行搜索。

query(search)

参数

  • search
    search对象,具体定义如下:
search
{
    query: string,          mandatory, in appropriate format and encoded for the given language
    store: string,          optional, defaults to 'workspace://SpacesStore'
    language: string,       optional, one of: lucene, xpath, jcr-xpath, fts-alfresco - defaults to 'lucene'
    templates: [],          optional, Array of query language template objects (see below) - if supported by the language 
    sort: [],               optional, Array of sort column objects (see below) - if supported by the language
    page: object,           optional, paging information object (see below) - if supported by the language
    namespace: string,      optional, the default namespace for properties
    defaultField: string,   optional, the default field for query elements when not explicit in the query
    onerror: string         optional, result on error - one of: exception, no-results - defaults to 'exception'
}

sort
{
    column: string,         mandatory, sort column in appropriate format for the language
    ascending: boolean      optional, defaults to false
}

page
{
    maxItems: int,          optional, max number of items to return in result set
    skipCount: int          optional, number of items to skip over before returning results
}

template
{
    field: string,          mandatory, custom field name for the template
    template: string        mandatory, query template replacement for the template
}

返回值

将搜索结果以ScriptNode对象数组格式返回。

代码例

search对象可以像以下一样简单定义:

var results = search.query({query: "TEXT:alfresco"});

或者如下详细定义:

var sort1 = {
  column: "@{http://www.alfresco.org/model/content/1.0}modified",
  ascending: false
};

var sort2 = {
  column: "@{http://www.alfresco.org/model/content/1.0}created",
  ascending: false
};

var paging = {
  maxItems: 100,
  skipCount: 0
};

var def = {
  query: "cm:name:test*",
  store: "workspace://SpacesStore",
  language: "fts-alfresco",
  sort: [sort1, sort2],
  page: paging
};

var results = search.query(def);

此接口支持多列排序和任何Alfresco Content Services搜索语言。API的未来版本将允许使用其他属性扩展搜索定义对象,同时保持对之前版本的兼容性。
支持特殊的属性排序,例如:cm:content.size和cm:content.mimetype。

文档更新时间: 2020-03-01 01:56   作者:凌云文档