---
title: "属性値を渡してドキュメントを作成する方法"
slug: "creating-a-document-by-passing-attribute-values"
abstract: "インデックスドキュメントを作成するには、Sitecore SearchにインジェスションAPIを使いましょう。"
---
# 属性値を渡してドキュメントを作成する方法

Ingestion APIを使って、属性値を渡してインデックスドキュメントを作成できます。これは、属性値を渡して素早くコンテンツを追加したい場合に便利で、次のスケジュールされた再クロールを待ちたくない場合に便利です。

> !注あるいは、属性値を渡す代わりに、Ingestion APIを使ってURLやファイルから属性抽出ロジックを渡してインデックス文書を作成することもできます。 [既存のドキュメントエクストラクタを使う](https://doc.sitecore.com/search/ja/developers/search-developer-guide/using-the-ingestion-api-to-add-content-to-an-index/create-an-index-document/creating-an-index-document-by-using-an-existing-document-extractor.html "Creating an index document by using an existing document extractor") か、[新しいドキュメントエクストラクタを作成する](https://doc.sitecore.com/search/ja/developers/search-developer-guide/using-the-ingestion-api-to-add-content-to-an-index/create-an-index-document/creating-an-index-document-by-passing-a-new-document-extractor.html "Creating an index document by passing a new document extractor")こともできます。

インジェスションAPIを使って属性値を渡して文書を作成するには、POST呼び出しを行ってください。 {base-URL}/ingestion/v1/domains/{domain ID}/sources/{sourceID}/entities/{entityID}/documents?locale={locale}

このメソッドのデータモデルおよびオブジェクトおよびキーの説明については [、Ingestion API参照](https://doc.sitecore.com/search/en/developers/ingestion-api/index.html)を参照してください。 [ベースURL](https://doc.sitecore.com/search/ja/developers/search-developer-guide/the-sitecore-search-interface/the-api-access-tab.html "The API Access tab")はSearchの**Developer Resources**セクションで確認できます。

> !注インデックスドキュメントを作成する際は、データモデルで必要とマークされたすべての属性をパスしなければなりません。また、**Sitecore SearchのAttributes**セクション**Domain Settings** > > **Administration**で*必須*とマークされたすべての属性もパスしなければなりません。

例えば、*タイトル*、*説明*、*タイプ*、*URL*のフィールドを含むインデックスドキュメントを作成したい場合です。

こちらがPOST CURLのコールのサンプルです:

curl --location 'https://<base-url>/ingestion/v1/domains/<domainID>/sources/<sourceID>/entities/<entity>/documents?locale=<locale>' \\
--header 'Content-Type: application/json' \\
--header 'Authorization: <api-key>' \\
--data '{
 "document": {
 "id": "test\_id\_123",
 "fields": {
 "title": "Test blog",
 "description": "This is an awesome blog",
 "type": "blog",
 "url": "www.someURL.com"
 }
 }
}'

申請が成功した場合、以下の文200回答が届きます:

{
 "enqueued": true
}

回答では、enqueuedはSearchがこの文書をインデックスキューに追加したことを意味します。インジェスションジョブがインキューに入った後、文書の更新が**SearchのContent Collection**セクションに反映されるまでに数分かかることがあります。詳細は [「インジェスションタイミング」](https://doc.sitecore.com/search/en/users/search-user-guide/en/keep-indexes-up-to-date.html#UUID-3cc54e65-d998-5944-3949-b361448447a8_section-id235405681779258) を参照してください。