Spike: shrink audit full-text search index - #5834
Draft
ramonsmits wants to merge 2 commits into
Draft
Conversation
…earch index
Dates, durations, sizes and booleans in message metadata and headers were being
tokenized into the Query search field of both MessagesView indexes. Nobody searches
for them, and because they are unique per message they inflate the term dictionary
far more than the shared tokens (endpoint names, message types) do.
Identifiers are intentionally kept, since /messages/search/{id} is a full-text search.
Duplicate values (e.g. metadata MessageId vs NServiceBus.MessageId header) are now
indexed once. The analyzer is referenced by its short name since the index rebuilds anyway.
… search Identifiers are never partially matched, so the audit search now ORs an exact match on the MessageId and ConversationId index fields with the full-text search, and the ids (and their header copies) are dropped from the Query field. The OR group is built with the DocumentQuery API because the LINQ provider does not parenthesize it, which would bind the endpoint/time-range filters to the last OR term only.
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.
Spike: shrink the audit
MessagesViewfull-text indexDraft/spike — measuring on a real audit database before deciding whether to ship.
Problem
The
Querysearch field of bothMessagesViewIndexandMessagesViewIndexWithFullTextSearchindexes every metadata value and every header value. A large share of those are timestamps, durations, sizes, booleans and identifiers. Nobody searches for a timestamp or aProcessingTime, and because each of those values is unique per message they never share dictionary terms across documents, so they inflate the term dictionary far more than the shared tokens (endpoint names, message types, host names) do.Changes
Query— metadataTimeSent,CriticalTime,ProcessingTime,DeliveryTime,ContentLength,BodyUrl,IsSystemMessage,IsRetried,BodyNotStored,OriginatesFromSagaand headersTimeSent,ProcessingStarted,ProcessingEnded,DeliverAt,Timeout.Expire,Retries.Timestamp,ExceptionInfo.TimeOfFailure,TimeOfFailure,NonDurableMessage,TimeToBeReceived. Header values are indexed individually rather than as one joined string; null/empty values dropped;Distinct()removes metadata/header duplicates./messages/search/{keyword}now ORsMessageId = keywordandConversationId = keywordwith the full-text search, and ids (plus theirNServiceBus.MessageId/ConversationId/CorrelationId/RelatedToheader copies) are dropped fromQuery. The OR group is built with the DocumentQuery API because the LINQ provider does not parenthesizeSearch(..., SearchOptions.Or), which would bind the endpoint/time-range filters to the last OR term only (verified by inspecting the generated RQL).StandardAnalyzer, as the old comment suggested doing whenever the index has to rebuild anyway.When_processed_message_searched_by_conversationid.Estimated effect
Representative
OrderPlacedaudit message (21 headers, no body), StandardAnalyzer-style tokenization:Real numbers to be measured on an existing audit database (side-by-side trial indexes filtered on
ProcessedAt, old vs newQueryprojection over the same document set).Behaviour changes / open questions
MessagesViewindexes on startup (unavoidable for any map change).CorrelationIdandRelatedToare no longer searchable (no exact-match field). Correlation id usually equals message id. Acceptable?ErrorMessagesDataStore) and the EF/SQL persisters still index ids and timestamps as free text — same pattern, follow-up candidate.Verification
ServiceControl.Audit.Persistence.Tests.RavenDB41/41ServiceControl.Audit.AcceptanceTests.RavenDBandServiceControl.Audit.AcceptanceTestssearch tests 5/5 each