我将Nest 2.1和2.0(alpha)客户端与Nest C#客户端一起使用...我试图批量插入一些记录,但是服务器返回错误。我在与Linux服务器对话的Windows客户端上利用该客户端(但是我认为这并不重要)。
public static void AddQuestionsToElasticSearch()
{
var es = new ElasticsearchClient(new ConnectionConfiguration(
new Uri("http://elasticserver:9200"))
);
var foobars = new FooBar().Parse();
var descriptor = new BulkDescriptor();
descriptor.CreateMany<FooBar>(foobars, (bd, q) => bd.Id(q.Id.ToString()).Index("foobars"));
Console.WriteLine($"Inserting foobars into ES...");
var sw = new Stopwatch();
sw.Start();
var result = es.Bulk<FooBar>(descriptor);
sw.Stop();
Console.WriteLine($"Finished inserting foobars {GetTimeTaken(sw.Elapsed)}");
}
Run Code Online (Sandbox Code Playgroud)
更新-错误信息
我收到的错误是从Bulk()方法返回的响应中...返回的BulkResponse的两个属性是:
OriginalException:“远程服务器返回错误:(400)错误的请求”
ServerError.Error:“验证失败:1:未添加任何请求”
我正在尝试使用NEST复制下面的映射,并在将令牌字符映射到tokenizer时遇到问题.
{
"settings": {
"analysis": {
"filter": {
"nGram_filter": {
"type": "nGram",
"min_gram": 2,
"max_gram": 20,
"token_chars": [
"letter",
"digit",
"punctuation",
"symbol"
]
}
},
"analyzer": {
"nGram_analyzer": {
"type": "custom",
"tokenizer": "whitespace",
"filter": [
"lowercase",
"asciifolding",
"nGram_filter"
]
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我能够复制除令牌字符部分之外的所有内容.有人可以帮助这样做.下面是我的代码复制上面的映射.(令牌字符部分除外)
var nGramFilters1 = new List<string> { "lowercase", "asciifolding", "nGram_filter" };
var tChars = new List<string> { "letter", "digit", "punctuation", "symbol" };
var createIndexResponse = client.CreateIndex(defaultIndex, c => c
.Settings(st => st
.Analysis(an => an
.Analyzers(anz => …Run Code Online (Sandbox Code Playgroud) 我有一个 Observable,它从 API 返回一个大对象。我需要在我的模板中显示这些值。
对于以数组形式返回的其他数据,我可以使用:
<div *ngFor="let value of values | async">
<p>{{ value.prop }}</p>
</div>
Run Code Online (Sandbox Code Playgroud)
我不需要等待异步在 中完成*ngFor,因为它的父元素中已经有一个异步管道。
对于我的对象,我正在寻找类似的东西。目前,我正在做类似的事情:
<h2>{{ (obj | async)?.title }}</h2>
<p>{{ (obj | async)?.prop.prop2 }}</p>
<p>{{ (obj | async)?.another.prop }}</p>
Run Code Online (Sandbox Code Playgroud)
这显然留下了很多重复的代码。这样的事情存在吗?
<div *using="obj | async">
<!-- obj has resolved, can access obj.prop -->
</div>
Run Code Online (Sandbox Code Playgroud) 我编写了以下函数并得到如下所示的响应:
public async Task<GetMappingResponse> ShowMapping(string indexname)
{
var result =await _client.Indices.GetMappingAsync(new GetMappingRequest(indexname));
return result;
}
Run Code Online (Sandbox Code Playgroud)
回复:
{
"apiCall": {
"auditTrail": [
{
"event": 5,
"node": {
"clientNode": false,
......
......
"name": null,
"settings": {},
"uri": "http://localhost:9200/"
},
"path": "pure/_mapping",
"ended": "2020-01-22T11:25:48.2324298Z",
"started": "2020-01-22T11:25:47.836833Z",
"exception": null
}
],
"debugInformation": "Successful (200) low level call on GET: /pure/_mapping\r\n# Audit trail of this API call:\r\n - [1] PingSuccess: Node: http://localhost:9200/ Took: 00:00:00.1716082\r\n - [2] HealthyResponse: Node: http://localhost:9200/ Took: 00:00:00.3955968\r\n# Request:\r\n<Request stream not captured …Run Code Online (Sandbox Code Playgroud) 我想检查当前映射(如在我的C#代码中)与elasticsearch索引中的映射之间的差异.
只有:
var res = esClient.GetMapping<EsCompany>();
Run Code Online (Sandbox Code Playgroud)
我GetMappingResponse在c#中得到了对象,我将不得不逐字段地比较.更糟糕的是,每个字段都有自己的属性,我必须进入这些属性进行进一步比较.
在我的应用程序中,我更喜欢获取映射的原始json,并且我可以轻松区分两个json对象以获得相等性.
然后我尝试了这个:
var res = esClient.Raw.IndicesGetMapping(myIndexName);
Run Code Online (Sandbox Code Playgroud)
但是当我读到时res.Response,我得到一个AmbiguousMatchException例外.
这是我的NuGet.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
</packageSources>
<disabledPackageSources>
<add key="Microsoft and .NET" value="true" />
</disabledPackageSources>
</configuration>
Run Code Online (Sandbox Code Playgroud)
现在,在Visual Studio中,当我尝试安装'geckofx45'软件包时,出现以下错误:
install-package geckofx45 install-package:无法加载源https://api.nuget.org/v3/index.json的服务索引。在第1行:char:1 + install-package geckofx45 + ~~~~~~~~~~~~~~~~~~~~~~~ + + CategoryInfo:未指定:(:) [Install-Package ],异常+ FullyQualifiedErrorId:NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
你有什么解决方案 ?
先感谢您
我有一个登录保护程序,基本上可以检查用户il是否已登录。如果已登录,则跳过登录并转到主页。我编写了这段代码,并且可以正常工作:
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
return this.store.select(fromApp.isAuthenticated)
.pipe(take(1),
map(isAuthenticated => {
if (isAuthenticated) {
this.router.navigate(['/home']);
return false;
} else {
return true;
}
})
)
}
Run Code Online (Sandbox Code Playgroud)
现在,由于我不必更改或编辑输出数据(isAuthenticated布尔值),所以我想:为什么不使用tap运算符?因此,我重新编写了代码:
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
return this.store.select(fromApp.isAuthenticated)
.pipe(take(1),
HERE------> tap(isAuthenticated => { <------ HERE
if (isAuthenticated) {
this.router.navigate(['/home']);
return false;
} else {
return true;
}
})
)
}
Run Code Online (Sandbox Code Playgroud)
然后我去了Chrome,然后看到了黑页,情况就是这样:
我尝试在“材质”表的单元格中显示图像。因此,我在HTML文件中尝试了以下代码:
<ng-container matColumnDef="ImageUrl">
<mat-header-cell *matHeaderCellDef> imageUrl </mat-header-cell>
<mat-cell *matCellDef="let element"> {{element.imageUrl}} </mat-cell>
<img [src]="imageUrl" />
</ng-container>
Run Code Online (Sandbox Code Playgroud)
不幸的是,我的桌子上什么也没有。
我需要计算管道聚合返回的结果集中的桶数。问题是我的查询在这里使用脚本选择器:
POST visitor_carts/_search
{
"size": 0,
"aggs": {
"visitors": {
"terms": {"field" : "visitor_id"},
"aggs": {
"one_purchase": {
"bucket_selector": {
"buckets_path": {
"nb_purchases": "_count"
},
"script": "params.nb_purchases == 3"
}
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
返回类似的内容:
{
"took" : 0,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : 5,
"max_score" : 0.0,
"hits" : [ ]
},
"aggregations" : {
"visitors" …Run Code Online (Sandbox Code Playgroud) 我希望能够访问存储在postgresql数据库中的字段json中存储在json中的更深层元素.例如,我希望能够从下面提供的json访问遍历路径states-> events-> time的元素.这是我正在使用的postgreSQL查询:
SELECT
data#>> '{userId}' as user,
data#>> '{region}' as region,
data#>>'{priorTimeSpentInApp}' as priotTimeSpentInApp,
data#>>'{userAttributes, "Total Friends"}' as totalFriends
from game_json
WHERE game_name LIKE 'myNewGame'
LIMIT 1000
Run Code Online (Sandbox Code Playgroud)
这是来自json字段的示例记录
{
"region": "oh",
"deviceModel": "inHouseDevice",
"states": [
{
"events": [
{
"time": 1430247045.176,
"name": "Session Start",
"value": 0,
"parameters": {
"Balance": "40"
},
"info": ""
},
{
"time": 1430247293.501,
"name": "Mission1",
"value": 1,
"parameters": {
"Result": "Win ",
"Replay": "no",
"Attempt Number": "1"
},
"info": ""
}
]
}
],
"priorTimeSpentInApp": …Run Code Online (Sandbox Code Playgroud) 我有一个Visual Studio项目,它在TeamCity中设置了一个构建任务,通过OctoPack(3.0.43)创建工件.接下来,部署任务,从构建任务任务(成功构建)接收输出NuGet包作为依赖项.
我已经尝试使用MsBuildbuild-runner和Visual Studio (sln)one 来设置构建任务,但在这两种情况下都没有创建工件.
我已将OctoPack NuGet包添加到我的Visual Studio项目中.
我正在使用Anuglar材质(5.0.4),并且我希望mat-fab-button默认的背景颜色是白色,就像Angular示例中一样。但是对我来说,由于某种原因,背景色是强调色。
的HTML
<h2>Fab Buttons</h2>
<div>
<button mat-fab>Basic</button>
<button mat-fab color="primary">Primary</button>
<button mat-fab color="accent">Accent</button>
<button mat-fab color="warn">Warn</button>
<button mat-fab disabled>Disabled</button>
<button mat-fab>
<mat-icon aria-label="Example icon-button with a whats hot icon">whatshot</mat-icon>
</button>
<a mat-fab routerLink=".">Link</a>
</div>
<h2>Mini Fab Buttons</h2>
<div>
<button mat-mini-fab>Basic</button>
<button mat-mini-fab color="primary">Primary</button>
<button mat-mini-fab color="accent">Accent</button>
<button mat-mini-fab color="warn">Warn</button>
<button mat-mini-fab disabled>Disabled</button>
<button mat-mini-fab>
<mat-icon aria-label="Example icon-button with a whats hot icon">whatshot</mat-icon>
</button>
<a mat-mini-fab routerLink=".">Link</a>
</div>
Run Code Online (Sandbox Code Playgroud)
主题
$deeporange-teal-amber-theme-primary: mat-palette($mat-deep-orange, 500, 100, 700);
$deeporange-teal-amber-theme-accent: mat-palette($mat-teal);
$deeporange-teal-amber-theme-warn: …Run Code Online (Sandbox Code Playgroud) angular ×4
nest ×4
nuget ×2
json ×1
msbuild ×1
observable ×1
octopack ×1
postgresql ×1
redux ×1
rxjs ×1
rxjs6 ×1
teamcity ×1
typescript ×1