Azure搜索-导入.md文件

时间:2019-03-22 16:22:37

标签: azure postman azure-cosmosdb data-manipulation azure-search

我正在尝试使用邮递员上传数据并收到错误消息:“此资源不支持请求实体的媒体类型'text / plain'。”

我在使用邮递员,

url : https://azuresearchpocxxxx.search.windows.net/indexes/beers/docs/index?api-version=2017-11-11

request type : POST 
content-type : text/plain

数据位于.md文件中

| ID | Name                      | ActivelyBrewed | IBU | ABV  | Flavors | LastTappedOn | BreweryId | BreweryName                |
|----|---------------------------|----------------|-----|------|------------------------------|--------------|-----------|----------------------------|
| 1  | Ahool Ale                 | true           | 33  | 5.4  | biscuity                     | 1/23/2016    | b3TplPdS  | Northern Hemisphere Brewco |
| 2  | Agogwe Ale                | true           | 28  | 2.9  | wheat, floral                | 5/18/2016    | Ek4mwsBoe | Southern Hemisphere Brewco |
| 3  | Aswang Ale                | true           | 31  | 4.2  | butter, yeast                | 2/13/2016    | b3TplPdS  | Northern Hemisphere Brewco |
| 4  | Buru's Barley Wine        | true           | 76  | 11.1 | raisin, dried fruit, bourbon | 1/1/2016     | b3TplPdS  | Northern Hemisphere Brewco |
| 7  | Hyote Chocolate Stout     | true           | 78  | 7.4  | caramel, chocolate           | 1/7/2016     | zkXBTiBol | North American Brewco      | 
| 8  | Igopogo Pilsner           | true           | 36  | 5.7  | malt, bread                  | 11/15/2015   | zkXBTiBol | North American Brewco      | 
| 9  | Jackalobe Lager           | true           | 29  | 3.3  | fruit, citrus                | 3/15/2016    | zkXBTiBol | North American Brewco      |
| 11 | Mahamba Barley Wine       | true           | 57  | 9.7  | malt, raisin                 | 4/24/2016    | Ek4mwsBoe | Southern Hemisphere Brewco |
| 12 | Megalodon Pale Ale        | true           | 99  | 5.7  | bread, hops, pine            | 3/31/2016    | VkNvPjBse | Oceanic Brewco             |
| 16 | Pope Lick Porter          | true           | 39  | 6.5  | smokey, chocolate, banana    | 1/6/2016     | zkXBTiBol | North American Brewco      |
| 17 | Chocolate Pukwudgie Stout | true           | 35  | 12.2 | chocolate, coffee            | 2/25/2016    | zkXBTiBol | North American Brewco      |
| 18 | Sharlie Pilsner           | true           | 31  | 4.1  | grass                        | 2/18/2016    | zkXBTiBol | North American Brewco      |
| 19 | Sigbin Stout              | false          | 65  | 8.1  | coffee, caramel              | 3/18/2016    | b3TplPdS  | Northern Hemisphere Brewco |
| 21 | Snallygaster Pale Ale     | false          | 89  | 9.7  | pine, honey                  | 4/29/2016    | zkXBTiBol | North American Brewco      |
| 22 | Tikibalang Barley Wine    | true           | 45  | 9.6  | bourbon                      | 3/14/2016    | b3TplPdS  | Northern Hemisphere Brewco |
| 26 | Pale Popobawa Ale         | true           | 30  | 4.4  | wheat                        | 5/9/2016     | Ek4mwsBoe | Southern Hemisphere Brewco |
| 27 | North Adjule Lager        | true           | 30  | 3.7  | citrus                       | 2/8/2016     | Ek4mwsBoe | Southern Hemisphere Brewco | 

我已经创建了一个索引和一个字段来保存这种类型的数据。

我尝试使用Azure门户中的“导入数据”选项(它没有选择.md文件的选项)

对此表示感谢。

1 个答案:

答案 0 :(得分:0)

您在此处有2个选择:将数据作为“定界文本”文件导入或逐行上传数据。

选项1(“分隔文本”文件)

  1. 将文件上传到blob storage
  2. 从门户网站“导入数据”,并带有“ Azure Blob存储”数据源(如果要创建新的数据源,则为“ 默认”解析模式)
  3. 编辑索引以包含您关心的字段
  4. 在“索引器”标签中,展开“高级选项”部分,然后选择“定界文本”解析模式,选中“第一行包含标题” ,然后设置定界符为“ |”

等效地,您可以使用REST API(Data sourceIndexIndexer)进行所有操作。索引器将尝试索引不包含任何实际数据的第二行,根据您的用例,这可能是可接受的。

您可能需要将“ 最大失败项目”设置为在第二行不失败。

选项2(POST索引)

在您的md文件的每一行中使用Add Document REST API,并将 @ search.action设置为“ mergeOrUpload” 内容类型必须为“ application / json” ,您需要使用数据中的所有键值对生成JSON正文。


如果要更新数据,则应使用选项1 并按计划设置索引器,这样更改将被自动提取。