小编Hen*_*Kok的帖子

Elasticsearch NEST - 过滤多级嵌套类型

我有一个这样的文档模型:

"customer": {  
    "properties": {  
        "id": { "type": "integer" },
        "name": { "type": "string" },
        "orders": {
            "type": "nested",
            "properties": {
                "id": { "type": "integer" },
                "orderDate" : { "type": "date", "format" : "YYYY-MM-dd" },
                "orderLines": {
                    "type": "nested",
                    "properties": {
                        "seqno": { "type": "integer" },
                        "quantity": { "type": "integer" },
                        "articleId": { "type": "integer" }
                    }
                }
            }
        }
    }
}  
Run Code Online (Sandbox Code Playgroud)

一个客户可以有0个,1个或多个订单,订单可以有0,1个或多个orderLines
(这是我为这个问题创建的模型,因为我认为这是每个人都能理解的数据,所以如果你发现任何错误,请让我知道,但不要让他们分散你对我实际问题的注意力)

我想用NEST创建一个查询,该查询选择具有customer.id特定值的一个(或所有)客户,但前提是他们至少有一个带有特定articleId的orderLine.

我已经查看了需要使用NEST ElasticSearch库构建复杂索引的具体文档/示例,使用Elastic Search匹配完整的复杂嵌套集合项而不是单独的成员,但无法创建查询.根据第二个问题,我达到了我写作的地步

var results = client.Search<customer>(s => s
    .From(0)
    .Size(10) …
Run Code Online (Sandbox Code Playgroud)

elasticsearch nest

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

获取 Docker 容器中依赖包的 XML 文档

我们有一个 Asp.Net Core 2.0 Web 服务,我们将其部署在 Docker 容器中。

对于 Web 服务,我们生成一个 xml 文档文件,并在 Swagger-ui 中使用该文件。这适用于从项目本身生成的 xml 文档,但是当 Web 服务部署在 Docker 容器中时,我无法获得为可见的包含包生成的 xml 注释。

nuget 包(也由我们创建)确实包含一个 xml 文档文件,我们可以让 swagger 在本地机器上运行服务时使用它。通过调用 .IncludeXmlComments 使文档可用于 swagger,并且文档的路径是通过获取程序集的路径然后用 .xml 替换 .dll 扩展名来确定的。

我怀疑该包的xml doc文件未包含在容器中,因此无法找到。在 Dockerfile 我看到命令

COPY publish .
Run Code Online (Sandbox Code Playgroud)

我想要一个还添加/复制包的 xml doc 文件的命令,或者知道如何使 xml doc 文件成为发布资产的一部分。任何其他能够以稳健的方式(不仅仅是在我的机器上)进行这项工作的解决方案也是受欢迎的。

编辑:我们现在在 Docker 容器中有额外的 xml doc 文件,但 Swagger 仍然没有显示该文件中提供的描述(它在本地运行时会显示)。我们使用了类似的东西:

<Target Name="PrepublishScript" BeforeTargets="PrepareForPublish">  
    <ItemGroup>
        <DocFile Include="$(USERPROFILE)\.nuget\packages\{packagename}\**\lib\$(TargetFramework)\{PackageName}.xml" />
    </ItemGroup>
    <Copy SourceFiles="@(DocFile)" DestinationFolder="$(PublishDir)" SkipUnchangedFiles="false" />
</Target>
Run Code Online (Sandbox Code Playgroud)

其中 {PackageName} 应替换为您的包的实际名称。路径中的通配符使其版本独立(尽管我们现在必须检查这是否会导致问题,因为我们有多个版本)。

xml-documentation docker swagger-ui asp.net-core-2.0

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

ConcurrentDictionary TryAdd与Item setter性能

我们在一个高流量的网站上,我们想要使用ConcurrentDictionary进行一些非常简单的缓存计算,以防止它为每个请求完成.可能的输入数量足够有限,计算相对较重(拆分和重新连接字符串).

我正在考虑代码

string result;
if (!MyConCurrentDictionary.TryGetValue(someKey, out result))
{
    result = DoCalculation(someKey);
    // alternative 1: use Item property
    MyConcurrentDictionary[someKey] = result;
    //alternative 2: use TryAdd
    MyConcurrentDictionary.TryAdd(someKey, result);
}
Run Code Online (Sandbox Code Playgroud)

我的问题是:从绩效角度来看,哪种替代方案是最佳选择?

c#

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