Hi there,
I have a kind of object stored on magmacollections which has been indexed by an attribute which returns N dates. I've made an index which is pretty much like MaKeywordIndex but for DateAndTimes.
It works well. Now I need a metric on those objects to score them regarding to the number of ocurrences of the dates they will be found on the odb. So I have:
scoringLevel "Answers the quantity of dates of some relevance for the receiver."
^ ((self elements where:[:reader| (reader read: #relevantDates from: (Date today subtractDays: self daysBack) asDateAndTime to: DateAndTime now)]) distinct: true) size
by now I've set 2 years by answering 360*2 in daysBack but what if I want the socing for whole thing?
I've tried #read: without parameters other than the index name but then I've realized is not implemented in magma reader. I wish I can do something to count occurrences of my query like:
scoringLevel "Answers the quantity of dates of some relevance for the receiver."
^ ((self elements where:[:reader| reader read: #relevantDates]) distinct: true) size
So taking a look in the reader and indexes I figured I put in my *MagmaExtensions this method:
MagmaCollectionReader>>read: attributeSymbol "Answers a MaLargeCollectionReader with access to all its elements. NOTE: warning, is the whole thing, use smartly"
^ [:index| self readIndex: index fromHash: index lowestPossibleKey toHash: index highestPossibleKey] value: (self indexNamed: attributeSymbol)
But this it's returning a MaClause and no a reader as expected? Any clue on whats happening?
thanks,
Sebastian Sastre