void FacetOperator::doProcessOneResult(const TypedValue & attributeValue, const unsigned facetFieldIndex){ if(attributeValue.getType() == ATTRIBUTE_TYPE_MULTI_INT || attributeValue.getType() == ATTRIBUTE_TYPE_MULTI_LONG || attributeValue.getType() == ATTRIBUTE_TYPE_MULTI_FLOAT || attributeValue.getType() == ATTRIBUTE_TYPE_MULTI_DOUBLE || attributeValue.getType() == ATTRIBUTE_TYPE_MULTI_TEXT || attributeValue.getType() == ATTRIBUTE_TYPE_MULTI_TIME){ std::vector<std::pair<unsigned , std::string> > idsAndNames; this->facetHelpers.at(facetFieldIndex)->generateIDAndNameForMultiValued(attributeValue , idsAndNames); for(std::vector<std::pair<unsigned , std::string> >::iterator idAndName = idsAndNames.begin() ; idAndName != idsAndNames.end() ; ++idAndName){ this->facetResults.at(facetFieldIndex).second->addResultToBucket(idAndName->first , idAndName->second , FacetAggregationTypeCount); } }else{ // single value std::pair<unsigned , std::string> idandName = this->facetHelpers.at(facetFieldIndex)->generateIDAndName(attributeValue); this->facetResults.at(facetFieldIndex).second->addResultToBucket(idandName.first , idandName.second , FacetAggregationTypeCount); } }
void FacetHelper::generateIDAndNameForMultiValued(const TypedValue & attributeValue , std::vector< std::pair<unsigned , std::string> > & resultIdsAndNames){ ASSERT(attributeValue.getType() == ATTRIBUTE_TYPE_MULTI_INT || attributeValue.getType() == ATTRIBUTE_TYPE_MULTI_LONG || attributeValue.getType() == ATTRIBUTE_TYPE_MULTI_FLOAT || attributeValue.getType() == ATTRIBUTE_TYPE_MULTI_DOUBLE || attributeValue.getType() == ATTRIBUTE_TYPE_MULTI_TEXT || attributeValue.getType() == ATTRIBUTE_TYPE_MULTI_TIME); std::vector<TypedValue> singleValues; attributeValue.breakMultiValueIntoSingleValueTypedValueObjects(&singleValues); for(std::vector<TypedValue>::iterator singleValue = singleValues.begin() ; singleValue != singleValues.end() ; ++singleValue){ std::pair<unsigned, std::string> idAndNamePair = generateIDAndName(*singleValue); if(std::find(resultIdsAndNames.begin() , resultIdsAndNames.end() , idAndNamePair) == resultIdsAndNames.end()){ resultIdsAndNames.push_back(idAndNamePair); } } }