Skip to content
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

Improve description of aggregates functions #35

Merged
merged 1 commit into from
Feb 4, 2019
Merged
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
14 changes: 8 additions & 6 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -419,27 +419,29 @@ For make query to the composite index, pass []interface{} to `.WhereComposite` f

### Aggregations

Reindexer allows to do aggregation queries. Currently Average and Sum aggregations are supported. To support aggregation `Query` has method:
`Aggregate` should be called before Query execution - to ask reindexer calculate aggregation.
Reindexer allows to retrive aggregated results. Currently Average and Sum aggregations are supported.
In order to support aggregation, `Query` has method `Aggregate` that should be called before the `Query` execution: this will ask reindexer to calculate data aggregations.

To get aggregation results `Iterator` had method `AggResults`, it is available after query execution, and returns slice of reults.
To get aggregation results, `Iterator` has method `AggResults`: it is available after query execution and returns slice of results.

There are 3 aggregations availavle
There are 3 aggregations available

- `AggMax` - get maximum field value
- `AggMin` - get manimum field value
- `AggSum` - get sum field value
- `AggAvg` - get averatge field value
- `AggFacet` - get field facet value

Example code for aggregate `items` by `name`

```go

iterator := db.Query ("items").Aggregate ("name",reindexer.AggFacet).Exec ()
iterator := db.Query ("items").Aggregate ("name", reindexer.AggFacet).Exec ()

aggRes := iterator.AggResults()[0]

for facet := range aggRes.Facets {
fmt.Printf ("%s -> %d",facet.Value, facet.Count)
fmt.Printf ("%s -> %d", facet.Value, facet.Count)
}

```
Expand Down