メインコンテンツまでスキップ

関連しているデータを条件にしたfilter機能

ここではfilter機能で、関連しているデータを条件にして検索をする方法を紹介します。
:R(%module_name%:q|%filter_query%|)の形式でフィルターを作成することで、
関連情報に対する絞り込み条件を指定できるほか、キーワードとタグを組み合わせて検索するなど、柔軟な検索ができます。

設定方法

事前準備

関連情報に対する絞り込みを行うためには、まずfilter_request_allow_listで利用を許可するモジュールを設定します。
以下の形式でfilter_request_allow_listを記述します。

:q|%module_name%:[%column_name1%,%column_name2%]

例::q|topics:[topics_group_id,subject]
-> サブクエリに topics_group_id, subject の指定を許可。

また、:q|tag:[:ALL]のようにサブクエリを:ALLで指定も可能です。
指定できるサブクエリは利用できる項目を参照してください。

Image from Gyazo

絞り込み条件の変化

Topics, Tag, Inquiryは、allow_listの設定内容に応じてデフォルトの絞り込み条件が変化します。

  • Topics, Tag
    • allow_listにopen_flgを含まない場合、公開状態のコンテンツ/タグのみが検索対象になります。
    • allow_listにopen_flg(または:ALL)を含む場合、非公開のコンテンツ/タグも含めて検索対象になります。
  • Inquiry
    • allow_listにstatusを含まない場合、運用中のフォームのみが検索対象になります。
    • allow_listにstatus(または:ALL)を含む場合、休止中のフォームも含めて検索対象になります。

フィルター指定例

Tag::listのAPIでtopics_group_id=1 のコンテンツに紐付くタグを取得

filter: :R(topics:q|topics_group_id eq 1|)
filter_request_allow_list: :q|topics:[topics_group_id]
Image from Gyazo

Topics::listのAPIでtag_id=50 のタグに紐付くコンテンツを取得

filter: :R(tag:q|tag_id in [50]|)
filter_request_allow_list: :q|tag:[tag_id]
Image from Gyazo

Topics::listのAPIでキーワードとタグでAND検索

filter: search_keyword contains "テスト" AND :R(tag:q|tag_id in [50]|)
filter_request_allow_list:[search_keyword,:q|tag:[tag_id]]
Image from Gyazo

Topics::listのAPIで特定のタグ内でOR検索をし、それぞれをAND検索する

filter: :R(tag:q|tag_id in [7,8,9]|) AND :R(tag:q|tag_id in [5,6]|)
filter_request_allow_list: :q|tag:[tag_id] Image from Gyazo

利用できる項目

現状、サブクエリに指定できるのは限られた標準項目のみに限定されています。
利用できるmodule_nameとそのサブクエリ(column_name)は以下となります。

Topics

topics_id
topics_group_id
contents_type
subject
open_flg
topics_flg
regular_flg
inst_ymdhi
update_ymdhi

Member

member_id
group_ids
inst_ymdhi
update_ymdhi

Inquiry

inquiry_id
inquiry_name
status
inst_ymdhi
update_ymdhi

Tag

tag_id
tag_nm
open_flg
inst_ymdhi
update_ymdhi
tag_category_id
ext_col_01
ext_col_02
ext_col_03
ext_col_04
ext_col_05
ext_col_06
ext_col_07
ext_col_08
ext_col_09
ext_col_10


サポート

お探しのページは見つかりましたか?解決しない場合は、問い合わせフォームからお問い合わせいただくか、Slackコミュニティにご参加ください。