UNOFFICIAL
Hi everyone,
I need to get a sum of the values in an int field in all the documents in a
facet. Because there is only a CountFacetRequest in Lucene I am trying to write
a SumFacetRequest with associated Aggregator which does this. However the
results I am getting when I use my SumFacetRequest are not correct.
Here is the aggregate method from the Aggregator I have written (based on
CountingAggregator):
@Override
public void aggregate(int docID, float score, IntsRef ordinals) throws
IOException {
Document doc = searcher.doc(docID);
int value = doc.getField(fieldName).numericValue().intValue();
for (int i = 0; i < ordinals.length; i++) {
sumArray[ordinals.ints[i]] += value;
}
}
Would someone be able to tell me if this is correct? I have been assuming that
ordinals.ints[i] returns an id for a facet that contains the document but maybe
this is not correct.
Any help would be greatly appreciated.
Apologies if this is not the correct forum to post this.
Thanks,
Steve
UNOFFICIAL
--------------------------------------------------------------------
Important Notice: If you have received this email by mistake, please advise
the sender and delete the message and attachments immediately. This email,
including attachments, may contain confidential, sensitive, legally privileged
and/or copyright information. Any review, retransmission, dissemination
or other use of this information by persons or entities other than the
intended recipient is prohibited. DIAC respects your privacy and has
obligations under the Privacy Act 1988. The official departmental privacy
policy can be viewed on the department's website at www.immi.gov.au. See:
http://www.immi.gov.au/functional/privacy.htm
---------------------------------------------------------------------