Skip to content

Commit

Permalink
RavenDB-22703 Added index version check for v6.1
Browse files Browse the repository at this point in the history
Lwiel committed Aug 30, 2024
1 parent d05e561 commit d05bbf8
Showing 3 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -177,14 +177,18 @@ public static class IndexVersion
public const long PhraseQuerySupportInCoraxIndexes = 60_002;
public const long StoreOnlySupportInCoraxIndexes = 60_003; // RavenDB-22369
public const long JavaScriptProperlyHandleDynamicFieldsIndexFields = 60_004; // RavenDB-22363
public const long UseNonExistingPostingList = 60_005; // RavenDB-22703
public const long LoadDocumentWithDynamicCollectionNameShouldThrow = 61_000; // RavenDB-22359
public const long UseNonExistingPostingList_60 = 60_005; // RavenDB-22703

public const long Base61Version = 61_000;

public const long LoadDocumentWithDynamicCollectionNameShouldThrow = Base61Version; // RavenDB-22359
public const long CoraxComplexFieldIndexingBehavior = 61_001;
public const long UseNonExistingPostingList_61 = 61_002; // RavenDB-22703

/// <summary>
/// Remember to bump this
/// </summary>
public const long CurrentVersion = CoraxComplexFieldIndexingBehavior;
public const long CurrentVersion = UseNonExistingPostingList_61;

public static bool IsTimeTicksInJavaScriptIndexesSupported(long indexVersion)
{
@@ -195,6 +199,14 @@ public static bool IsTimeTicksInJavaScriptIndexesSupported(long indexVersion)

return indexVersion >= TimeTicksSupportInJavaScriptIndexes_54;
}

public static bool IsNonExistingPostingListSupported(long indexVersion)
{
if (indexVersion >= Base61Version)
return indexVersion >= UseNonExistingPostingList_61;

return indexVersion >= UseNonExistingPostingList_60;
}
}
}

Original file line number Diff line number Diff line change
@@ -425,15 +425,16 @@ protected void InsertRegularField<TBuilder>(IndexField field, object value, Json

protected void RegisterMissingFieldFor(IndexField field)
{
if (field.Id == CoraxConstants.IndexWriter.DynamicField || _index.Definition.Version < IndexDefinitionBaseServerSide.IndexVersion.UseNonExistingPostingList)
if (field.Id == CoraxConstants.IndexWriter.DynamicField ||
IndexDefinitionBaseServerSide.IndexVersion.IsNonExistingPostingListSupported(_index.Definition.Version) == false)
return;

_nonExistingFieldsOfDocument.Add(field.Name);
}

protected void WriteNonExistingMarkerForMissingFields<TBuilder>(TBuilder builder) where TBuilder : IIndexEntryBuilder
{
if (_index.Definition.Version < IndexDefinitionBaseServerSide.IndexVersion.UseNonExistingPostingList)
if (IndexDefinitionBaseServerSide.IndexVersion.IsNonExistingPostingListSupported(_index.Definition.Version) == false)
return;

foreach (var fieldName in _nonExistingFieldsOfDocument)
Original file line number Diff line number Diff line change
@@ -280,7 +280,7 @@ internal static IQueryMatch BuildQuery(Parameters builderParameters, out OrderMe

var indexVersion = builderParameters.Index.Definition.Version;

if (indexVersion >= IndexDefinitionBaseServerSide.IndexVersion.UseNonExistingPostingList)
if (IndexDefinitionBaseServerSide.IndexVersion.IsNonExistingPostingListSupported(indexVersion))
{
var queryWithNullAndNonExistingMatches = indexSearcher.IncludeNonExistingMatch(in sortBy.Field, queryWithNullMatches, sortBy.Ascending);
coraxQuery = queryWithNullAndNonExistingMatches;

0 comments on commit d05bbf8

Please sign in to comment.