Skip to content

Update documentation #650

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 13, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions new_docs/contents/nest/core/delete-by-query.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,30 @@ menuitem: delete-by-query

# Delete by Query

this.ConnectedClient.DeleteByQuery<ElasticSearchProject>(q => q.Term(f => f.Name, "elasticsearch.pm"));
ConnectedClient.DeleteByQuery<object>(q => q.Query(rq => rq.Term(f => f.Name, "elasticsearch.pm")));

Elasticsearch allows you to delete over multiple types and indexes, so does NEST.

this.ConnectedClient.DeleteByQuery<ElasticSearchProject>(q => q
.Indices(new[] { "index1", "index2" })
.Term(f => f.Name, "elasticsearch.pm")
ConnectedClient.DeleteByQuery<ElasticSearchProject>(q => q
.Indices(new[] {"index1", "index2"})
.Query(rq => rq.Term(f => f.Name, "elasticsearch.pm"))
);

As always `*Async` variants are available too.

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

this.ConnectedClient.DeleteByQuery<ElasticSearchProject>(q => q
ConnectedClient.DeleteByQuery<ElasticSearchProject>(q => q
.AllIndices()
.Term(f => f.Name, "elasticsearch.pm")
.Query(rq => rq.Term(f => f.Name, "elasticsearch.pm"))
);

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

this.ConnectedClient.DeleteByQuery<ElasticSearchProject>(
q => q.Term(f => f.Name, "elasticsearch.pm")
, new DeleteByQueryParameters { Consistency = Consistency.Quorum, Replication = Replication.Sync, Routing = "NEST" }
ConnectedClient.DeleteByQuery<ElasticSearchProject>(q => q
.Query(rq => rq
.Term(f => f.Name, "elasticsearch.pm"))
.Routing("nest")
.Replication(ReplicationOptions.Sync)
);

19 changes: 13 additions & 6 deletions new_docs/contents/nest/core/delete.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,27 @@ The delete API allows to delete a typed JSON document from a specific index base

## By Id

this.ConnectedClient.DeleteById<ElasticSearchProject>(searchProject.Id);
this.ConnectedClient.DeleteByIdAsync<ElasticSearchProject>(searchProject.Id, c => /* called later */);
this.ConnectedClient.Delete<ElasticSearchProject>(searchProject.Id);
this.ConnectedClient.DeleteAsync<ElasticSearchProject>(searchProject.Id);

## Delete with custom parameters

_client.Delete(request.Id, s => s
.Type("users")
.Index("myindex")
);

## By object (T)

Id property is inferred (can be any value type (int, string, float ...))

this.ConnectedClient.Delete(searchProject);
this.ConnectedClient.DeleteAsync(searchProject);
this.ConnectedClient.Delete(searchProject);
this.ConnectedClient.DeleteAsync(searchProject);

## By IEnumerable<T>

this.ConnectedClient.DeleteMany(searchProjects);
this.ConnectedClient.DeleteManyAsync(searchProjects);
this.ConnectedClient.DeleteMany(searchProjects);
this.ConnectedClient.DeleteManyAsync(searchProjects);

## By IEnumerable<T> using bulkparameters

Expand Down
6 changes: 5 additions & 1 deletion new_docs/contents/nest/core/index.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ is sufficient. this will index post too `/[default index]/posts/12`. The typenam

If you need more control there are plenty of overloads, i.e:

client.Index(post, "index", "type", "id");
_client.Index(post, i => i
.Index(index)
.Type(type)
.Id(post.Id)
);

## Asynchronous

Expand Down
34 changes: 34 additions & 0 deletions new_docs/contents/nest/query/aggregation.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
template: layout.jade
title: Connecting
menusection: search
menuitem: aggregation
---


# Aggregations

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.

## Simple query

var results = EClinet.Search<ElasticSearchObject>(s => s.QueryString("*")
.Aggregations(a => a.Terms("GroupName", ta => ta.Field("Category")))
);

then to read items

var termBucket = results.Aggs.Terms("GroupName").Items;

## Global

var results = EClinet.Search<ElasticSearchObject>(s => s.QueryString("*")
.Aggregations(a => a.Global("Title", g=>g.Aggregations(ga => ga.Terms("GroupName", ta => ta.Field("Category"))))
));

##Sub aggregation

var results = EClinet.Search<ElasticSearchObject>(s => s.QueryString("*")
.Aggregations(a => a.Global("Title", g=>g.Aggregations(ga => ga.Terms("GroupName", ta => ta.Field("Category")
.Aggregations(sa=>sa.Terms("Color", sat=>sat.Field("Color")))
)))));