- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在将 Azure 认知搜索服务的 SDK 从 v10 更新到 v11。我已按照指南中的所有步骤进行升级,但是我注意到有关索引(合并或上传)操作的奇怪行为:UploadDocumentAsync(但也使用其他用于索引数据的方法)当 Collection (Edm.ComplexType) 类型的属性为 null 时,操作失败,并出现以下错误:
尝试读取属性内容时,从 JSON 读取器读取了“PrimitiveValue”类型的节点。但是,“StartArray”节点应为 json。
IndexDocumentsResult response = await searchClient.UploadDocumentsAsync<T>(documents).ConfigureAwait (false);
在 v10 中,这个问题没有出现。我发现的解决方法是将集合设置为空数组而不是空值,但我想找到更好的解决方案。
编辑:我从 Microsoft.Azure.Search v10.1.0 升级到 Azure.Search.Documents v11.1.1以下是用于索引数据的通用 T 类的示例:
public class IndexEntity
{
[JsonProperty("@search.score")]
public double SearchScore { get; set; }
[JsonProperty("Key")]
public Guid Id { get; set; }
[JsonProperty("Code")]
public string Code { get; set; }
[JsonProperty("ComplexObj")]
public ComplexType[] CollectionOfComplexType{ get; set; }
}
遵循ModelObjectToIndex的定义
public class ComplexType
{
[JsonProperty("Id")]
public string Id { get; set; }
[JsonProperty("Value")]
public string Value { get; set; }
}
基本上,当 CollectionOfComplexType 属性为 null 时,我会收到上述错误。如果我将其设置为空数组,则不会发生错误,但正如前面提到的,我不喜欢这个解决方案,而且在旧版本中这是允许的操作(索引已成功完成)
最佳答案
我们的 Azure.Search.Documents 行为在这方面似乎已经发生了变化。我已经打开https://github.com/Azure/azure-sdk-for-net/issues/18169跟踪分辨率。
您可以通过传入 JsonSerializerSettings
来解决此问题,而无需将集合初始化为空数组,这与我们在旧版 Microsoft.Azure.Search 库中所做的类似,因为它似乎是使用无论如何,您正在使用 Newtonsoft.Json
(又名 Json.NET)的 JsonPropertyAttribute
:
添加对 Microsoft.Azure.Core.NewtonsoftJson 的包引用(如果尚未添加)。它最近进行了 GA,因此您不需要使用预览,我认为这是因为 System.Text.Json
- 我们的默认序列化程序 - 不会尊重您的属性重命名。 p>
在创建 SearchClient
之前传入 JsonSerializerSettings
,如下所示:
var settings = new JsonSerializerSettings
{
// Customize anything else you want here; otherwise, defaults are used.
NullValueHandling = NullValueHandling.Ignore,
};
var options = new SearchClientOptions
{
Serializer = new NewtonsoftJsonObjectSerializer(settings),
};
var searchClient = new SearchClient(options);
如果可以的话,我们将讨论如何默认解决此问题。与旧库相比的一大变化是能够自定义所使用的序列化器。默认情况下,我们使用 System.Text.Json,但我们支持其他序列化程序,包括 Newtonsoft.Json。如果有人要传递自己的设置 - 或者甚至想要默认值 - 更改这可能是灾难性的。所以我很好奇:如果我们至少记录了这种行为变化(也许在 SearchClient
类注释和/或 UploadDocuments
和相关方法上)以及如何保留以前的行为,这会有所帮助还是令人满意?
关于c# - Azure 搜索 v11 : Indexing nullable Collection of Complex Type,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65823922/
我有一个使用 c++ 的大型代码库标题和许多std::complex对象。但现在我还想使用其他几个使用 fftw 的库( spinsfast 和 ) .不幸的是,混合这两种类型的复合体似乎与 gc
我是 Maxima 的新手,在文档中找不到如何对复数进行正式计算。当我使用未指定的变量时,Maxima 似乎假设它们是真实的: 例如,共轭(x)返回 x。 有没有办法解决这个问题? 提前致谢。 最佳答
我是学习大O表示法的新手,并想到了这个问题。复杂度 O(a * b) 的名称是什么?是线性复杂度吗?多项式?或者是其他东西。实现代码如下。 function twoInputsMult(a, b) {
我是学习大O表示法的新手,并想到了这个问题。复杂度 O(a * b) 的名称是什么?是线性复杂度吗?多项式?或者是其他东西。实现代码如下。 function twoInputsMult(a, b) {
这是我的 Complex 类,我重载了“+” class Complex(object): def __init__(self, real, imag): self.__ima
我正在使用 R5RS 标准的 Scheme 实现。 现在假设您必须找出一个元素 '(2 3 4) 是否在列表 '(1 2 3 4) 中。 至于示例,更严格地说,您希望: 1. (is-in? '(2
注意事项: 我正在使用 Apple LLVM 版本 6.0 (clang-600.0.56)(基于 LLVM 3.5svn)在 OSX 上编译 具体来说,我正在尝试从 LibIIR 编译一个整体源,这
这段fortran代码最初是用Fortran 77格式编写的(我稍后会展示它)。拿到后,我通过转换工具将其转换为f90免费格式。使用intel fortran编译器 ifort,编译和运行和以前一样好
我有一个实现用户定义的算术类型的MyType类。此类提供以下转换运算符 struct MyType { ... operator double() { return to_double
我目前正在使用 Cxx 来允许 Julia 代码与 C++ 库交互。我想做的一部分是在两个方向上有效地传递复杂数据的集合(通常是 vector )。也就是说,我想要以下内容: cv = [1 + 2i
假设我有一个名为“汽车”的实体。 我使用复杂类型来定义“引擎”部分。 [TableName("T_CAR")] public sealed class Car:IEngine { ... pu
我想使用 static_cast 将 complex 转换为 complex 。 Convert complex to complex 我正在尝试做与这篇文章相同的事情,但我需要使用 static_c
` ?
对于多项式方程求解器,最好将其模板化为任何可用类型: template class PolynomialEquation { public: private: array myEquatio
为了在 cython 中将实部与复部分开,我通常使用 complex.real 和 complex.imag 来完成这项工作。然而,这确实会在 html 输出中生成颜色为“python red”的代码
我的问题很简单: Are both "complex float" and "float complex" valid C? 两者似乎都被 gcc 接受而没有警告。 最佳答案 complex 是 co
以下声明有什么区别? 结构体 *ptr1=(结构体*)malloc(4*sizeof(结构体)); 结构体 (*ptr1)[4]=(结构体*)malloc(sizeof(结构体)); 哪个更好用? 最
我想创建一个 C++ 类的复数。这里是Complex.h(最基本的形式) #ifndef _COMPLEX #define _COMPLEX #include "TVector2.h" class C
我已经使用 Visual Studio 2012 和 NDepend 对我的解决方案进行了代码分析 对于方法 MethodA,Visual Studio 显示复杂度为 105,Ndepend 显示为
我的代码: #include using std::cin; using std::cout; using std::istream; using std::ostream; template cl
我在 swift3 中有以下代码,我正在使用 swift lint 对代码进行 linting。给出代码如下: func selectedMenuInLoggedOutState(sender
我是一名优秀的程序员,十分优秀!