国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

Azure Machine Learning - 使用 REST API 創(chuàng)建 Azure AI 搜索索引

這篇具有很好參考價值的文章主要介紹了Azure Machine Learning - 使用 REST API 創(chuàng)建 Azure AI 搜索索引。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

本文介紹如何使用 Azure AI 搜索 REST AP和用于發(fā)送和接收請求的 REST 客戶端以交互方式構(gòu)建請求。

關(guān)注TechLead,分享AI全維度知識。作者擁有10+年互聯(lián)網(wǎng)服務(wù)架構(gòu)、AI產(chǎn)品研發(fā)經(jīng)驗、團隊管理經(jīng)驗,同濟本復旦碩,復旦機器人智能實驗室成員,阿里云認證的資深架構(gòu)師,項目管理專業(yè)人士,上億營收AI產(chǎn)品研發(fā)負責人。文章來源地址http://www.zghlxwxcb.cn/news/detail-760872.html

Azure Machine Learning - 使用 REST API 創(chuàng)建 Azure AI 搜索索引,azure,人工智能,microsoft

環(huán)境準備

  • Postman 應(yīng)用,用于將請求發(fā)送到 Azure AI 搜索。

  • [創(chuàng)建 Azure AI 搜索服務(wù)]或在當前訂閱下查找現(xiàn)有服務(wù)。 可以使用本快速入門的免費服務(wù)。

復制密鑰和 URL

REST 調(diào)用需要在每個請求中使用服務(wù) URL 和訪問密鑰。 搜索服務(wù)是使用這二者創(chuàng)建的,因此,如果向訂閱添加了 Azure AI 搜索,則請按以下步驟獲取必需信息:

  1. 登錄到 Azure 門戶,在搜索服務(wù)的“概覽”頁中獲取 URL。 示例終結(jié)點可能類似于 https://mydemo.search.windows.net。

  2. 在“設(shè)置”>“密鑰”中,獲取有關(guān)該服務(wù)的完全權(quán)限的管理員密鑰 。 有兩個可交換的管理員密鑰,為保證業(yè)務(wù)連續(xù)性而提供,以防需要滾動一個密鑰。 可以在請求中使用主要或輔助密鑰來添加、修改和刪除對象。

Azure Machine Learning - 使用 REST API 創(chuàng)建 Azure AI 搜索索引,azure,人工智能,microsoft

所有請求對發(fā)送到服務(wù)的每個請求都需要 API 密鑰。 具有有效的密鑰可以在發(fā)送請求的應(yīng)用程序與處理請求的服務(wù)之間建立信任關(guān)系,這種信任關(guān)系以每個請求為基礎(chǔ)。

連接到 Azure AI 搜索

連接信息在 URI 終結(jié)點中指定。 集合變量用于表示搜索服務(wù)名稱和 API 密鑰。 本快速入門中的典型 URI 如下所示:

https://{{service-name}}.search.windows.net/indexes/hotels-quickstart?api-version=2020-06-30

請注意 HTTPS 前綴、服務(wù)變量的名稱、對象的名稱(在本例中為索引集合中的某個索引的名稱)和 api-version。 api-version 是必需的。

請求頭組合包括兩個元素:Content-Type,以及用于向 Azure AI 搜索進行身份驗證的 api-key。 api-key 指定為變量,也是必需的。

若要使請求成功,需要提供服務(wù)名稱和 api-key 作為集合變量。

  1. 打開 Postman 應(yīng)用并導入集合。

  2. 選擇集合的訪問菜單,選擇“編輯”,并提供搜索服務(wù)的服務(wù)名稱和密鑰。
    Azure Machine Learning - 使用 REST API 創(chuàng)建 Azure AI 搜索索引,azure,人工智能,microsoft

1 - 創(chuàng)建索引

在 Azure AI 搜索中,通常會先創(chuàng)建索引,然后再連同數(shù)據(jù)一起加載索引。 本任務(wù)將使用[創(chuàng)建索引 REST API]。

需擴展 URL 以包含 hotels-quickstart 索引名稱。

  1. 將謂詞設(shè)置為 PUT。

  2. 復制此 URL https://{{service-name}}.search.windows.net/indexes/hotels-quickstart?api-version=2020-06-30。

  3. 在請求正文中提供索引定義(接下來提供可直接復制的代碼)。

  4. 選擇“發(fā)送”。

Azure Machine Learning - 使用 REST API 創(chuàng)建 Azure AI 搜索索引,azure,人工智能,microsoft

索引定義

字段集合定義文檔結(jié)構(gòu)。 每個文檔必須包含這些字段,每個字段必須具有一個數(shù)據(jù)類型。 字符串字段用于全文搜索。 如果你需要使數(shù)值數(shù)據(jù)可供搜索,則需要將數(shù)值數(shù)據(jù)強制轉(zhuǎn)換為字符串。

字段的屬性決定了允許的操作。 默認情況下,REST API 允許很多操作。 例如,默認情況下,所有字符串均可供搜索、檢索、篩選、分面。 通常,僅當需要禁用某種行為時,才要設(shè)置屬性。

{
    "name": "hotels-quickstart",  
    "fields": [
        {"name": "HotelId", "type": "Edm.String", "key": true, "filterable": true},
        {"name": "HotelName", "type": "Edm.String", "searchable": true, "filterable": false, "sortable": true, "facetable": false},
        {"name": "Description", "type": "Edm.String", "searchable": true, "filterable": false, "sortable": false, "facetable": false, "analyzer": "en.lucene"},
        {"name": "Category", "type": "Edm.String", "searchable": true, "filterable": true, "sortable": true, "facetable": true},
        {"name": "Tags", "type": "Collection(Edm.String)", "searchable": true, "filterable": true, "sortable": false, "facetable": true},
        {"name": "ParkingIncluded", "type": "Edm.Boolean", "filterable": true, "sortable": true, "facetable": true},
        {"name": "LastRenovationDate", "type": "Edm.DateTimeOffset", "filterable": true, "sortable": true, "facetable": true},
        {"name": "Rating", "type": "Edm.Double", "filterable": true, "sortable": true, "facetable": true},
        {"name": "Address", "type": "Edm.ComplexType", 
        "fields": [
        {"name": "StreetAddress", "type": "Edm.String", "filterable": false, "sortable": false, "facetable": false, "searchable": true},
        {"name": "City", "type": "Edm.String", "searchable": true, "filterable": true, "sortable": true, "facetable": true},
        {"name": "StateProvince", "type": "Edm.String", "searchable": true, "filterable": true, "sortable": true, "facetable": true},
        {"name": "PostalCode", "type": "Edm.String", "searchable": true, "filterable": true, "sortable": true, "facetable": true},
        {"name": "Country", "type": "Edm.String", "searchable": true, "filterable": true, "sortable": true, "facetable": true}
        ]
     }
  ]
}

提交此請求后,會獲得 HTTP 201 響應(yīng),指示索引已成功創(chuàng)建。 可以在門戶中驗證此操作,但請注意,門戶頁有刷新時間間隔,因此可能需要等待一到兩分鐘。

2 - 加載文檔

創(chuàng)建索引和填充索引是分開的步驟。 在 Azure AI 搜索中,索引包含所有可搜索的數(shù)據(jù)。 在此場景中,數(shù)據(jù)以 JSON 文檔的形式提供。 本任務(wù)將使用[添加、更新或刪除文檔 REST API]。

需擴展 URL 以包含 docs 集合與 index 操作。

  1. 將謂詞設(shè)置為 POST。

  2. 復制此 URL https://{{service-name}}.search.windows.net/indexes/hotels-quickstart/docs/index?api-version=2020-06-30

  3. 在請求的正文中提供 JSON 文檔(接下來提供可直接復制的代碼)。

  4. 選擇“發(fā)送”。

Azure Machine Learning - 使用 REST API 創(chuàng)建 Azure AI 搜索索引,azure,人工智能,microsoft

要載入索引的 JSON 文檔

請求正文包含四個要添加到 hotels 索引的文檔。

{
    "value": [
    {
    "@search.action": "upload",
    "HotelId": "1",
    "HotelName": "Secret Point Motel",
    "Description": "The hotel is ideally located on the main commercial artery of the city in the heart of New York. A few minutes away is Time's Square and the historic centre of the city, as well as other places of interest that make New York one of America's most attractive and cosmopolitan cities.",
    "Category": "Boutique",
    "Tags": [ "pool", "air conditioning", "concierge" ],
    "ParkingIncluded": false,
    "LastRenovationDate": "1970-01-18T00:00:00Z",
    "Rating": 3.60,
    "Address": 
        {
        "StreetAddress": "677 5th Ave",
        "City": "New York",
        "StateProvince": "NY",
        "PostalCode": "10022",
        "Country": "USA"
        } 
    },
    {
    "@search.action": "upload",
    "HotelId": "2",
    "HotelName": "Twin Dome Motel",
    "Description": "The hotel is situated in a  nineteenth century plaza, which has been expanded and renovated to the highest architectural standards to create a modern, functional and first-class hotel in which art and unique historical elements coexist with the most modern comforts.",
    "Category": "Boutique",
    "Tags": [ "pool", "free wifi", "concierge" ],
    "ParkingIncluded": false,
    "LastRenovationDate": "1979-02-18T00:00:00Z",
    "Rating": 3.60,
    "Address": 
        {
        "StreetAddress": "140 University Town Center Dr",
        "City": "Sarasota",
        "StateProvince": "FL",
        "PostalCode": "34243",
        "Country": "USA"
        } 
    },
    {
    "@search.action": "upload",
    "HotelId": "3",
    "HotelName": "Triple Landscape Hotel",
    "Description": "The Hotel stands out for its gastronomic excellence under the management of William Dough, who advises on and oversees all of the Hotel’s restaurant services.",
    "Category": "Resort and Spa",
    "Tags": [ "air conditioning", "bar", "continental breakfast" ],
    "ParkingIncluded": true,
    "LastRenovationDate": "2015-09-20T00:00:00Z",
    "Rating": 4.80,
    "Address": 
        {
        "StreetAddress": "3393 Peachtree Rd",
        "City": "Atlanta",
        "StateProvince": "GA",
        "PostalCode": "30326",
        "Country": "USA"
        } 
    },
    {
    "@search.action": "upload",
    "HotelId": "4",
    "HotelName": "Sublime Cliff Hotel",
    "Description": "Sublime Cliff Hotel is located in the heart of the historic center of Sublime in an extremely vibrant and lively area within short walking distance to the sites and landmarks of the city and is surrounded by the extraordinary beauty of churches, buildings, shops and monuments. Sublime Cliff is part of a lovingly restored 1800 palace.",
    "Category": "Boutique",
    "Tags": [ "concierge", "view", "24-hour front desk service" ],
    "ParkingIncluded": true,
    "LastRenovationDate": "1960-02-06T00:00:00Z",
    "Rating": 4.60,
    "Address": 
        {
        "StreetAddress": "7400 San Pedro Ave",
        "City": "San Antonio",
        "StateProvince": "TX",
        "PostalCode": "78216",
        "Country": "USA"
        }
    }
  ]
}

在幾秒鐘內(nèi),應(yīng)在會話列表中看到 HTTP 201 響應(yīng)。 這指示已成功創(chuàng)建文檔。

如果收到 207,則指示至少有一個文檔無法上傳。 如果收到 404,則表示請求的標頭或正文有語法錯誤:請驗證是否已更改終結(jié)點,使之包括 /docs/index。

提示

對于所選數(shù)據(jù)源,可[創(chuàng)建索引器],這可簡化并減少索引所需的代碼量。

3 - 搜索索引

現(xiàn)在,索引和文檔集已加載,可以使用搜索文檔 REST API 針對它們發(fā)出查詢了。

需擴展 URL,以包含使用搜索運算符指定的查詢表達式。

  1. 將謂詞設(shè)置為 GET。

  2. 復制此 URL https://{{service-name}}.search.windows.net/indexes/hotels-quickstart/docs?search=*&$count=true&api-version=2020-06-30。

  3. 選擇Send

此查詢?yōu)榭?,在搜索結(jié)果中返回文檔的計數(shù)。 在選擇“發(fā)送”后,請求和響應(yīng)應(yīng)類似于以下針對 Postman 的屏幕截圖。 狀態(tài)代碼應(yīng)為 200。
Azure Machine Learning - 使用 REST API 創(chuàng)建 Azure AI 搜索索引,azure,人工智能,microsoft
嘗試其他查詢示例來了解語法。 你可以執(zhí)行字符串搜索、逐字篩選查詢、限制結(jié)果集、將搜索范圍限定為特定字段等。

# Query example 1 - Search on restaurant and wifi
# Return only the HotelName, Description, and Tags fields
https://{{service-name}}.search.windows.net/indexes/hotels-quickstart/docs?search=restaurant wifi&$count=true&$select=HotelName,Description,Tags&api-version=2020-06-30

# Query example 2 - Apply a filter to the index to find hotels rated 4 or highter
# Returns the HotelName and Rating. Two documents match
https://{service-name}}.search.windows.net/indexes/hotels-quickstart/docs?search=*&$filter=Rating gt 4&$select=HotelName,Rating&api-version=2020-06-30

# Query example 3 - Take the top two results, and show only HotelName and Category in the results
https://{service-name}}.search.windows.net/indexes/hotels-quickstart/docs?search=boutique&$top=2&$select=HotelName,Category&api-version=2020-06-30

# Query example 4 - Sort by a specific field (Address/City) in ascending order
https://{service-name}}.search.windows.net/indexes/hotels-quickstart/docs?search=pool&$orderby=Address/City asc&$select=HotelName, Address/City, Tags, Rating&api-version=2020-06-30

獲取索引屬性

還可以使用獲取統(tǒng)計信息來查詢文檔計數(shù)和索引大?。?/p>

https://{{service-name}}.search.windows.net/indexes/hotels-quickstart/stats?api-version=2020-06-30

向 URL 添加 /stats 會返回索引信息。 在 Postman 中,請求應(yīng)如下所示,響應(yīng)包括文檔計數(shù)和所用空間(以字節(jié)為單位)。
Azure Machine Learning - 使用 REST API 創(chuàng)建 Azure AI 搜索索引,azure,人工智能,microsoft
請注意,api-version 語法有所不同。 對于此請求,請使用 ? 來追加 api-version。 ? 將 URL 路徑與查詢字符串分隔開,而 & 將查詢字符串中的每個“名稱=值”對分隔開。 就此查詢來說,api-version 是查詢字符串中的第一個項,也是唯一項。

關(guān)注TechLead,分享AI全維度知識。作者擁有10+年互聯(lián)網(wǎng)服務(wù)架構(gòu)、AI產(chǎn)品研發(fā)經(jīng)驗、團隊管理經(jīng)驗,同濟本復旦碩,復旦機器人智能實驗室成員,阿里云認證的資深架構(gòu)師,項目管理專業(yè)人士,上億營收AI產(chǎn)品研發(fā)負責人。

到了這里,關(guān)于Azure Machine Learning - 使用 REST API 創(chuàng)建 Azure AI 搜索索引的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔相關(guān)法律責任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費用

相關(guān)文章

  • Azure Machine Learning - 使用自己的數(shù)據(jù)與 Azure OpenAI 模型對話

    Azure Machine Learning - 使用自己的數(shù)據(jù)與 Azure OpenAI 模型對話

    在本文中,可以將自己的數(shù)據(jù)與 Azure OpenAI 模型配合使用。 對數(shù)據(jù)使用 Azure OpenAI 模型可以提供功能強大的對話 AI 平臺,從而實現(xiàn)更快、更準確的通信。 關(guān)注TechLead,分享AI全維度知識。作者擁有10+年互聯(lián)網(wǎng)服務(wù)架構(gòu)、AI產(chǎn)品研發(fā)經(jīng)驗、團隊管理經(jīng)驗,同濟本復旦碩,復旦機器

    2024年02月04日
    瀏覽(21)
  • Azure Machine Learning - Azure OpenAI 服務(wù)使用 GPT-35-Turbo and GPT-4

    Azure Machine Learning - Azure OpenAI 服務(wù)使用 GPT-35-Turbo and GPT-4

    通過 Azure OpenAI 服務(wù)使用 GPT-35-Turbo and GPT-4 Azure 訂閱 - 免費創(chuàng)建訂閱 已在所需的 Azure 訂閱中授予對 Azure OpenAI 服務(wù)的訪問權(quán)限。 目前,僅應(yīng)用程序授予對此服務(wù)的訪問權(quán)限。 可以填寫 https://aka.ms/oai/access 處的表單來申請對 Azure OpenAI 服務(wù)的訪問權(quán)限。 Python 3.7.1 或更高版本。

    2024年02月05日
    瀏覽(57)
  • Azure Machine Learning - 聊天機器人構(gòu)建

    Azure Machine Learning - 聊天機器人構(gòu)建

    本文介紹如何部署和運行適用于 Python 的企業(yè)聊天應(yīng)用示例。 此示例使用 Python、Azure OpenAI 服務(wù)和 Azure AI 搜索中的檢索擴充生成(RAG)實現(xiàn)聊天應(yīng)用,以獲取虛構(gòu)公司員工福利的解答。 關(guān)注TechLead,分享AI全維度知識。作者擁有10+年互聯(lián)網(wǎng)服務(wù)架構(gòu)、AI產(chǎn)品研發(fā)經(jīng)驗、團隊管理

    2024年01月19日
    瀏覽(25)
  • Azure Machine Learning - Azure OpenAI GPT 3.5 Turbo 微調(diào)教程

    Azure Machine Learning - Azure OpenAI GPT 3.5 Turbo 微調(diào)教程

    本教程將引導你在Azure平臺完成對 gpt-35-turbo-0613 模型的微調(diào)。 關(guān)注TechLead,分享AI全維度知識。作者擁有10+年互聯(lián)網(wǎng)服務(wù)架構(gòu)、AI產(chǎn)品研發(fā)經(jīng)驗、團隊管理經(jīng)驗,同濟本復旦碩,復旦機器人智能實驗室成員,阿里云認證的資深架構(gòu)師,項目管理專業(yè)人士,上億營收AI產(chǎn)品研發(fā)負

    2024年02月04日
    瀏覽(24)
  • Azure云工作站上做Machine Learning模型開發(fā) - 全流程演示

    Azure云工作站上做Machine Learning模型開發(fā) - 全流程演示

    關(guān)注TechLead,分享AI全維度知識。作者擁有10+年互聯(lián)網(wǎng)服務(wù)架構(gòu)、AI產(chǎn)品研發(fā)經(jīng)驗、團隊管理經(jīng)驗,同濟本復旦碩,復旦機器人智能實驗室成員,阿里云認證的資深架構(gòu)師,項目管理專業(yè)人士,上億營收AI產(chǎn)品研發(fā)負責人。 了解如何在 Azure 機器學習云工作站上使用筆記本開發(fā)訓

    2024年02月08日
    瀏覽(25)
  • 使用Azure Data Factory REST API和HDInsight Spark進行簡化數(shù)據(jù)處理

    在這篇文章中,我們將探討如何利用Azure Data Factory和HDInsight Spark創(chuàng)建一個強大的數(shù)據(jù)處理管道。 在當今數(shù)據(jù)驅(qū)動的世界中,組織經(jīng)常面臨著高效可靠地處理和分析大量數(shù)據(jù)的挑戰(zhàn)。Azure Data Factory是一種基于云的數(shù)據(jù)集成服務(wù),結(jié)合HDInsight Spark,一種快速可擴展的大數(shù)據(jù)處理框

    2024年02月10日
    瀏覽(38)
  • 如何使用Python Flask和MySQL創(chuàng)建管理用戶的REST API

    如何使用Python Flask和MySQL創(chuàng)建管理用戶的REST API

    部分數(shù)據(jù)來源: ChatGPT? 引言 ????????在現(xiàn)代化的應(yīng)用開發(fā)中,數(shù)據(jù)庫是一個非常重要的組成部分。關(guān)系型數(shù)據(jù)庫(例如:MySQL、PostgreSQL)在這方面尤其是很流行。Flask是一個Python的web框架,非常適合實現(xiàn)REST API。在這篇文章中,我們將介紹如何使用Python Flask和MySQL創(chuàng)建一個

    2024年02月08日
    瀏覽(28)
  • (Rest風格API)Elasticsearch索引操作、映射配置、數(shù)據(jù)操作、查詢操作

    (Rest風格API)Elasticsearch索引操作、映射配置、數(shù)據(jù)操作、查詢操作

    1.請求方式:put 2.請求路徑:索引庫名 3.請求參數(shù):json格式 number_of_shards 是指索引要做多少個分片,只能在創(chuàng)建索引時指定,后期無法修改。 number_of_replicas 是指每個分片有多少個副本,后期可以動態(tài)修改 什么是分片? ES中所存數(shù)據(jù)的文件塊,也是數(shù)據(jù)的最小單元塊。假如有

    2024年04月26日
    瀏覽(21)
  • 【AWS】API Gateway創(chuàng)建Rest API--從S3下載文件

    【AWS】API Gateway創(chuàng)建Rest API--從S3下載文件

    ?一、背景 在不給AK,SK的前提下,用戶查看s3上文件(從s3下載文件) 二、創(chuàng)建API 1、打開API Gateway,點擊創(chuàng)建API,選擇REST API REST API和HTTP API區(qū)別:(來自AWS官網(wǎng)) REST API 和 HTTP API 都是 RESTful API 產(chǎn)品。REST API 支持的功能比 HTTP API 多,而 HTTP API 在設(shè)計時功能就極少,因此能夠

    2024年02月11日
    瀏覽(20)
  • Jira REST API_獲取創(chuàng)建issue時的字段配置

    通過 Jira REST API 創(chuàng)建 jira issue 時,可以根據(jù)jira 配置,動態(tài)獲取需要填寫的字段;這樣就不用每次通過UI ,固定指定創(chuàng)建issue時需要填充的內(nèi)容,來實現(xiàn)接口創(chuàng)建 issue 了。 獲取創(chuàng)建項目的問題類型: 獲取指定問題類型創(chuàng)建時的字段配置 可以先獲取項目類型id,然后再在末尾傳

    2024年01月17日
    瀏覽(22)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包