我有一个 4 节点的 elasticsearch 集群。我有一个 .net 控制台应用程序,旨在用来自 sql 的数据填充集群。只要我将添加(或删除)记录的速度保持在相当低的水平,一切都可以正常工作。如果我最终增加线程数,我会在控制台应用程序中看到超时错误。该集群共有 48 个内核,索引一条记录所需的平均时间约为 0.1 秒。
我已经能够让它每秒处理大约 7000 条记录(文档)。我从来没有看到从 elasticsearch.net 抛出的任何表明资源不足的异常。我从未看到任何索引队列超载。服务器的 CPU 峰值永远不会超过 10%。看起来问题不是集群或其配置,而是嵌套连接中的问题。这是我的连接代码:
//set up the es client
Uri node = new Uri(ConfigurationManager.AppSettings["ESConnectionString"]);
var connectionPool = new SniffingConnectionPool(new[] { node });
ConnectionSettings settings = new ConnectionSettings(connectionPool);
settings.SetDefaultPropertyNameInferrer(p => p); //ditch the camelcase
settings.SniffOnConnectionFault(true);
settings.SniffOnStartup(true);
settings.SniffLifeSpan(TimeSpan.FromMinutes(1));
settings.SetPingTimeout(3000);
settings.SetTimeout(5000);
settings.MaximumRetries(5);
//settings.SetMaximumAsyncConnections(20);
settings.SetDefaultIndex("dummyindex");
settings.SetBasicAuthentication(ConfigurationManager.AppSettings["ESUser"], ConfigurationManager.AppSettings["ESPass"]);
ElasticClient client = new ElasticClient(settings);
Run Code Online (Sandbox Code Playgroud)
我使用 http.basic 身份验证设置了集群,但我尝试打开和关闭它,但没有任何区别。以下是来自 ES 节点的一些相关设置:
discovery.zen.minimum_master_nodes: 2
discovery.zen.fd.ping_timeout: 30s
discovery.zen.ping.multicast.enabled: false
discovery.zen.ping.unicast.hosts: ["CACHE01","CACHE02","CACHE03","CACHE04"]
cluster.routing.allocation.node_concurrent_recoveries: 5 …Run Code Online (Sandbox Code Playgroud) 我很难让模块在Angular 2中工作.我已经创建了一个演示问题的插件.在插件中,你会看到我有app.module.该模块导入app-common.module,其中包含一个显示页眉的组件.顶级组件的模板app.component包含此组件的选择器.这是app.common.module:
@NgModule({
imports:[CommonModule, FormsModule],
declarations: [PageHeaderComponent]
})
export class AppCommonModule { }
Run Code Online (Sandbox Code Playgroud)
这是app.module:
@NgModule({
imports: [AppCommonModule, BrowserModule],
declarations: [AppComponent ],
bootstrap: [ AppComponent ]
})
export class AppModule { }
Run Code Online (Sandbox Code Playgroud)
运行应用程序时,它会抛出一个错误,"ref-pageheader"不是已知元素.如果我在app.module中声明组件,它可以正常工作.那么,为什么我不能在导入到主app.module的模块中声明这个组件?看来Angular在完成后无法找到它.我究竟做错了什么?我错过了什么吗?
在我的Angular应用程序中,我有一个父模块与其他子模块一起填充.我的子模块有这个模板:
<input type="radio" class="form-control"
[checked] = "message.default == 1"
[value] = "message.default"
(change)="onSelectionChange(message)"
name="default" >
Run Code Online (Sandbox Code Playgroud)
这是ts:
export class MessageComponent implements OnInit {
message: MessageInterface;
@Output() onCheckedChange = new EventEmitter<MessageInterface>();
constructor() { }
ngOnInit() {
}
onSelectionChange(message: MessageInterface) {
this.onCheckedChange.emit(message);
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的父模板
<div #placeholder ></div>
Run Code Online (Sandbox Code Playgroud)
和ts
export class ParentComponent implements OnInit {
@ViewChild('placeholder', {read: ViewContainerRef}) placeHolder;
ngOnInit() {
for(let i=0; i<this.aVariable; i++) {
let factory = this.componentFactoryResolver.resolveComponentFactory(ChildComponent);
this.placeHolder.createComponent(factory);
}
}
onCheckedChange(message: MessageInterface) {
console.log("parent intercept");
}
Run Code Online (Sandbox Code Playgroud)
其中"aVariable"变量是从我调用的服务返回的值.
当我点击radiobutton时,没有显示日志消息,似乎父节点没有收到EventEmitter发射.怎么了?
我正在使用LazyCache ,并且希望每小时刷新一次缓存,但理想情况下,我希望缓存项过期后的第一个调用者不要等待缓存重新加载。我写了以下内容
\n\npublic async Task<List<KeyValuePair<string, string>>> GetCarriersAsync()\n{\n\n var options = new MemoryCacheEntryOptions\n {\n AbsoluteExpirationRelativeToNow = new TimeSpan(1,0,0),// consider to config\n }.RegisterPostEvictionCallback(\n async (key, value, reason, state) =>\n {\n await GetCarriersAsync();//will save to cache\n _logger.LogInformation("Carriers are reloaded: " );\n });\n Func<Task<List<KeyValuePair<string, string>>>> cacheableAsyncFunc = () => GetCarriersFromApi();\n var cachedCarriers = await _cache.GetOrAddAsync($"Carriers", cacheableAsyncFunc, options);\n\n return cachedCarriers;\n}\nRun Code Online (Sandbox Code Playgroud)\n\n但是,当缓存项过期时,不会调用 RegisterPostEvictionCallback,而是仅在对该项的下一个请求发生时调用(并且调用者需要等待漫长的操作)。
\n\n线程 Expiration 几乎永远不会在后台自行发生\xc2\xa0#248解释说这是设计使然,并建议解决方法来指定 CancellationTokenSource.CancelAfter(TimeSpan.FromHours(1)) 而不是 SetAbsoluteExpiration。
\n\n不幸的是,LazyCache.GetOrAddAsync 没有\xe2\x80\x99t 有 CancellationToken 作为参数。\n在预定时间触发缓存重新加载且第一个用户的等待时间最短的最佳方法是什么?
\nES 并不是我工作的主流,而且有一种行为我无法纠正。我有一个相当简单的聚合查询:
GET /my_index/_search
{
"size": 0,
"query": {
"bool": {
"must": [
{
"match": {
"request_type": "some_type"
}
},
{
"match": {
"carrier_name.keyword": "some_carrier"
}
}
]
}
},
"aggs": {
"by_date": {
"terms": {
"field": "date",
"order": {
"_term": "asc"
}
},
"aggs": {
"carrier_total": {
"sum": {
"field": "total_count"
}
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我对https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html的理解是,并非所有文档都包含在聚合中。事实上,根据查询部分,我确实在结果中看到“sum_other_doc_count”:值大于零。
我的问题:有没有办法构建搜索以包含所有文档?文档数量相当少,通常在1k以下,
预先感谢,鲁文
我正在使用带有Nest的ElasticSearch(0.9.16)并且有一些查询需要超过60秒.发生这种情况时,我收到以下错误:
var setting = new ConnectionSettings(new Uri(searchUrl)).SetTimeout(200000);
Run Code Online (Sandbox Code Playgroud)
虽然我担心查询花了这么长时间,但对于这个问题,如果有办法增加超时,我只是感兴趣.我一直无法找到增加超时的方法.
注意,我确实看到了几个可以设置超时的地方,但这些不是正确的地方:
searchdescriptor.Timeout("120000");
Run Code Online (Sandbox Code Playgroud)
要么
var setting = new ConnectionSettings(new Uri(searchUrl)).SetTimeout(200000);
Run Code Online (Sandbox Code Playgroud)
第一个设置连接超时,第二个设置ElasticSearch超时,这两个都没有帮助.
谢谢,埃里克
我的应用程序类中有编译错误.这是我的代码AssemblyInfo.cs:
[assembly: AssemblyTitle("myApp")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("CCS")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
[assembly: AssemblyVersion ("0.1.0")]
// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.
//[assembly: AssemblyDelaySign(false)]
//[assembly: …Run Code Online (Sandbox Code Playgroud) 我试图在multiMatch搜索中增加一些字段而不是其他字段.
看看我看到的文档可以Field通过这样做来创建一个提升
var titleField = Infer.Field<Page>(p => p.Title, 2);
Run Code Online (Sandbox Code Playgroud)
我无法弄清楚这是如何转化的Fields.
这样的事情是不对的
var bodyField = Infer.Field<Page>(p => p.Body);
var titleField = Infer.Field<Page>(p => p.Title, 2);
var metaDescriptionField = Infer.Field<Page>(p => p.MetaDescription, 1.5);
var metaKeywordsField = Infer.Field<Page>(p => p.Keywords, 2);
MultiMatchQuery multiMatchQuery = new MultiMatchQuery()
{
Fields = Infer.Fields<Page>(bodyField, titleField, metaDescriptionField, metaKeywordsField),
Query = search.Term
};
Run Code Online (Sandbox Code Playgroud)
我是否需要为字段使用字符串名称
var titleFieldString = "Title^2";
Run Code Online (Sandbox Code Playgroud)
把它们传递进去 Infer.Fields
我有以下代码将消息发送到总线:
var queueClient = new QueueClient(ServiceBusConnectionString, QueueName);
var message = new Message(poco.SerializeToBytes());
await queueClient.SendAsync(message);
Run Code Online (Sandbox Code Playgroud)
但他们似乎直接进入了死亡信件消息计数:
我还创建了一个Azure函数,它将选择消息:
[FunctionName("ServiceBusFunction")]
public static void Run([ServiceBusTrigger("schedule", AccessRights.Listen, Connection = "ServiceBusConnection")]byte[] myQueueItem, TraceWriter log)
{
log.Info($"C# ServiceBus queue trigger function processed message: {myQueueItem}");
}
Run Code Online (Sandbox Code Playgroud)
当我关闭该功能时,在创建此功能之前,消息进入ACTIVE MESSAGE COUNT.我已尝试在本地运行该函数,但该函数未被命中.我觉得自己错过了从函数中获取总线上的消息方面的基本信息吗?
azure azureservicebus azure-servicebus-queues azure-functions
我正在做一个angular2项目,在assets文件夹中有一个文件,并且创建了一个在运行应用程序时下载文件的按钮。
我看到上述问题有很多解决方案,所以我很困惑。你能帮忙吗?
<button pButton type="button" (click)="f1()" label="Download Sample Defaults
XML File"></button>
Run Code Online (Sandbox Code Playgroud)
我需要f1()的代码,当单击上面的按钮时,该代码可以帮助我将文件下载到我的“下载”文件夹中。帮助表示赞赏。谢谢
angular ×3
nest ×3
.net-core ×1
android ×1
angular-http ×1
azure ×1
c# ×1
caching ×1
eventemitter ×1
lazycache ×1
memorycache ×1
timeout ×1