Alfresco API

POST /search

基本信息

Note: 该端点在Alfresco 5.2和更高版本中可用。

您可以在JSON主体中指定此API中的所有参数(You specify all the parameters in this API in a JSON body),不支持URL参数。 基本查询如下所示:

{
  "query": {
    "query": "foo"
  }
}

Note: 这些是可能的最小查询参数。

默认的search语言是afts(Alfresco全文search),但是您也可以指定cmislucene

基本的CMIS查询如下所示:

{
  "query": {
    "query": "select * from cmis:folder",
    "language": "cmis"
  }
}

默认情况下,结果限制为前100个(results are limited to the first 100)。可以使用“分页”限制结果。 例如:

"paging": {
  "maxItems": "50",
  "skipCount": "28"
}

本示例将确保结果受最终大小的限制(limited by Final Size),跳过前28个结果并返回下一个50。

另外,您可以使用limits JSON body参数来限制(limits JSON body parameter)结果。 例如,

"limits": {
  "permissionEvaluationTime": 20000,
  "permissionEvaluationCount": 2000
}

您可以使用include JSON body parameter返回其他信息。 这与核心API中的/ nodes / {nodeId} / children方法中的工作方式相同。 例如

"include": ["aspectNames", "properties", "isLink"]

例如,如果您想节省整体带宽,则可以使用fields JSON body parameter来限制响应中返回的字段。 这与核心API中的/ nodes / {nodeId} / children方法中的工作方式相同。 例如:

"fields": ["id", "name", "search"]

您可以使用sort JSON body parameter对结果进行排序,例如:

"sort": [{"type":"FIELD", "field":"cm:description", "ascending":"true"}]

Note: CMIS查询不支持sort参数。

默认情况下,search使用“节点”位置(“nodes” location),该位置是称为“ workspace:// SpacesStore”的内容存储( content store known as workspace://SpacesStore)。 要将范围更改为另一个位置,可以使用 locations JSON body parameter。 您可以指定节点nodes(默认),版本versions或已删除节点deleted-nodes。 例如,

"scope": {
    "locations": ["deleted-nodes"]
}

您可以使用templates JSON body parameter指定模板,例如:

"templates": [{"name": "_PERSON","template": "|%firstName OR |%lastName OR |%userName"},
              {"name": "mytemplate","template": "%cm:content"}]

Note:如果已经启用建议,则拼写检查仅在Search Services(Solr 6)上有效。(Spell checking only works on Search Services (Solr 6) if you have already enabled suggestions.

对于拼写检查(spell checking),您可以使用如下查询:

{
  "query": {
    "query": "cm:title:alfrezco"
  },
  "spellcheck": {"query": "alfrezco"}
}

如果您已经指定“ userQuery”,则以下操作可能会更容易并且产生相同的结果:

{
  "query": {
    "query": "cm:title:alfrezco",
    "userQuery": "alfrezco"
  },
  "spellcheck": {}
}

拼写检查响应包括拼写检查上下文:

"context": {
  "spellCheck": {
    "type": "searchInsteadFor",
    "suggestions": ["alfresco"]
  }
},

要指定默认值,请使用defaults JSON body parameter,例如:

"defaults": {
  "textAttributes": [
    "cm:content", "cm:name"
  ],
  "defaultFTSOperator": "AND",
  "defaultFTSFieldOperator": "OR",
  "namespace": "cm",
  "defaultFieldName": "PATH"
}

您可以使用filterQueries JSON body parameter指定多个过滤器查询,例如:

"filterQueries": [{"query": "TYPE:'cm:folder'"},{"query": "cm:creator:mjackson"}]

您可以使用facetQueries JSON body parameter指定多个构面查询,例如:

"facetQueries": [{"query": "created:2016","label": "CreatedThisYear"}]

响应将包含匹配的“上下文”部分,“标签”将匹配构面查询。

"context": {
  "facetQueries": [
    {"label": "CreatedThisYear","count": 3}
  ]
},

通过content.size字段进行分面的完整查询如下所示:

{
  "query": {
    "query": "presentation",
    "language": "afts"
  },
    "facetQueries": [
        {"query": "content.size:[0 TO 10240]", "label": "xtra small"},
        {"query": "content.size:[10240 TO 102400]", "label": "small"},
        {"query": "content.size:[102400 TO 1048576]", "label": "medium"},
        {"query": "content.size:[1048576 TO 16777216]", "label": "large"},
        {"query": "content.size:[16777216 TO 134217728]", "label": "xtra large"},
        {"query": "content.size:[134217728 TO MAX]", "label": "XX large"}
  ],
    "facetFields": {"facets": [{"field": "'content.size'"}]}
}

响应将包含匹配的“上下文”部分,“标签”将匹配构面查询。

"context": {
  "facetQueries": [
    { "label": "small","count": 2 },
    { "label": "large","count": 0 },
    { "label": "xtra small","count": 5 },
    { "label": "xtra large","count": 56},
    { "label": "medium","count": 4 },
    { "label": "XX large", "count": 1 }
  ]
},

您可以使用 facetFields JSON body parameter指定多个构面字段,例如:

"facetFields": {"facets": [{"field": "creator", "mincount": 1}, {"field": "modifier", "mincount": 1}]}

响应将包含匹配的“上下文”部分,“标签”将匹配构面字段。

"context": {
   "facetsFields": [
     {  "label": "creator",
        "buckets": [
          { "label": "System", "count": 75 },
          { "label": "mjackson", "count": 5 }
        ]},
     {  "label": "modifier",
        "buckets": [
          { "label": "System", "count": 72 },
          { "label": "mjackson", "count": 5 },
          { "label": "admin", "count": 3 }
        ]}
   ]
},

可以通过在事实查询中指定组标签来对组合在一起的构面查询进行分组,如下所示:

    {
        "query": {
            "query": "presentation"
        },
        "facetQueries": [
            {"query": "content.size:[0 TO 102400]", "label": "small", "group":"foo"},
            {"query": "content.size:[102400 TO 1048576]", "label": "medium","group":"foo"},
            {"query": "content.size:[1048576 TO 16777216]", "label": "large","group":"foo"}
        ]
    }

上面的查询返回结果,其分面字段分组在标签foo下:

{
    "context": {"facetsFields": [{
        "label": "foo",
        "buckets": [
            {
                "count": 109,
                "label": "small",
                "filterQuery": "content.size:[0 TO 102400]"
            },
            {
                "count": 0,
                "label": "large",
                "filterQuery": "content.size:[1048576 TO 16777216]"
            },
            {
                "count": 0,
                "label": "medium",
                "filterQuery": "content.size:[102400 TO 1048576]"
            }
        ]
    }]
}

ranges JSON body parameter支持Range Faceting,例如:

   {
        "query": {
            "query": "presentation"
        },
        "ranges": [
        {
            "field": "content.size",
             "start": "0",
             "end": "100",
             "gap": "20",
             "hardend": true
        },
        {
            "field": "created",
            "start": "2015-09-29T10:45:15.729Z",
            "end": "2016-09-29T10:45:15.729Z",
            "gap": "+100DAY"
        }]
    }

search突出显示(search highlighting)的示例查询如下所示:

{
  "query": {
    "query": "description:workflow",
    "userQuery":"workflow"
  },
  "highlight": {
    "prefix": "¿",
    "postfix": "?",
    "mergeContiguous": true,
    "fields": [
      {
        "field": "cm:title"
      },
      {
        "field": "description",
        "prefix": "(",
        "postfix": ")"
      }

    ]
  }
}

上面的示例将突出显示的前缀和后缀从所有字段的默认值更改为 ¿? 并且仅用于()的“说明”字段。 重要信息添加到每个节点条目响应中; 这是部分响应的示例:

"entry": {
        "createdAt": "2016-10-12T15:24:31.202+0000",
        "isFolder": true,
        "search": {
          "score": 1,
          "highlight": [
            {
              "field": "cm:title",
              "snippets": [
                "Customized ¿Workflow? Process Definitions"
              ]
            },
            {
              "field": "description",
              "snippets": [
                "Customized (Workflow) Process Definitions"
              ]
            }
          ]
      },

请求方式 :POST

请求API :/search

响应等级(状态200)

成功回应

{
  "list": {
    "pagination": {
      "count": 0,
      "hasMoreItems": true,
      "totalItems": 0,
      "skipCount": 0,
      "maxItems": 0
    },
    "context": {
      "consistency": {
        "lastTxId": 0
      },
      "request": {
        "query": {
          "language": "afts",
          "userQuery": "string",
          "query": "string"
        },
        "paging": {
          "maxItems": 100,
          "skipCount": 0
        },
        "include": [
          "allowableOperations"
        ],
        "includeRequest": false,
        "fields": [
          "string"
        ],
        "sort": [
          {
            "type": "FIELD",
            "field": "string",
            "ascending": false
          }
        ],
        "templates": [
          {
            "name": "string",
            "template": "string"
          }
        ],
        "defaults": {
          "textAttributes": [
            "cm:content"
          ],
          "defaultFTSOperator": "AND",
          "defaultFTSFieldOperator": "AND",
          "namespace": "cm",
          "defaultFieldName": "TEXT"
        },
        "localization": {
          "timezone": "string",
          "locales": [
            "string"
          ]
        },
        "filterQueries": [
          {
            "query": "string",
            "tags": [
              "string"
            ]
          }
        ],
        "facetQueries": [
          {
            "query": "string",
            "label": "string"
          }
        ],
        "facetFields": {
          "facets": [
            {
              "field": "string",
              "label": "string",
              "prefix": "string",
              "sort": "COUNT",
              "method": "ENUM",
              "missing": false,
              "limit": 0,
              "offset": 0,
              "mincount": 1,
              "facetEnumCacheMinDf": 0,
              "excludeFilters": [
                "string"
              ]
            }
          ]
        },
        "facetIntervals": {
          "sets": [
            {
              "label": "string",
              "start": "string",
              "end": "string",
              "startInclusive": true,
              "endInclusive": true
            }
          ],
          "intervals": [
            {
              "field": "string",
              "label": "string",
              "sets": [
                {
                  "label": "string",
                  "start": "string",
                  "end": "string",
                  "startInclusive": true,
                  "endInclusive": true
                }
              ]
            }
          ]
        },
        "pivots": [
          {
            "key": "string",
            "pivots": [
              {}
            ]
          }
        ],
        "stats": [
          {
            "field": "string",
            "label": "string",
            "min": true,
            "max": true,
            "sum": true,
            "countValues": true,
            "missing": true,
            "mean": true,
            "stddev": true,
            "sumOfSquares": true,
            "distinctValues": false,
            "countDistinct": false,
            "cardinality": false,
            "cardinalityAccuracy": 0.3,
            "excludeFilters": [
              "string"
            ],
            "percentiles": [
              0
            ]
          }
        ],
        "spellcheck": {
          "query": "string"
        },
        "scope": {
          "locations": "nodes"
        },
        "limits": {
          "permissionEvaluationTime": 20000,
          "permissionEvaluationCount": 2000
        },
        "highlight": {
          "prefix": "string",
          "postfix": "string",
          "snippetCount": 0,
          "fragmentSize": 0,
          "maxAnalyzedChars": 0,
          "mergeContiguous": true,
          "usePhraseHighlighter": true,
          "fields": [
            {
              "field": "string",
              "snippetCount": 0,
              "fragmentSize": 0,
              "mergeContiguous": true,
              "prefix": "string",
              "postfix": "string"
            }
          ]
        },
        "ranges": [
          {
            "field": "string",
            "start": "string",
            "end": "string",
            "gap": "string",
            "hardend": true,
            "other": [
              "string"
            ],
            "include": [
              "string"
            ],
            "label": "string",
            "excludeFilters": [
              "string"
            ]
          }
        ]
      },
      "facetQueries": [
        {
          "label": "string",
          "filterQuery": "string",
          "count": 0
        }
      ],
      "facetsFields": [
        {
          "label": "string",
          "buckets": [
            {
              "label": "string",
              "filterQuery": "string",
              "count": 0,
              "display": {}
            }
          ]
        }
      ],
      "facets": [
        {
          "type": "string",
          "label": "string",
          "buckets": [
            {
              "label": "string",
              "filterQuery": "string",
              "display": {},
              "metrics": [
                {
                  "type": "string",
                  "value": {}
                }
              ],
              "facets": [
                {}
              ],
              "bucketInfo": {
                "start": "string",
                "startInclusive": true,
                "end": "string",
                "endInclusive": true
              }
            }
          ]
        }
      ],
      "spellcheck": [
        {
          "type": "searchInsteadFor",
          "suggestion": [
            "string"
          ]
        }
      ]
    },
    "entries": [
      {
        "entry": {
          "id": "string",
          "name": "string",
          "nodeType": "string",
          "isFolder": true,
          "isFile": true,
          "isLocked": false,
          "modifiedAt": "2021-01-15T06:07:46.143Z",
          "modifiedByUser": {
            "displayName": "string",
            "id": "string"
          },
          "createdAt": "2021-01-15T06:07:46.143Z",
          "createdByUser": {
            "displayName": "string",
            "id": "string"
          },
          "parentId": "string",
          "isLink": true,
          "content": {
            "mimeType": "string",
            "mimeTypeName": "string",
            "sizeInBytes": 0,
            "encoding": "string",
            "mimeTypeGroup": "string"
          },
          "aspectNames": [
            "string"
          ],
          "properties": {},
          "allowableOperations": [
            "string"
          ],
          "path": {
            "elements": [
              {
                "id": "string",
                "name": "string"
              }
            ],
            "name": "string",
            "isComplete": true
          },
          "search": {
            "score": 0,
            "highlight": [
              {
                "field": "string",
                "snippets": [
                  "string"
                ]
              }
            ]
          },
          "archivedByUser": {
            "displayName": "string",
            "id": "string"
          },
          "archivedAt": "2021-01-15T06:07:46.143Z",
          "versionLabel": "string",
          "versionComment": "string"
        }
      }
    ]
  }
}

响应内容类型 applicaiton/json

Body参数(queryBody

request body示例

{
  "query": {
    "language": "afts",
    "userQuery": "string",
    "query": "string"
  },
  "paging": {
    "maxItems": 100,
    "skipCount": 0
  },
  "include": [
    "allowableOperations"
  ],
  "includeRequest": false,
  "fields": [
    "string"
  ],
  "sort": [
    {
      "type": "FIELD",
      "field": "string",
      "ascending": false
    }
  ],
  "templates": [
    {
      "name": "string",
      "template": "string"
    }
  ],
  "defaults": {
    "textAttributes": [
      "cm:content"
    ],
    "defaultFTSOperator": "AND",
    "defaultFTSFieldOperator": "AND",
    "namespace": "cm",
    "defaultFieldName": "TEXT"
  },
  "localization": {
    "timezone": "string",
    "locales": [
      "string"
    ]
  },
  "filterQueries": [
    {
      "query": "string",
      "tags": [
        "string"
      ]
    }
  ],
  "facetQueries": [
    {
      "query": "string",
      "label": "string"
    }
  ],
  "facetFields": {
    "facets": [
      {
        "field": "string",
        "label": "string",
        "prefix": "string",
        "sort": "COUNT",
        "method": "ENUM",
        "missing": false,
        "limit": 0,
        "offset": 0,
        "mincount": 1,
        "facetEnumCacheMinDf": 0,
        "excludeFilters": [
          "string"
        ]
      }
    ]
  },
  "facetIntervals": {
    "sets": [
      {
        "label": "string",
        "start": "string",
        "end": "string",
        "startInclusive": true,
        "endInclusive": true
      }
    ],
    "intervals": [
      {
        "field": "string",
        "label": "string",
        "sets": [
          {
            "label": "string",
            "start": "string",
            "end": "string",
            "startInclusive": true,
            "endInclusive": true
          }
        ]
      }
    ]
  },
  "pivots": [
    {
      "key": "string",
      "pivots": [
        {}
      ]
    }
  ],
  "stats": [
    {
      "field": "string",
      "label": "string",
      "min": true,
      "max": true,
      "sum": true,
      "countValues": true,
      "missing": true,
      "mean": true,
      "stddev": true,
      "sumOfSquares": true,
      "distinctValues": false,
      "countDistinct": false,
      "cardinality": false,
      "cardinalityAccuracy": 0.3,
      "excludeFilters": [
        "string"
      ],
      "percentiles": [
        0
      ]
    }
  ],
  "spellcheck": {
    "query": "string"
  },
  "scope": {
    "locations": "nodes"
  },
  "limits": {
    "permissionEvaluationTime": 20000,
    "permissionEvaluationCount": 2000
  },
  "highlight": {
    "prefix": "string",
    "postfix": "string",
    "snippetCount": 0,
    "fragmentSize": 0,
    "maxAnalyzedChars": 0,
    "mergeContiguous": true,
    "usePhraseHighlighter": true,
    "fields": [
      {
        "field": "string",
        "snippetCount": 0,
        "fragmentSize": 0,
        "mergeContiguous": true,
        "prefix": "string",
        "postfix": "string"
      }
    ]
  },
  "ranges": [
    {
      "field": "string",
      "start": "string",
      "end": "string",
      "gap": "string",
      "hardend": true,
      "other": [
        "string"
      ],
      "include": [
        "string"
      ],
      "label": "string",
      "excludeFilters": [
        "string"
      ]
    }
  ]
}

错误信息描述

状态码 原因
default 意外错误

返回结果示例

{
  "error": {
    "errorKey": "string",
    "statusCode": 0,
    "briefSummary": "string",
    "stackTrace": "string",
    "descriptionURL": "string",
    "logId": "string"
  }
}