0
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?

Azure AI Search で SharePoint Online のインデックスを作成する

Posted at

参考にしたもの

公式: SharePoint Online インデクサー (プレビュー) - Azure AI Search | Microsoft Learn

先人の知恵:
【Microsoft×生成AI連載】【やってみた】Azure AI SearchでSharePoint Onlineのインデックスを作成してみた - JBS Tech Blog
Azure Cognitive Search(Azure AI Search)で SharePoint ドキュメントのインデックスを作成する #CognitiveSearch - Qiita

API

データ ソース

POST https://<service name>.search.windows.net/datasources?api-version=2024-05-01-preview
Content-Type: application/json
api-key: <api-key>

{
    "name" : "sharepoint-datasource",
    "type" : "sharepoint",
    "credentials" : { "connectionString" : "SharePointOnlineEndpoint=<接続文字列>" },
    "container" : { "name" : "defaultSiteLibrary", "query" : null }
}

接続文字列の形式
接続文字列の形式は、インデクサーが委任された API のアクセス許可を使用しているか、アプリケーション API のアクセス許可を使用しているかに基づいて変化します。

委任された API のアクセス許可の接続文字列の形式
SharePointOnlineEndpoint=[SharePoint site url];ApplicationId=[Azure AD App ID];TenantId=[SharePoint site tenant id]

アプリケーション API のアクセス許可の接続文字列の形式
SharePointOnlineEndpoint=[SharePoint site url];ApplicationId=[Azure AD App ID];ApplicationSecret=[Azure AD App client secret];TenantId=[SharePoint site tenant id]

インデックス

POST https://<service name>.search.windows.net/indexes?api-version=2024-05-01-preview
Content-Type: application/json
api-key: <api-key>

{
    "name" : "sharepoint-index",
    "fields": [
        { "name": "id", "type": "Edm.String", "key": true, "searchable": false },
        { "name": "metadata_spo_item_name", "type": "Edm.String", "key": false, "searchable": true, "filterable": false, "sortable": false, "facetable": false },
        { "name": "metadata_spo_item_path", "type": "Edm.String", "key": false, "searchable": false, "filterable": false, "sortable": false, "facetable": false },
        { "name": "metadata_spo_item_content_type", "type": "Edm.String", "key": false, "searchable": false, "filterable": true, "sortable": false, "facetable": true },
        { "name": "metadata_spo_item_last_modified", "type": "Edm.DateTimeOffset", "key": false, "searchable": false, "filterable": false, "sortable": true, "facetable": false },
        { "name": "metadata_spo_item_size", "type": "Edm.Int64", "key": false, "searchable": false, "filterable": false, "sortable": false, "facetable": false },
        { "name": "content", "type": "Edm.String", "searchable": true, "filterable": false, "sortable": false, "facetable": false }
    ]
}

インデクサー

GET https://<service name>.search.windows.net/indexers/sharepoint-indexer/status?api-version=2024-05-01-preview
Content-Type: application/json
api-key: <api-key>
POST https://<service name>.search.windows.net/indexers?api-version=2024-05-01-preview
Content-Type: application/json
api-key: <api-key>

{
    "name" : "sharepoint-indexer",
    "dataSourceName" : "sharepoint-datasource",
    "targetIndexName" : "sharepoint-index",
    "parameters": {
    "batchSize": null,
    "maxFailedItems": null,
    "maxFailedItemsPerBatch": null,
    "base64EncodeKeys": null,
    "configuration": {
        "indexedFileNameExtensions" : ".pdf, .docx, .json, .txt, .xlsx",
        "excludedFileNameExtensions" : ".png, .jpg",
        "dataToExtract": "contentAndMetadata"
      }
    },
    "schedule" : { },
    "fieldMappings" : [
        { 
          "sourceFieldName" : "metadata_spo_site_library_item_id", 
          "targetFieldName" : "id", 
          "mappingFunction" : { 
            "name" : "base64Encode" 
          } 
         }
    ]
}

テナント

アプリの登録 をするテナントと SharePoint のテナントを同一にした。

検索対象

UTF-8 で準備。
image.png

image.png

以上メモです。

0
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
0
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?