Repository navigation
[improvement] Weighted indexer - #37
Merged
Merged
Conversation
Ranks search results by how often each resource is deliberately opened, so frequently consulted resources surface above equally relevant ones. UsageService counts views recorded by QueryService.describe -- opening a resource, never a search impression, which would boost whatever already ranked highly and is self-fulfilling. Counts live in cortex://usage, a reserved named graph beside cortex://provenance, so nothing here writes to the default graph and the review rule still holds. Views buffer in memory and flush in batches: TDB2 admits a single writer, so a write transaction per view would serialize the read path against ingestion. The Spring bean flushes on shutdown via destroyMethod. Only unflushed deltas are held in memory, never totals. Restore replaces the whole assertions dataset during context refresh, so a total cached at construction would be written back over the restored counts at the next flush -- silently, and only on replicas that restore. The current value is re-read inside the flush transaction, making the update a true increment. The weight saturates and is bounded at 2x. Raw counts would let one hot resource swamp textual relevance, and since boosted results are seen and so viewed more often, an unbounded weight compounds into a rich-get-richer loop that new resources cannot break into. Re-ranking runs over the whole candidate set rather than a truncated head, so a popular resource low in the candidates can still be promoted. UsageService is wired into QueryService rather than added as a role, so Cortex remains nine roles and JenaCortex eleven services. Both assembly paths construct it. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Search ranking weights each resource by how often it is opened. Without decay a resource popular a year ago outranks a newer one indefinitely, so a view's contribution now halves every cortex.search.viewHalfLife (default 30d; 0 disables decay and restores plain lifetime counting). cortex:viewCount is therefore no longer a tally but a decayed score, meaningless without the cortex:viewCountUpdated instant beside it. Storing a timestamped event per view would grow without bound, so each resource keeps one score plus when it was last recomputed, and the discount is computed from that. Changing the half-life takes effect immediately, with no stored history to migrate. The discount is applied on read as well as on write. Applying it only on write would leave a resource nobody has opened since holding a stale score until the moment someone opened it again -- exactly backwards. A missing timestamp means "current" rather than the epoch, so counts written before decay existed are not silently wiped on first read. CortexBuilder.DEFAULT_VIEW_HALF_LIFE and the property default must stay equal; the two assembly paths are required to produce identical graphs. Also replaces the note-pad search fixtures' previous naming, which had leaked domain vocabulary into the test corpus and the published docs, and documents the ranking model in README, CLAUDE.md, and the site. The site states plainly that this is a query-independent ranking prior and not Hebbian learning: each resource carries its own score, and nothing strengthens a connection between two resources. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.