private void forEachUpdateToolStripMenuItem_Click(object sender, EventArgs e) { var tempNode = (ElasticNode)treeViewAdv1.SelectedNode.Tag; if (tempNode != null) { var start = DateTime.Now; var size = 500; string type = "bc8c7a80-c2fc-4d62-9de3-ec6b9f59ba95"; GetInput g=new GetInput(type,"Type"); if(g.ShowDialog()==DialogResult.OK) { type = g.Input; } string query = "*"; g = new GetInput(query, "Query"); if (g.ShowDialog() == DialogResult.OK) { query = g.Input; } var total = currentElasticSearchInstance.Count(tempNode.IndexName, query); string sort = "__TIME"; g = new GetInput(sort, "SortBy"); if (g.ShowDialog() == DialogResult.OK) { sort = g.Input; } string content = "{\"visibleType\":\"0\"}"; g = new GetInput(content, "update content"); if (g.ShowDialog() == DialogResult.OK) { content = g.Input; } int hit = 0; for (int i = 0; i < total; i+=size) { WriteLog("Index From:{0},Size:{1}".Fill(i,size)); SearchResult docs= currentElasticSearchInstance.Search(tempNode.IndexName, type, new QueryStringQuery(query), new SortItem(sort, SortType.Asc), i, size); WriteLog("QueryResult:{0} // {1}".Fill(docs.GetHitIds().Count,docs.GetTotalCount())); List<string> ids = docs.GetHitIds(); foreach (var id in ids) { var result= currentElasticSearchInstance.PartialUpdate(tempNode.IndexName, type, id, content); if(result) { hit += 1; }else{WriteLog("Index Failed:{0}".Fill(id));} } } var end = DateTime.Now; WriteLog("Index:{0} Updating Finished.total {1} updated,time:{2},{3} ".Fill(tempNode.IndexName, hit,end-start,hit)); } }
private void facetToolStripMenuItem_Click(object sender, EventArgs e) { var tempNode = (ElasticNode)treeViewAdv1.SelectedNode.Tag; if (tempNode != null) { var g = new GetInput("","pls input a fileld name to do Facet"); if (g.ShowDialog() == DialogResult.OK) { var facets= currentElasticSearchInstance.Search(tempNode.IndexName, new ElasticQuery(new MatchAllQuery(), null, 0, 10) {Facets = new TermsFacet("facet", g.Input)}); tempNode.Nodes.Clear();//NOTE var facetNode = new ElasticNode("facets"); tempNode.Nodes.Add(facetNode); if (facets.Facets != null) foreach (var facet in facets.Facets) { var item = new ElasticNode(facet.Key + "(" + facet.Value.Count + ")"); facetNode.Nodes.Add(item); foreach (var VARIABLE in facet.Value) { item.Nodes.Add(new ElasticNode(VARIABLE.Key + "(" + VARIABLE.Value.ToString() + ")")); } } } } }
private void facetToolStripMenuItem_Click(object sender, EventArgs e) { var tempNode = (ElasticNode)treeViewAdv1.SelectedNode.Tag; if (tempNode != null) { var g = new GetInput("", "pls input a fileld name to do Facet,ie: disease.name.not_analyzed"); if (g.ShowDialog() == DialogResult.OK) { int facet_size = 10; var gf = new GetInput("","pls input size of Facet"); if (gf.ShowDialog() == DialogResult.OK) { if(!gf.Input.ToString().IsNullOrEmpty()) { facet_size = Convert.ToInt32(gf.Input); } } var facets= currentElasticSearchInstance.Search(tempNode.IndexName, new ElasticQuery(new MatchAllQuery(), null, 0, 10) { Facets = new TermsFacet("facet", g.Input, facet_size) }); // WriteLog("facets.Response"); // WriteLog(facets.Response); tempNode.Nodes.Clear();//NOTE var facetNode = new ElasticNode("facets"); tempNode.Nodes.Add(facetNode); if (facets.Facets != null) foreach (var facet in facets.Facets) { var item = new ElasticNode(facet.Key + "(" + facet.Value.Count + ")"); facetNode.Nodes.Add(item); foreach (var VARIABLE in facet.Value) { item.Nodes.Add(new ElasticNode(VARIABLE.Key + "(" + VARIABLE.Value.ToString() + ")")); } } } } }