Skip to content

Commit df613d6

Browse files
author
unknown
committed
aggregation and delete query
1 parent 9b97aed commit df613d6

File tree

2 files changed

+42
-8
lines changed

2 files changed

+42
-8
lines changed

new_docs/contents/nest/core/delete-by-query.markdown

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,25 @@ menuitem: delete-by-query
1313
Elasticsearch allows you to delete over multiple types and indexes, so does NEST.
1414

1515
ConnectedClient.DeleteByQuery<ElasticSearchProject>(q => q
16-
.Indices(new[] {"index1", "index2"})
17-
.Query(rq => rq.Term(f => f.Name, "elasticsearch.pm"))
16+
.Indices(new[] {"index1", "index2"})
17+
.Query(rq => rq.Term(f => f.Name, "elasticsearch.pm"))
1818
);
1919

2020
As always `*Async` variants are available too.
2121

2222
You can also delete by query over all the indices and types:
2323

2424
ConnectedClient.DeleteByQuery<ElasticSearchProject>(q => q
25-
.AllIndices()
26-
.Query(rq => rq.Term(f => f.Name, "elasticsearch.pm"))
25+
.AllIndices()
26+
.Query(rq => rq.Term(f => f.Name, "elasticsearch.pm"))
2727
);
2828

2929
The DeleteByQuery can be further controlled by passing a `DeleteByQueryParameters` object
3030

3131
ConnectedClient.DeleteByQuery<ElasticSearchProject>(q => q
32-
.Query(rq => rq
33-
.Term(f => f.Name, "elasticsearch.pm"))
34-
.Routing("nest")
35-
.Replication(ReplicationOptions.Sync)
32+
.Query(rq => rq
33+
.Term(f => f.Name, "elasticsearch.pm"))
34+
.Routing("nest")
35+
.Replication(ReplicationOptions.Sync)
3636
);
3737
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
template: layout.jade
3+
title: Connecting
4+
menusection: search
5+
menuitem: aggregation
6+
---
7+
8+
9+
# Aggregations
10+
11+
Aggregations is new and more powerfull way to build facets. Using them its possible to build any kind of facets and grouped in way as needed.
12+
13+
## Simple query
14+
15+
var results = EClinet.Search<ElasticSearchObject>(s => s.QueryString("*")
16+
.Aggregations(a => a.Terms("GroupName", ta => ta.Field("Category")))
17+
);
18+
19+
then to read items
20+
21+
var termBucket = results.Aggs.Terms("GroupName").Items;
22+
23+
## Global
24+
25+
var results = EClinet.Search<ElasticSearchObject>(s => s.QueryString("*")
26+
.Aggregations(a => a.Global("Title", g=>g.Aggregations(ga => ga.Terms("GroupName", ta => ta.Field("Category"))))
27+
));
28+
29+
##Sub aggregation
30+
31+
var results = EClinet.Search<ElasticSearchObject>(s => s.QueryString("*")
32+
.Aggregations(a => a.Global("Title", g=>g.Aggregations(ga => ga.Terms("GroupName", ta => ta.Field("Category")
33+
.Aggregations(sa=>sa.Terms("Color", sat=>sat.Field("Color")))
34+
)))));

0 commit comments

Comments
 (0)