标签: azure-search-.net-sdk

任务被取消 - 这是什么意思?

我正在使用Azure Search .Net SDK.

我正在调用这样的同步(NOT ASYNC)函数:

var searchResults = searchIndexClient.Documents.Search<T>(searchText, searchParameters);
Run Code Online (Sandbox Code Playgroud)

它通常有效.我没有使用任何异步函数,但不知何故我刚刚得到的错误看起来像一个异步错误:

System.Threading.Tasks.TaskCanceledException: A task was canceled.

CancellationToken: IsCanceleationRequested=false

Task: Id = 556, Status = Canceled, Method = "{null}", Result = "{Not yet computed}"

StackTrace:
Run Code Online (Sandbox Code Playgroud)

在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)System.Runtime.CompilerServices.ConfiguredTaskAwaitable的System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)1.ConfiguredTaskAwaiter.GetResult() at Microsoft.Azure.Search.DocumentsOperations.<DoContinueSearchWithHttpMessagesAsync>d__153.MoveNext()---来自之前的堆栈跟踪结束抛出异常的位置---在系统的System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)的System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()处系统的System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务) .Runtime.CompilerServices.ConfiguredTaskAwaitable 1.ConfiguredTaskAwaiter.GetResult() at Microsoft.Azure.Search.DocumentsOperationsExtensions.<SearchAsync>d__151.MoveNext()---抛出异常的前一个位置的堆栈跟踪结束---在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess上的System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()处System.Runtime.CompilerServices.TaskAwaite上System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)的(任务任务)r 1.GetResult() at Microsoft.Azure.Search.DocumentsOperationsExtensions.Search[T](IDocumentsOperations operations, String searchText, SearchParameters searchParameters, SearchRequestOptions searchRequestOptions) at MyApp.AzureSearch.AzureSearchService.PerformSearch[T](String searchText, SearchParameters searchParameters) in c:\Projects\MyAppServer\src\MyApp.AzureSearch\AzureSearchService.cs:line 359 at MyApp.AzureSearch.AzureSearchService.Search[T](String searchText, List1 searchFields,SearchMode searchMode,List 1 select, Nullable1 skip,Nullable 1 top, String filter, Boolean …

asynchronous azure-cognitive-search azure-search-.net-sdk

6
推荐指数
1
解决办法
6280
查看次数

为什么 AzureSearch SDK 会因传输连接问题而自发失败?

昨天我们非常兴奋。我们的两个使用 AzureSearch 的 SDK 的 Web 应用程序(已部署和至少 3 个月未受影响)在不同时间(一个清晨;另一个在晚上)停止工作。indexClient.Documents.Search 方法开始失败并出现以下错误:

与 XXXXsearch.search.windows.net(#435)的 HTTPS 握手失败。System.IO.IOException 无法从传输连接读取数据:远程主机强制关闭现有连接。< 现有连接被远程主机强行关闭

在疯狂的谷歌争夺之后,我们在修复它的搜索之前添加了这 3 行。

            const SslProtocols _Tls12 = (SslProtocols)0x00000C00;
            const SecurityProtocolType Tls12 = (SecurityProtocolType)_Tls12;
            ServicePointManager.SecurityProtocol = Tls12;
Run Code Online (Sandbox Code Playgroud)

我所能想象的只是我们错过了某种“AzureSDK 正在改变”电子邮件?这非常糟糕,我们很幸运能够快速解决问题,否则它可能是一场灾难。有谁知道为什么会发生这种情况?

azure-cognitive-search azure-search-.net-sdk

6
推荐指数
1
解决办法
1000
查看次数

Azure搜索.net SDK-如何使用"FindFailedActionsToRetry"?

使用Azure搜索.net SDK,当您尝试索引文档时,可能会出现异常IndexBatchException.

从这里的文档:

        try
        {
            var batch = IndexBatch.Upload(documents);
            indexClient.Documents.Index(batch);
        }
        catch (IndexBatchException e)
        {
            // Sometimes when your Search service is under load, indexing will fail for some of the documents in
            // the batch. Depending on your application, you can take compensating actions like delaying and
            // retrying. For this simple demo, we just log the failed document keys and continue.
            Console.WriteLine(
                "Failed to index some of the documents: {0}",
                String.Join(", ", e.IndexingResults.Where(r => !r.Succeeded).Select(r …
Run Code Online (Sandbox Code Playgroud)

azure azure-cognitive-search azure-search-.net-sdk

5
推荐指数
1
解决办法
859
查看次数

这个 Azure 搜索索引错误是什么意思?“'search.documentFields' 类型不存在属性 'x'...”

我得到的例外是: The property 'documentType' does not exist on type 'search.documentFields'. Make sure to only use property names that are defined by the type.

我已经用谷歌搜索了这个,但仍然无法弄清楚发生了什么。

这是我们使用的模型:

[SerializePropertyNamesAsCamelCase]
public class WebSearchDocument : SearchDocument, IEventSearchDocument, IResourceSearchDocument
{
    [IsFacetable]
    public string DocumentType { get; set; }
    [IsSearchable]
    public string Title { get; set; }
    [IsSearchable]
    public string Description { get; set; }
    [IsFilterable]
    public DateTime? PublishedDate { get; set; }
    public DateTime? LastUpdatedDate { get; set; }
    public string ImageUrl { get; set; } …
Run Code Online (Sandbox Code Playgroud)

azure azure-cognitive-search azure-search-.net-sdk

4
推荐指数
1
解决办法
2336
查看次数

如何解码.NET Core中Azure搜索索引器生成的metadata_storage_path

使用.NetCore 1.1.2.

通过Azure Search SDK成功获取搜索结果后,我正在尝试解码metadata_storage_path值.我见过有人说要在.NET中使用HttpServerUtility.UrlTokenDecode或者在这里看到其他语言中的等价物.

那么问题就变成了,HttpServerUtility.UrlTokenDecode的.NetCore中的等价物是什么?附:

var pathEncoded = "aHR0cHM6Ly9mYWtlZC5ibG9iLmNvcmUud2luZG93cy5uZXQvcGRmYmxvYnMvYW5udWFsX3JlcG9ydF8yMDA5XzI0NTU20";
Run Code Online (Sandbox Code Playgroud)

我尝试过以下方法:

var pathbytes = Convert.FromBase64String(pathEncoded); 
//Throws System.FormatException "Invalid length for a Base-64 char array or string."
Run Code Online (Sandbox Code Playgroud)

var pathbytes = WebEncoders.Base64UrlDecode(pathEncoded);
//Throws System.FormatException - "TODO: Malformed input."
Run Code Online (Sandbox Code Playgroud)

有趣的是,如果我切断了pathEncoded中的最后一个字符,一切都运行正常...用Microsoft.AspNetCore 1.1.2处理这种情况的正确方法是什么?

c# azure azure-cognitive-search asp.net-core azure-search-.net-sdk

4
推荐指数
2
解决办法
1160
查看次数

如何在Azure搜索中过滤数组

我在索引中有以下数据,

{
"name" : "The 100",
"lists" : [
                "2c8540ee-85df-4f1a-b35f-00124e1d3c4a;Bellamy",
                "2c8540ee-85df-4f1a-b35f-00155c40f11c;Pike",
                "2c8540ee-85df-4f1a-b35f-00155c02e581;Clark"
          ]

}
Run Code Online (Sandbox Code Playgroud)

我必须得到列表中有Pike的所有文档.

虽然完整的搜索查询适用于任何我无法得到包含工作.

$filter=lists/any(t: t eq '2c8540ee-85df-4f1a-b35f-00155c40f11c;Pike')
Run Code Online (Sandbox Code Playgroud)

但是我不知道如何只用Pike搜索.

$filter=lists/any(t: t eq 'Pike')

我想eq寻找全文搜索,有没有任何方式使用给定的数据结构我应该使这个查询工作.

目前,字段列表没有可搜索的属性,只有可过滤的属性.

azure-cognitive-search azure-search-.net-sdk

3
推荐指数
1
解决办法
1805
查看次数

Azure 搜索中的同义词映射、同义词短语

我尝试在 Azure 搜索中使用同义词映射,但遇到了问题。我希望将多个单词和短语映射到单个搜索查询中。

换句话说,当我搜索:

产品 123 ,产品 0123 ,产品 0123

我希望搜索返回查询短语的结果:

产品123

阅读完教程后,一切似乎都非常简单。

我正在使用 .Net Azure.Search SDK 5.0,因此我执行了以下操作:

var synonymMap = new SynonymMap
{
     Name = "test-map",
     Format = SynonymMapFormat.Solr,
     Synonyms = "product 123, product0123, product 0123=>product123\n"
};  
_searchClient.SynonymMaps.CreateOrUpdate(synonymMap);
Run Code Online (Sandbox Code Playgroud)

我在其中一个搜索字段上使用地图

index.Fields.First(x => x.Name == "Title").SynonymMaps = new[] {"test-map"};
Run Code Online (Sandbox Code Playgroud)

到目前为止,一切都很好。现在,如果我搜索product0123,我会得到product123的结果,正如我所期望的那样。但如果我搜索短语“产品 123”“产品 0123”,我会得到一堆不相关的结果。同义词映射几乎不适用于多词项。

所以我的问题是,我是否错误地使用了同义词映射表,或者这些映射表仅适用于单个单词同义词?

synonym azure-cognitive-search azure-search-.net-sdk

3
推荐指数
1
解决办法
1134
查看次数

获取 Azure 搜索中的实际匹配数

Azure 搜索一次最多返回 1,000 个结果。对于客户端上的分页,我想要匹配的总数,以便能够在底部显示正确数量的分页按钮,并能够告诉用户有多少结果。但是,如果有超过一千个,我如何获得实际计数?我只知道至少有1,000 场比赛。

我需要能够在 SDK 中执行此操作。

azure azure-cognitive-search azure-search-.net-sdk

2
推荐指数
1
解决办法
2551
查看次数

Azure 搜索 .NET SDK 自定义分析器

没有太多背景,这是我的问题:

要使用 C# 中的 .NET SDK 创建新的 Azure 搜索索引(使用文档中提供的 Hotel 示例),我的代码如下所示:

public class Hotel
{
    [System.ComponentModel.DataAnnotations.Key]
    [IsFilterable]
    public string HotelId { get; set; }

    [IsFilterable, IsSortable, IsFacetable]
    public double? BaseRate { get; set; }

    [IsSearchable]
    public string Description { get; set; }

    [IsSearchable]
    [Analyzer(AnalyzerName.AsString.FrLucene)]
    [JsonProperty("description_fr")]
    public string DescriptionFr { get; set; }

    [IsSearchable, IsFilterable, IsSortable]
    public string HotelName { get; set; }

    [IsSearchable, IsFilterable, IsSortable, IsFacetable]
    public string Category { get; set; }

    [IsSearchable, IsFilterable, IsFacetable]
    public string[] Tags { …
Run Code Online (Sandbox Code Playgroud)

c# wildcard analyzer azure-search-.net-sdk

2
推荐指数
1
解决办法
1163
查看次数

当文档添加/更新到搜索索引时,是否有任何默认时间戳会更新?

我知道 Azure Cosmos Db 中有一个 _ts(时间戳)属性,它会在任何文档插入/更新时更新。

Azure 搜索索引中的文档是否有类似的内容?

(或者)

我们应该有自己的时间戳属性吗?

c# azure azure-cognitive-search azure-search-.net-sdk

1
推荐指数
1
解决办法
284
查看次数

azure认知搜索-地理点问题

我指定一个字段如下:

    [SimpleField(IsFilterable = true, IsSortable = true)]
    public  Microsoft.Spatial.GeographyPoint Location { get; set; }
Run Code Online (Sandbox Code Playgroud)

在我的索引中,我可以看到它已成功创建并具有正确的内容,但是当我尝试使用 geo.distance 进行搜索时,它会抛出以下错误:

$filter=geo.distance(Location, geography'POINT(-82.51571 31.89063)') le 30
Run Code Online (Sandbox Code Playgroud)

错误:

“无效表达式:名称为“geo.distance”的函数没有与指定参数匹配的函数签名。考虑的函数签名为:geo.distance(Edm.GeographyPoint Nullable=true, Edm.GeographyPoint Nullable=true); geo.distance (Edm.GeometryPoint Nullable=true, Edm.GeometryPoint Nullable=true)。\r\n参数名称:$filter"

azure azure-cognitive-search azure-search-.net-sdk

1
推荐指数
1
解决办法
934
查看次数

使用 .NET 客户端添加评分配置文件

我找不到如何使用 .NET 客户端进行 Azure 搜索来添加评分配置文件。是的,我知道有一个文档可以使用 REST API 来完成,谢谢。

azure-cognitive-search azure-search-.net-sdk

0
推荐指数
1
解决办法
187
查看次数

使用通配符或模糊搜索的 Azure 完整搜索未返回预期结果

我的 Azure 搜索索引中有以下记录

{ 
    "customerId": "8feda7ca-c9f0-40d9-86d8-434b0bbe94c2", 
    "registeredName": "TeamPeacock", 
    "tradingName": "TeamPeacock", 
}, 
{ 
    "customerId": "b445eb04-8d07-4708-a197-770cda3a459e", 
    "registeredName": "TeamPeacock1", 
    "tradingName": "TeamPeacock 1", 
}
Run Code Online (Sandbox Code Playgroud)

我使用带有通配符/模糊搜索的完整搜索来获取记录。

以下搜索查询无法获取上述记录:

查询 1 失败:

{ 
    "search": "(peacock*) OR (peacock*~) OR (peacock~)", 
    "queryType": "full", 
    "searchMode": "all" 
}
Run Code Online (Sandbox Code Playgroud)

查询 2 失败:

{ 
    "search": "(peacock*) OR (peacock*~) OR (peacock~)", 
    "queryType": "full", 
    "searchMode": "any" 
}
Run Code Online (Sandbox Code Playgroud)

查询 3 失败:

{ 
    "search": "(peacock*)", 
    "queryType": "full", 
    "searchMode": "any" 
}
Run Code Online (Sandbox Code Playgroud)

查询 4 ​​失败:

{ 
    "search": "(peacock*~) OR (peacock~)", 
    "queryType": "full", 
    "searchMode": "any" 
}
Run Code Online (Sandbox Code Playgroud)

但如果我包含术语“teampeacock”,搜索查询将返回结果。

通过查询:

{ 
    "search": …
Run Code Online (Sandbox Code Playgroud)

azure-cognitive-search azure-search-.net-sdk

0
推荐指数
1
解决办法
969
查看次数