View a markdown version of this page

在 Amazon OpenSearch Service 中搜尋文件 - Amazon OpenSearch Service

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

在 Amazon OpenSearch Service 中搜尋文件

若要在 Amazon OpenSearch Service 網域中搜尋文件,請使用 OpenSearch 搜尋 API。或者,您可以使用 OpenSearch Dashboards 搜尋網域中的文件。

從命令列搜尋文件

執行以下命令搜尋影片網域的 mars 這個字:

curl -XGET -u 'master-user:master-user-password' 'domain-endpoint/movies/_search?q=mars&pretty=true'

如果已在先前頁面中使用大量資料,則請嘗試改成搜尋 rebel。

您應該會看到類似以下的回應:

{ "took" : 5, "timed_out" : false, "_shards" : { "total" : 5, "successful" : 5, "skipped" : 0, "failed" : 0 }, "hits" : { "total" : { "value" : 1, "relation" : "eq" }, "max_score" : 0.2876821, "hits" : [ { "_index" : "movies", "_type" : "_doc", "_id" : "1", "_score" : 0.2876821, "_source" : { "director" : "Burton, Tim", "genre" : [ "Comedy", "Sci-Fi" ], "year" : 1996, "actor" : [ "Jack Nicholson", "Pierce Brosnan", "Sarah Jessica Parker" ], "title" : "Mars Attacks!" } } ] } }

使用 OpenSearch Dashboards 搜尋文件

OpenSearch Dashboards 是一種常見的開源視覺化工具,專為與 OpenSearch 一起使用而設計。它提供了一個很有幫助的使用者介面,供您搜尋和監控您的索引。

若要使用 Dashboards 從 OpenSearch Service 網域中搜尋文件
  1. 導覽至您網域的 OpenSearch Dashboards URL。您可以在 OpenSearch Service 主控台網域的儀表板上找到 URL。URL 遵循以下格式:

    domain-endpoint/_dashboards/
  2. 使用您的主要使用者名稱和密碼登入。

  3. 若要使用 Dashboards,您需要建立至少一個索引模式。Dashboards 使用這些模式來識別您要分析的索引。開啟左側導覽面板,選擇儀表板管理 (在舊版稱為堆疊管理),選擇索引模式,然後選擇建立索引模式。對於本教學課程,輸入 movies。

  4. 選擇 Next step (下一步),然後選擇 Create index pattern (建立索引模式)。建立模式之後,您可以檢視各種文件欄位,例如 actor 和 director。

  5. 返回 Index Patterns (索引模式) 頁面,並確認將 movies 設為預設值。如果不是,請選擇模式並選擇星形圖示以使其成為預設值。

  6. 若要開始搜尋您的資料,請再次開啟左側導覽面板,然後選擇 Discover (探索)。

  7. 如果上傳了單一文件,則在搜尋列中輸入 mars,或者如果上傳了多份文件,則輸入 rebel,然後按 Enter 鍵。您可以嘗試搜尋其他用語,例如演員或導演姓名。

下一步:刪除網域