-
Notifications
You must be signed in to change notification settings - Fork 497
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add FullTextIndexes to IndexingPolicy and add FullTextPolicy to ContainerProperties #4816
Draft
changanhan
wants to merge
1
commit into
master
Choose a base branch
from
users/changanhan/fulltextpolicy
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
61 changes: 61 additions & 0 deletions
61
Microsoft.Azure.Cosmos/src/Resource/Settings/FullTextIndexPath.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,61 @@ | ||
//------------------------------------------------------------ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
//------------------------------------------------------------ | ||
namespace Microsoft.Azure.Cosmos | ||
{ | ||
using System.Collections.Generic; | ||
using Microsoft.Azure.Documents; | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Converters; | ||
using Newtonsoft.Json.Linq; | ||
|
||
/// <summary> | ||
/// DOM for a vector index path. A vector index path is used in a vector index. | ||
/// </summary> | ||
/// <example> | ||
/// <![CDATA[ | ||
/// "indexingPolicy": { | ||
/// "includedPaths": [ | ||
/// { | ||
/// "path": "/*" | ||
/// } | ||
/// ], | ||
/// "excludedPaths": [ | ||
/// { | ||
/// } | ||
/// ], | ||
/// "fullTextIndexes": [ | ||
/// { | ||
/// "path": "/v1", | ||
/// }, | ||
/// { | ||
/// "path": "/v2", | ||
/// }, | ||
/// { | ||
/// "path": "/v3", | ||
/// } | ||
/// ] | ||
/// } | ||
/// ]]> | ||
/// </example> | ||
#if PREVIEW | ||
public | ||
#else | ||
internal | ||
#endif | ||
sealed class FullTextIndexPath | ||
{ | ||
/// <summary> | ||
/// Gets or sets the full path in a document used for full text indexing. | ||
/// </summary> | ||
[JsonProperty(PropertyName = Constants.Properties.Path)] | ||
public string Path { get; set; } | ||
|
||
/// <summary> | ||
/// This contains additional values for scenarios where the SDK is not aware of new fields. | ||
/// This ensures that if resource is read and updated none of the fields will be lost in the process. | ||
/// </summary> | ||
[JsonExtensionData] | ||
internal IDictionary<string, JToken> AdditionalProperties { get; private set; } | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
Microsoft.Azure.Cosmos/src/Resource/Settings/FullTextPath.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,70 @@ | ||
//------------------------------------------------------------ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
//------------------------------------------------------------ | ||
|
||
namespace Microsoft.Azure.Cosmos | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using Microsoft.Azure.Documents; | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Converters; | ||
using Newtonsoft.Json.Linq; | ||
|
||
/// <summary> | ||
/// Represents the embedding settings for the vector index. | ||
/// </summary> | ||
#if PREVIEW | ||
public | ||
#else | ||
internal | ||
#endif | ||
class FullTextPath : IEquatable<FullTextPath> | ||
{ | ||
/// <summary> | ||
/// Gets or sets a string containing the path of the full text index. | ||
/// </summary> | ||
[JsonProperty(PropertyName = Constants.Properties.Path)] | ||
public string Path { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets a string containing the language of the full text path. | ||
/// </summary> | ||
[JsonProperty(PropertyName = "language")] | ||
public string Language { get; set; } | ||
|
||
/// <summary> | ||
/// This contains additional values for scenarios where the SDK is not aware of new fields. | ||
/// This ensures that if resource is read and updated none of the fields will be lost in the process. | ||
/// </summary> | ||
[JsonExtensionData] | ||
internal IDictionary<string, JToken> AdditionalProperties { get; private set; } | ||
|
||
/// <summary> | ||
/// Ensures that the paths specified in the full text policy are valid. | ||
/// </summary> | ||
public void ValidateFullTextPath() | ||
{ | ||
if (string.IsNullOrEmpty(this.Path)) | ||
{ | ||
throw new ArgumentException("Argument {0} can't be null or empty.", nameof(this.Path)); | ||
} | ||
|
||
if (string.IsNullOrEmpty(this.Language)) | ||
{ | ||
throw new ArgumentException("Argument {0} can't be null or empty.", nameof(this.Language)); | ||
} | ||
|
||
if (this.Path[0] != '/') | ||
{ | ||
throw new ArgumentException("The argument {0} is not a valid path.", this.Path); | ||
} | ||
} | ||
|
||
/// <inheritdoc/> | ||
public bool Equals(FullTextPath that) | ||
{ | ||
return this.Path.Equals(that.Path) && this.Language.Equals(that.Language); | ||
} | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
Microsoft.Azure.Cosmos/src/Resource/Settings/FullTextPolicy.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,70 @@ | ||
//------------------------------------------------------------ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
//------------------------------------------------------------ | ||
namespace Microsoft.Azure.Cosmos | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Linq; | ||
|
||
/// <summary> | ||
/// Represents the full text policy configuration for specifying the full text paths on documents in the collection in the Azure Cosmos DB service. | ||
/// </summary> | ||
/// <seealso cref="ContainerProperties"/> | ||
#if PREVIEW | ||
public | ||
#else | ||
internal | ||
#endif | ||
sealed class FullTextPolicy | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="FullTextPolicy"/> class. | ||
/// </summary> | ||
/// <param name="defaultLanguage">String of the default language of the container.</param> | ||
/// <param name="fullTextPaths">List of full text paths to include in the policy definition.</param> | ||
public FullTextPolicy(string defaultLanguage, Collection<FullTextPath> fullTextPaths) | ||
{ | ||
if (fullTextPaths != null) | ||
{ | ||
FullTextPolicy.ValidateFullTextPaths(fullTextPaths); | ||
} | ||
|
||
this.DefaultLanguage = defaultLanguage; | ||
this.FullTextPaths = fullTextPaths; | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets a string containing the default language of the container. | ||
/// </summary> | ||
[JsonProperty(PropertyName = "defaultLanguage", NullValueHandling=NullValueHandling.Ignore)] | ||
public string DefaultLanguage { get; set; } | ||
|
||
/// <summary> | ||
/// Gets a collection of <see cref="FullTextPath"/> that contains the full text paths of documents in collection in the Azure Cosmos DB service. | ||
/// </summary> | ||
[JsonProperty(PropertyName = "fullTextPaths", NullValueHandling=NullValueHandling.Ignore)] | ||
public readonly Collection<FullTextPath> FullTextPaths; | ||
|
||
/// <summary> | ||
/// This contains additional values for scenarios where the SDK is not aware of new fields. | ||
/// This ensures that if resource is read and updated none of the fields will be lost in the process. | ||
/// </summary> | ||
[JsonExtensionData] | ||
internal IDictionary<string, JToken> AdditionalProperties { get; private set; } | ||
|
||
/// <summary> | ||
/// Ensures that the specified full text paths in the policy are valid. | ||
/// </summary> | ||
private static void ValidateFullTextPaths( | ||
IEnumerable<FullTextPath> fullTextPaths) | ||
{ | ||
foreach (FullTextPath item in fullTextPaths) | ||
{ | ||
item.ValidateFullTextPath(); | ||
} | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -147,6 +147,33 @@ public IndexingPolicy() | |
#endif | ||
Collection<VectorIndexPath> VectorIndexes { get; set; } = new Collection<VectorIndexPath>(); | ||
|
||
/// <summary> | ||
/// Gets the full text indexes | ||
/// </summary> | ||
/// <example> | ||
/// <![CDATA[ | ||
/// "fullTextIndexes": [ | ||
/// { | ||
/// "path": "/v1", | ||
/// }, | ||
/// { | ||
/// "path": "/v2", | ||
/// }, | ||
/// { | ||
/// "path": "/v3", | ||
/// } | ||
/// ] | ||
/// ]]> | ||
/// </example> | ||
[JsonProperty(PropertyName = "fullTextIndexes", NullValueHandling = NullValueHandling.Ignore)] | ||
#if PREVIEW | ||
|
||
public | ||
#else | ||
internal | ||
#endif | ||
Collection<FullTextIndexPath> FullTextIndexes { get; set; } = new Collection<FullTextIndexPath>(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tests? |
||
|
||
/// <summary> | ||
/// This contains additional values for scenarios where the SDK is not aware of new fields. | ||
/// This ensures that if resource is read and updated none of the fields will be lost in the process. | ||
|
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it a override for the container language?