-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a base document-index to allow indexing non-content items in Azur…
…eAI search (#16611)
- Loading branch information
1 parent
4395dbb
commit dbb2f05
Showing
8 changed files
with
102 additions
and
90 deletions.
There are no files selected for viewing
This file contains 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
74 changes: 6 additions & 68 deletions
74
src/OrchardCore/OrchardCore.Indexing.Abstractions/DocumentIndex.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,14 @@ | ||
using Microsoft.AspNetCore.Html; | ||
|
||
namespace OrchardCore.Indexing; | ||
|
||
public class DocumentIndex(string contentItemId, string contentItemVersionId) | ||
public class DocumentIndex : DocumentIndexBase | ||
{ | ||
public List<DocumentIndexEntry> Entries { get; } = []; | ||
|
||
public void Set(string name, string value, DocumentIndexOptions options) | ||
{ | ||
Entries.Add(new DocumentIndexEntry(name, value, Types.Text, options)); | ||
} | ||
|
||
public void Set(string name, IHtmlContent value, DocumentIndexOptions options) | ||
{ | ||
Entries.Add(new DocumentIndexEntry(name, value, Types.Text, options)); | ||
} | ||
|
||
public void Set(string name, DateTimeOffset? value, DocumentIndexOptions options) | ||
{ | ||
Entries.Add(new DocumentIndexEntry(name, value, Types.DateTime, options)); | ||
} | ||
|
||
public void Set(string name, int? value, DocumentIndexOptions options) | ||
{ | ||
Entries.Add(new DocumentIndexEntry(name, value, Types.Integer, options)); | ||
} | ||
|
||
public void Set(string name, bool? value, DocumentIndexOptions options) | ||
{ | ||
Entries.Add(new DocumentIndexEntry(name, value, Types.Boolean, options)); | ||
} | ||
public string ContentItemId { get; } | ||
|
||
public void Set(string name, double? value, DocumentIndexOptions options) | ||
{ | ||
Entries.Add(new DocumentIndexEntry(name, value, Types.Number, options)); | ||
} | ||
|
||
public void Set(string name, decimal? value, DocumentIndexOptions options) | ||
{ | ||
Entries.Add(new DocumentIndexEntry(name, value, Types.Number, options)); | ||
} | ||
|
||
public void Set(string name, GeoPoint value, DocumentIndexOptions options) | ||
{ | ||
Entries.Add(new DocumentIndexEntry(name, value, Types.GeoPoint, options)); | ||
} | ||
|
||
public string ContentItemId { get; } = contentItemId; | ||
|
||
public string ContentItemVersionId { get; } = contentItemVersionId; | ||
|
||
public enum Types | ||
{ | ||
Integer, | ||
Text, | ||
DateTime, | ||
Boolean, | ||
Number, | ||
GeoPoint | ||
} | ||
|
||
public class GeoPoint | ||
{ | ||
public decimal Longitude; | ||
public decimal Latitude; | ||
} | ||
public string ContentItemVersionId { get; } | ||
|
||
public class DocumentIndexEntry(string name, object value, Types type, DocumentIndexOptions options) | ||
public DocumentIndex(string contentItemId, string contentItemVersionId) | ||
{ | ||
public string Name { get; } = name; | ||
public object Value { get; } = value; | ||
public Types Type { get; } = type; | ||
public DocumentIndexOptions Options { get; } = options; | ||
ContentItemId = contentItemId; | ||
ContentItemVersionId = contentItemVersionId; | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
src/OrchardCore/OrchardCore.Indexing.Abstractions/DocumentIndexBase.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
using Microsoft.AspNetCore.Html; | ||
|
||
namespace OrchardCore.Indexing; | ||
|
||
public class DocumentIndexBase | ||
{ | ||
public List<DocumentIndexEntry> Entries { get; } = []; | ||
|
||
public void Set(string name, string value, DocumentIndexOptions options) | ||
{ | ||
Entries.Add(new DocumentIndexEntry(name, value, Types.Text, options)); | ||
} | ||
|
||
public void Set(string name, IHtmlContent value, DocumentIndexOptions options) | ||
{ | ||
Entries.Add(new DocumentIndexEntry(name, value, Types.Text, options)); | ||
} | ||
|
||
public void Set(string name, DateTimeOffset? value, DocumentIndexOptions options) | ||
{ | ||
Entries.Add(new DocumentIndexEntry(name, value, Types.DateTime, options)); | ||
} | ||
|
||
public void Set(string name, int? value, DocumentIndexOptions options) | ||
{ | ||
Entries.Add(new DocumentIndexEntry(name, value, Types.Integer, options)); | ||
} | ||
|
||
public void Set(string name, bool? value, DocumentIndexOptions options) | ||
{ | ||
Entries.Add(new DocumentIndexEntry(name, value, Types.Boolean, options)); | ||
} | ||
|
||
public void Set(string name, double? value, DocumentIndexOptions options) | ||
{ | ||
Entries.Add(new DocumentIndexEntry(name, value, Types.Number, options)); | ||
} | ||
|
||
public void Set(string name, decimal? value, DocumentIndexOptions options) | ||
{ | ||
Entries.Add(new DocumentIndexEntry(name, value, Types.Number, options)); | ||
} | ||
|
||
public void Set(string name, GeoPoint value, DocumentIndexOptions options) | ||
{ | ||
Entries.Add(new DocumentIndexEntry(name, value, Types.GeoPoint, options)); | ||
} | ||
|
||
public enum Types | ||
{ | ||
Integer, | ||
Text, | ||
DateTime, | ||
Boolean, | ||
Number, | ||
GeoPoint, | ||
} | ||
|
||
public class GeoPoint | ||
{ | ||
public decimal Longitude; | ||
public decimal Latitude; | ||
} | ||
|
||
public class DocumentIndexEntry(string name, object value, Types type, DocumentIndexOptions options) | ||
{ | ||
public string Name { get; } = name; | ||
public object Value { get; } = value; | ||
public Types Type { get; } = type; | ||
public DocumentIndexOptions Options { get; } = options; | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
src/OrchardCore/OrchardCore.Search.AzureAI.Core/Models/AzureAISearchIndexMap.cs
This file contains 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
2 changes: 1 addition & 1 deletion
2
src/OrchardCore/OrchardCore.Search.AzureAI.Core/Models/SearchIndexDefinition.cs
This file contains 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
This file contains 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
This file contains 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
This file contains 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