search_by_attribute
Search MLIT Data Platform metadata using specific attributes like catalog name, dataset ID, prefecture code, or municipality to find relevant datasets with optional keyword refinement.
Instructions
メタデータ項目を用いて検索する。例えば、カタログ名、データセット名、都道府県、市区町村等を設定して検索することが可能。 属性フィルタで検索(GraphQL公式形のみ): attributeFilter { attributeName: "DPF:...", is: }。operatorは常に is。
使い方:
- 属性(attribute_name)と値(attribute_value)を指定してメタデータ検索を行う。
- キーワード(term)を併用して、より細かい条件指定も可能。
例:
- 特定データセット内の検索:
attribute_name="DPF:dataset_id", attribute_value="mlit-001", term="橋梁"
- 東京都に属するデータ:
attribute_name="DPF:prefecture_code", attribute_value="13"
- データカタログ単位で検索:
attribute_name="DPF:catalog_id", attribute_value="mlit-cat-001", term=""
注意:
- attribute_name には DPF:prefix を含む正式属性名を指定してください(例: "DPF:dataset_id")。
- attribute_value の型は文字列または数値。operator は常に "is" 固定。
- term="" の場合でも属性条件のみで検索可能。
- minimal=True を指定すると軽量レスポンスになります。Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| term | No | 検索キーワード。属性のみで検索する場合は空文字列""または省略可能 | |
| first | No | 検索結果の開始位置 | |
| size | No | 取得件数(最大500) | |
| phrase_match | No | フレーズマッチモード | |
| attribute_name | Yes | 属性名(必須)。ネームスペースプレフィックス付き。 例: - DPF:dataset_id (データセットID) - DPF:prefecture_code (都道府県コード) - DPF:municipality_code (市区町村コード) - DPF:year (年度) - DPF:catalog_id (カタログID) - RSDB:tenken.nendo (点検年度 - 道路施設) - PLATEAU:... (PLATEAU関連属性) プレフィックスがない場合、一般的な属性には自動的にDPF:が追加されます | |
| attribute_value | Yes | 属性値(必須)。'is'オペレータで完全一致検索します。 例: - dataset_id: 'mlit-plateau-2023' - prefecture_code: '13' (東京都) - year: '2023' - municipality_code: '13101' (千代田区) 数値コードの場合、normalize_codesで正規化してから使用することを推奨 | |
| minimal | No | 最小限のフィールドのみ返す |
Implementation Reference
- src/client.py:698-719 (handler)The raw implementation of searching by attribute, which builds a GraphQL query with an attribute filter.
async def search_by_attribute_raw( self, *, term: Optional[str] = None, first: int = 0, size: int = 20, phrase_match: bool = True, attribute_name: str, attribute_value: Any, fields: Optional[str] = None, ) -> Dict[str, Any]: af = self.make_single_attribute_filter(attribute_name, attribute_value) effective_term = term if term is not None else "" q = self.build_search( term=effective_term, first=first, size=size, phrase_match=phrase_match, attribute_filter=af, fields=fields or self._fields_basic(), ) return await self.post_query(q) - src/server.py:1290-1303 (registration)Registration/handler logic for the search_by_attribute tool within the server's call_tool function.
elif name == "search_by_attribute": # GraphQL (attribute_name + attribute_value; operator is) p = SearchByAttr.model_validate(arguments) fields = None if not p.minimal else client._fields_min() data = await client.search_by_attribute_raw( term=p.term, first=p.first, size=p.size, phrase_match=p.phrase_match, attribute_name=p.attribute_name, attribute_value=p.attribute_value, fields=fields, ) - src/server.py:259-281 (schema)Tool definition and input schema for search_by_attribute, including descriptions and usage examples.
name="search_by_attribute", description="""メタデータ項目を用いて検索する。例えば、カタログ名、データセット名、都道府県、市区町村等を設定して検索することが可能。 属性フィルタで検索(GraphQL公式形のみ): attributeFilter { attributeName: "DPF:...", is: <value> }。operatorは常に is。 使い方: - 属性(attribute_name)と値(attribute_value)を指定してメタデータ検索を行う。 - キーワード(term)を併用して、より細かい条件指定も可能。 例: - 特定データセット内の検索: attribute_name="DPF:dataset_id", attribute_value="mlit-001", term="橋梁" - 東京都に属するデータ: attribute_name="DPF:prefecture_code", attribute_value="13" - データカタログ単位で検索: attribute_name="DPF:catalog_id", attribute_value="mlit-cat-001", term="" 注意: - attribute_name には DPF:prefix を含む正式属性名を指定してください(例: "DPF:dataset_id")。 - attribute_value の型は文字列または数値。operator は常に "is" 固定。 - term="" の場合でも属性条件のみで検索可能。 - minimal=True を指定すると軽量レスポンスになります。""",