I have a Solr core having documents with 6 fields as below -
FIELDNAME TYPE INDEXED STORED
department STRING TRUE TRUE
group STRING TRUE TRUE
age INT TRUE TRUE
salary INT TRUE TRUE
bonus INT TRUE TRUE
What I want is the following -
SUMthesalaryof all employees from differentdepartment.SUMthesalaryandbonusof all employees from differentdepartment.SUMthesalaryof all employees from differentdepartmentandgroup.SUMthesalaryandbonusof all employees from differentdepartmentandgroup.
Example data -
<doc>
<str name="department">IT</str>
<str name="group">INFRASTRUCTURE</str>
<int name="age">27</int>
<int name="salary">1000</int>
<int name="bonus">10</int>
</doc>
<doc>
<str name="department">IT</str>
<str name="group">DEVELOPMENT</str>
<int name="age">30</int>
<int name="salary">10000</int>
<int name="bonus">100</int>
</doc>
<doc>
<str name="department">IT</str>
<str name="group">DEVOPS</str>
<int name="age">32</int>
<int name="salary">2000</int>
<int name="bonus">150</int>
</doc>
<doc>
<str name="department">IT</str>
<str name="group">INFRASTRUCTURE</str>
<int name="age">35</int>
<int name="salary">20000</int>
<int name="bonus">200</int>
</doc>
<doc>
<str name="department">HR</str>
<str name="group">PEOPLE</str>
<int name="age">27</int>
<int name="salary">900</int>
<int name="bonus">5</int>
</doc>
Excepted Output -
1. For the 1st requirement -
IT - 33000
HR - 900
2. For the 2nd requirement -
IT - 33460
HR - 905
3. For the 3rd requirement -
IT -
INFRASTRUCTURE - 21000
DEVELOPMENT - 10000
DEVOPS - 2000
HR -
PEOPLE - 900
4. For the 4th requirement -
IT -
INFRASTRUCTURE - 21210
DEVELOPMENT - 10100
DEVOPS - 2150
HR -
PEOPLE - 905
I tried to achieve it by following the directions here, however, I am unable to merge PIVOT FACET with the SUM function.