- Elasticsearch Blueprints
- Vineeth Mohan
- 281字
- 2021-07-16 13:39:33
Aggregating your results
Next, when I search for Lenovo, I would like to see different product types associated with it. This is more like making a report out of the results, but then, as this makes your data more explorable and easy to understand, it's safe to see this as enhancing search capabilities.
Hence, whenever I search for something, I want to see the following reports on my query results or rather, an aggregate of my results in the following information:
- Different types of
productType
- The number of products in various predefined price ranges
- The number of documents per year based on manufacturing dates
For this, we need to build different aggregations to capture these reports.
Note
It's very important to understand that the score of aggregation is the query. This means that the aggregations would only be done on those documents that match the query.
The format in which we should provide aggregations is as follows:
{ "query" : { ….}, "aggregations" : { "aggregationNameA" : { "aggregationType" : { <Aggregation type specific information> }, } }, "aggregationNameB" : { "aggregationType" : { <Aggregation type specific information> }, } }, { …. } }
Once we fire a search request with this JSON, we can retrieve our results in the following format:
{ "took" : 21 , …. }
Note
We identify the results of the inpidual aggregation request using the aggregation name we gave in the query.
Terms aggregation
Terms aggregation is usually done on string field types, which means that this is very handy to retrieve statistics on terms. Like in our case, the number of different unique values for the productType
and the number of documents in which each terms are occurring.
- 黑客攻防從入門(mén)到精通(實(shí)戰(zhàn)秘笈版)
- Mastering Selenium WebDriver
- Mastering Ember.js
- Vue.js 3.x從入門(mén)到精通(視頻教學(xué)版)
- Python爬蟲(chóng)開(kāi)發(fā)與項(xiàng)目實(shí)戰(zhàn)
- 面向?qū)ο蟪绦蛟O(shè)計(jì)(Java版)
- Java軟件開(kāi)發(fā)基礎(chǔ)
- GameMaker Programming By Example
- Microsoft System Center Orchestrator 2012 R2 Essentials
- Learning SciPy for Numerical and Scientific Computing(Second Edition)
- C語(yǔ)言程序設(shè)計(jì)
- Express Web Application Development
- Illustrator CC平面設(shè)計(jì)實(shí)戰(zhàn)從入門(mén)到精通(視頻自學(xué)全彩版)
- 零基礎(chǔ)學(xué)Python編程(少兒趣味版)
- C指針原理揭秘:基于底層實(shí)現(xiàn)機(jī)制