我想在我的应用程序中提供全文搜索功能,因此我试图配置具有认知搜索功能的Azure搜索,以便可以索引存储在Azure Blob存储中的图像以及非图像文档。但是,在使用Azure Search的REST API通过Java代码配置Azure Search时,我无法将OCR功能利用到Azure Search中,并且图像文档也未建立索引。通过Java代码(使用Azure Search REST API)配置Azure搜索时,我缺少一些配置详细信息。
案例1:我可以从Azure门户
案例2:我可以使用Azure REST API从Java代码中获得
我正在使用Java代码中的以下示例Azure Search Rest API 1. https://%s.search.windows.net/datasources?api-version=%s 2. https://%s.search.windows.net/skillsets/cog-search-demo-ss?api-version=%s 3. https://%s.search.windows.net/indexes/%s?api-version=%s 4. https://%s.search.windows.net/indexers?api-version=%s
配置json: 1. datasource.json
{
"name" : "csstoragetest",
"type" : "azureblob",
"credentials" : { "connectionString" : "connectionString" },
"container" : { "name" : "csblob" }
}
{
"description": "Extract text from images and merge with content text to produce merged_text",
"skills":
[
{
"description": "Extract text (plain and structured) from image.",
"@odata.type": "#Microsoft.Skills.Vision.OcrSkill",
"context": "/document/normalized_images/*",
"defaultLanguageCode": "null",
"detectOrientation": true,
"inputs": [
{
"name": "image",
"source": "/document/normalized_images/*"
}
],
"outputs": [
{
"name": "text",
"targetName": "myText"
},
{
"name": "layoutText",
"targetName": "myLayoutText"
}
]
},
{
"@odata.type": "#Microsoft.Skills.Text.MergeSkill",
"description": "Create merged_text, which includes all the textual representation of each image inserted at the right location in the content field.",
"context": "/document",
"insertPreTag": " ",
"insertPostTag": " ",
"inputs": [
{
"name":"text", "source": "/document/content"
},
{
"name": "itemsToInsert", "source": "/document/normalized_images/*/text"
},
{
"name":"offsets", "source": "/document/normalized_images/*/contentOffset"
}
],
"outputs": [
{
"name": "mergedText", "targetName" : "merged_text"
}
]
}
]
}
{
"name": "azureblob-indexing",
"fields": [
{ "name": "id", "type": "Edm.String", "key": true, "searchable": false },
{ "name": "content", "type": "Edm.String", "searchable": true, "filterable": false, "sortable": false, "facetable": false }
]
}
{
"name" : "azureblob-indexing1",
"dataSourceName" : "csstoragetest",
"targetIndexName" : "azureblob-indexing",
"schedule" : { "interval" : "PT2H" },
"skillsetName" : "cog-search-demo-ss",
"parameters":
{
"maxFailedItems":-1,
"maxFailedItemsPerBatch":-1,
"configuration":
{
"dataToExtract": "contentAndMetadata",
"imageAction":"generateNormalizedImages",
"parsingMode": "default",
"firstLineContainsHeaders": false,
"delimitedTextDelimiter": ","
}
}
}
通过Java代码配置Azure搜索之后,Image文档应该在Azure搜索中建立索引,并且我应该能够基于其中包含的文本来搜索它们。
答案 0 :(得分:0)
尝试将默认语言代码设置为null,在 skillset.json 中不加引号:
"defaultLanguageCode": null
答案 1 :(得分:0)
我已经弄清楚自己需要的配置。 它需要如上所述(在问题中)匹配案例1和案例2之间的所有参数,然后更新配置json。