AggregateRule[] aggregateRules = indexingConfig.getAggregateRules();
if (aggregateRules == null) {
return;
}
try {
ItemDataConsumer ism = getContext().getItemStateManager();
for (int i = 0; i < aggregateRules.length; i++) {
boolean ruleMatched = false;
// node includes
NodeData[] aggregates = aggregateRules[i]
.getAggregatedNodeStates(state);
if (aggregates != null) {
ruleMatched = true;
for (int j = 0; j < aggregates.length; j++) {
Document aDoc = createDocument(aggregates[j],
getNamespaceMappings(), index
.getIndexFormatVersion());
// transfer fields to doc if there are any
Fieldable[] fulltextFields = aDoc
.getFieldables(FieldNames.FULLTEXT);
if (fulltextFields != null) {
for (int k = 0; k < fulltextFields.length; k++) {
doc.add(fulltextFields[k]);
}
doc.add(new Field(
FieldNames.AGGREGATED_NODE_UUID,
aggregates[j].getIdentifier(),
Field.Store.NO,
Field.Index.NOT_ANALYZED_NO_NORMS));
}
}
}
// property includes
PropertyData[] propStates = aggregateRules[i]
.getAggregatedPropertyStates(state);
if (propStates != null) {
ruleMatched = true;
for (int j = 0; j < propStates.length; j++) {
PropertyData propState = propStates[j];
String namePrefix = FieldNames
.createNamedValue(getNamespaceMappings()
.translateName(
propState.getQPath()
.getName()), "");
NodeData parent = (NodeData) ism
.getItemData(propState
.getParentIdentifier());
Document aDoc = createDocument(parent,
getNamespaceMappings(), getIndex()
.getIndexFormatVersion());