1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[Confluence] CQLでContent Propertyをまとめて取得する

Last updated at Posted at 2019-08-26

ConfluenceはContent(ページ、コメントなどいろいろ)に、メタデータを保存することができる「Content Property」という機能がある。埋め込んだメタデータはREST APIから操作できるだけでなく、CQLで条件に該当する全部のメタデータを取得することも可能となっている。

この機能を使えば、各ページに埋め込んだ情報の統計データをすぐに収集できるので、WikiをただのWebサイトとしてではなく、情報収集にも活用することができるようになる。

もし、集計の実現を?expand=body.storageで内部保存形式を取得、解析してから行おうなんて考えているなら、ページごとにJavascriptを仕込んで、Content Propertyに保存することを考えた方が処理負荷的に賢明だと思う。

Content Propertyの取得方法

Content Propertyでキーがkeyの物を取得する方法は以下の3通りある。一括で複数取得できるのは、Content(Search)だけの模様。

API 対象 リクエストURI
Property 単一 /rest/api/content/{id}/property/{key}
Content(GetById) 単一 /rest/api/content/{id}?expand=metadata.properties.{key}
Content(Search) 複数 /rest/api/content/search?cql={cql}&expand=metadata.properties.{key}

備考: /rest/api/content/**{id}**?expand=metadata.propertiesを実行すると、metadata.properties._expandableに、利用可能なkeyが列挙される。

CQL

cqlに指定できる文字列は、「Advanced Searching using CQL」で書かれている条件式となる。「Content properties in the REST API」によると、CQLでContent Propertyの値に対してcontent.property[<KEY>].<PATH> <OPERATOR> valueという式で条件を設定することができるようだった。いくつかサンプルを作ってみて試してみようと思う。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?