Skip to content

Commit

Permalink
Add NullValue to IndexingConstants (#15072)
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeAlhayek authored and hishamco committed Feb 1, 2024
1 parent b2ef9d7 commit a1a9d29
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Threading.Tasks;
using OrchardCore.ContentFields.Fields;
using OrchardCore.Contents.Indexing;
using OrchardCore.Indexing;

namespace OrchardCore.ContentFields.Indexing
Expand All @@ -24,7 +25,7 @@ public override Task BuildIndexAsync(ContentPickerField field, BuildFieldIndexCo
{
foreach (var key in context.Keys)
{
context.DocumentIndex.Set(key, "NULL", options);
context.DocumentIndex.Set(key, IndexingConstants.NullValue, options);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Threading.Tasks;
using OrchardCore.ContentFields.Fields;
using OrchardCore.Contents.Indexing;
using OrchardCore.Indexing;
using OrchardCore.Modules;

Expand All @@ -26,7 +27,7 @@ public override Task BuildIndexAsync(LocalizationSetContentPickerField field, Bu
{
foreach (var key in context.Keys)
{
context.DocumentIndex.Set(key, "NULL", options);
context.DocumentIndex.Set(key, IndexingConstants.NullValue, options);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Threading.Tasks;
using OrchardCore.ContentFields.Fields;
using OrchardCore.Contents.Indexing;
using OrchardCore.Indexing;

namespace OrchardCore.ContentFields.Indexing
Expand Down Expand Up @@ -33,7 +34,7 @@ public override Task BuildIndexAsync(UserPickerField field, BuildFieldIndexConte
{
foreach (var key in context.Keys)
{
context.DocumentIndex.Set(key, "NULL", options);
context.DocumentIndex.Set(key, IndexingConstants.NullValue, options);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.IO;
using System.Threading.Tasks;
using Microsoft.Extensions.Options;
using OrchardCore.Contents.Indexing;
using OrchardCore.Environment.Shell.Builders;
using OrchardCore.Indexing;
using OrchardCore.Media.Fields;
Expand Down Expand Up @@ -38,8 +39,8 @@ public async override Task BuildIndexAsync(MediaField field, BuildFieldIndexCont
{
foreach (var key in context.Keys)
{
context.DocumentIndex.Set(key + MediaTextKeySuffix, "NULL", options);
context.DocumentIndex.Set(key + FileTextKeySuffix, "NULL", options);
context.DocumentIndex.Set(key + MediaTextKeySuffix, IndexingConstants.NullValue, options);
context.DocumentIndex.Set(key + FileTextKeySuffix, IndexingConstants.NullValue, options);
}

return;
Expand All @@ -58,7 +59,7 @@ public async override Task BuildIndexAsync(MediaField field, BuildFieldIndexCont
}
else
{
context.DocumentIndex.Set(key + MediaTextKeySuffix, "NULL", options);
context.DocumentIndex.Set(key + MediaTextKeySuffix, IndexingConstants.NullValue, options);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
using Lucene.Net.Spatial.Prefix;
using Lucene.Net.Spatial.Prefix.Tree;
using Lucene.Net.Store;
using LuceneLock = Lucene.Net.Store.Lock;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using OrchardCore.Contents.Indexing;
Expand All @@ -24,6 +23,7 @@
using Spatial4n.Context;
using Directory = System.IO.Directory;
using LDirectory = Lucene.Net.Store.Directory;
using LuceneLock = Lucene.Net.Store.Lock;

namespace OrchardCore.Search.Lucene
{
Expand Down Expand Up @@ -257,7 +257,7 @@ private Document CreateLuceneDocument(DocumentIndex documentIndex, LuceneIndexSe
}
else
{
doc.Add(new StringField(entry.Name, "NULL", store));
doc.Add(new StringField(entry.Name, IndexingConstants.NullValue, store));
}
break;

Expand All @@ -273,7 +273,7 @@ private Document CreateLuceneDocument(DocumentIndex documentIndex, LuceneIndexSe
}
else
{
doc.Add(new StringField(entry.Name, "NULL", store));
doc.Add(new StringField(entry.Name, IndexingConstants.NullValue, store));
}

break;
Expand All @@ -290,7 +290,7 @@ private Document CreateLuceneDocument(DocumentIndex documentIndex, LuceneIndexSe
}
else
{
doc.Add(new StringField(entry.Name, "NULL", store));
doc.Add(new StringField(entry.Name, IndexingConstants.NullValue, store));
}
break;

Expand Down Expand Up @@ -325,11 +325,11 @@ private Document CreateLuceneDocument(DocumentIndex documentIndex, LuceneIndexSe
{
if (entry.Options.HasFlag(DocumentIndexOptions.Keyword))
{
doc.Add(new StringField(entry.Name, "NULL", store));
doc.Add(new StringField(entry.Name, IndexingConstants.NullValue, store));
}
else
{
doc.Add(new TextField(entry.Name, "NULL", store));
doc.Add(new TextField(entry.Name, IndexingConstants.NullValue, store));
}
}
break;
Expand All @@ -354,7 +354,7 @@ private Document CreateLuceneDocument(DocumentIndex documentIndex, LuceneIndexSe
}
else
{
doc.Add(new StoredField(strategy.FieldName, "NULL"));
doc.Add(new StoredField(strategy.FieldName, IndexingConstants.NullValue));
}
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ public static class IndexingConstants
public const string IdsKey = ".Ids";
public const string OrderKey = ".Order";
public const string SourceKey = "_source.";
public const string NullValue = "NULL";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ private SearchDocument CreateSearchDocument(DocumentIndex documentIndex, Diction
{
var stringValue = Convert.ToString(entry.Value);

if (!string.IsNullOrEmpty(stringValue) && stringValue != "NULL")
if (!string.IsNullOrEmpty(stringValue) && stringValue != IndexingConstants.NullValue)
{
// Full-text and display-text support multi-value.
// keyword fields contains single string. All others, support a collection of strings.
Expand Down

0 comments on commit a1a9d29

Please sign in to comment.