Using iKnow metadata to get aggregate metadata values
I have iKnow domain of forum posts, their full text is an iKnow data, and each post also has a number of views as a metadata field.
I want to get a sum of views by concept. Let's say I have a concept called "TESTEST" and there are 10 sources that have this concept. Each source has some views. I want to get views total - impact of this concept so to say.
What's the best iKnow architecture for this use case?
So far I got this:
ClassMethod Views(id As %Integer) As %Integer { #dim domainid As %Integer = ..#DomainId #dim sourceid As %String = ##class(%iKnow.Queries.SourceAPI).GetSourceId(domainid, id) #dim fieldId As %Integer = ##class(%iKnow.Queries.MetadataAPI).GetFieldId(domainid, "Views", .sc) set value = ##class(%iKnow.Queries.MetadataAPI).GetValueById(domainid, fieldId, sourceid, .sc) quit value }
But it's a three stage process.
- Get all sources for a concept.
- Get Views metadata value for each source.
- Sum it all up.
Is there a better solution?