小编Sim*_*lia的帖子

Elasticsearch SQL就像子查询聚合一样

我正在玩ES以了解它是否可以涵盖我的大部分场景.我正处于考虑如何在SQL中达到某些非常简单的结果的问题.

这是一个例子

在弹性我有一个索引与这些文件

{ "Id": 1,  "Fruit": "Banana", "BoughtInStore"="Jungle", "BoughtDate"=20160101,  "BestBeforeDate": 20160102, "BiteBy":"John"}
{ "Id": 2,  "Fruit": "Banana", "BoughtInStore"="Jungle", "BoughtDate"=20160102,  "BestBeforeDate": 20160104, "BiteBy":"Mat"}
{ "Id": 3,  "Fruit": "Banana", "BoughtInStore"="Jungle", "BoughtDate"=20160103,  "BestBeforeDate": 20160105, "BiteBy":"Mark"}
{ "Id": 4,  "Fruit": "Banana", "BoughtInStore"="Jungle", "BoughtDate"=20160104,  "BestBeforeDate": 20160201, "BiteBy":"Simon"}
{ "Id": 5,  "Fruit": "Orange", "BoughtInStore"="Jungle", "BoughtDate"=20160112,  "BestBeforeDate": 20160112, "BiteBy":"John"}
{ "Id": 6,  "Fruit": "Orange", "BoughtInStore"="Jungle", "BoughtDate"=20160114,  "BestBeforeDate": 20160116, "BiteBy":"Mark"}
{ "Id": 7,  "Fruit": "Orange", "BoughtInStore"="Jungle", "BoughtDate"=20160120,  "BestBeforeDate": 20160121, "BiteBy":"Simon"}
{ "Id": 8,  "Fruit": "Kiwi", "BoughtInStore"="Shop", "BoughtDate"=20160121, …
Run Code Online (Sandbox Code Playgroud)

group-by report elasticsearch elasticsearch-aggregation

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

OWIN身份验证和自定义响应

我创建了一个自定义 BasicAuthenticationMiddleware,它使用BasicAuthenticationHandler来验证从客户端到WebAPI的请求.

所述BasicAuthenticationHandler从派生的AuthenticationHandler <TOptions>基类.

一切正常,我实施了

AuthenticateCoreAsync ,用于进行身份验证的逻辑

ApplyChallengeResponseAsync 其中逻辑,在未经过身份验证的请求的情况下,将WWW-Authenticate标头发送到客户端.

我现在想要实现的是在Response中设置一个Custom Body(IOwinResponse,在ApplyChallengeResponseAsync中,使用自定义对象,如:

{
Code="999",
Description="My failing reason"
AdditionalInfo = "My additional infos"
}
Run Code Online (Sandbox Code Playgroud)

而不是像标准的消息

{
    message="Authorization has been denied for this request."
}
Run Code Online (Sandbox Code Playgroud)

你有什么建议吗?

谢谢

asp.net-mvc asp.net-web-api owin asp.net-web-api2

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