-
Notifications
You must be signed in to change notification settings - Fork 524
[Internal] ContainerProperties: Adds Full Text Search and Indexing Policy #4837
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
Merged
kirankumarkolli
merged 11 commits into
master
from
users/kundadebdatta/4820_add_full_text_search_indexing_policy
Oct 23, 2024
Merged
Changes from 10 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
983c0d7
Initial code changes to introduce full text search.
kundadebdatta 8100f5f
Code changes to add full text index tests.
kundadebdatta 20a47f1
Code changes make the full text search internal only for now.
kundadebdatta b48cc48
Ignoring the FTS emulator tests.
kundadebdatta e7be9bf
Code changes to address review comments. Made the FTS public for prev…
kundadebdatta f5f5fa8
Code changes to update verbaige.
kundadebdatta 5377b39
Code changes to fix test failures.
kundadebdatta 7e84283
Code changes to fix build failure.
kundadebdatta 4ff06a1
Merge branch 'master' into users/kundadebdatta/4820_add_full_text_sea…
kundadebdatta 52a21b9
Code changes to address review comments.
kundadebdatta 467de77
Code changes to update preview contract
kundadebdatta 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 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
65 changes: 65 additions & 0 deletions
65
Microsoft.Azure.Cosmos/src/Fluent/Settings/FullTextIndexDefinition.cs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| //------------------------------------------------------------ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| //------------------------------------------------------------ | ||
|
|
||
| namespace Microsoft.Azure.Cosmos.Fluent | ||
| { | ||
| using System; | ||
|
|
||
| /// <summary> | ||
| /// Full text index fluent definition. | ||
| /// </summary> | ||
| /// <seealso cref="FullTextIndexPath"/> | ||
| #if PREVIEW | ||
| public | ||
| #else | ||
| internal | ||
| #endif | ||
| class FullTextIndexDefinition<T> | ||
| { | ||
| private readonly FullTextIndexPath fullTextIndexPath = new (); | ||
| private readonly T parent; | ||
| private readonly Action<FullTextIndexPath> attachCallback; | ||
|
|
||
| /// <summary> | ||
| /// Initializes a new instance of the <see cref="FullTextIndexDefinition{T}"/> class. | ||
| /// </summary> | ||
| /// <param name="parent">The original instance of <see cref="ContainerBuilder"/>.</param> | ||
| /// <param name="attachCallback">A callback delegate to be used at a later point of time.</param> | ||
| public FullTextIndexDefinition( | ||
| T parent, | ||
| Action<FullTextIndexPath> attachCallback) | ||
| { | ||
| this.parent = parent; | ||
| this.attachCallback = attachCallback; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Add a path to the current <see cref="FullTextIndexPath"/> definition. | ||
| /// </summary> | ||
| /// <param name="path">Property path for the current definition. Example: /property</param> | ||
| /// <returns>An instance of the current <see cref="FullTextIndexDefinition{T}"/>.</returns> | ||
| public FullTextIndexDefinition<T> Path( | ||
| string path) | ||
| { | ||
| if (string.IsNullOrEmpty(path)) | ||
| { | ||
| throw new ArgumentNullException(nameof(path)); | ||
| } | ||
|
|
||
| this.fullTextIndexPath.Path = path; | ||
|
|
||
| return this; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Applies the current definition to the parent. | ||
| /// </summary> | ||
| /// <returns>An instance of the parent.</returns> | ||
| public T Attach() | ||
| { | ||
| this.attachCallback(this.fullTextIndexPath); | ||
| return this.parent; | ||
| } | ||
| } | ||
| } | ||
60 changes: 60 additions & 0 deletions
60
Microsoft.Azure.Cosmos/src/Fluent/Settings/FullTextPolicyDefinition.cs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| //------------------------------------------------------------ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| //------------------------------------------------------------ | ||
|
|
||
| namespace Microsoft.Azure.Cosmos.Fluent | ||
| { | ||
| using System; | ||
| using System.Collections.ObjectModel; | ||
|
|
||
| /// <summary> | ||
| /// <see cref="FullTextPolicyDefinition"/> fluent definition. | ||
| /// </summary> | ||
| #if PREVIEW | ||
| public | ||
| #else | ||
| internal | ||
| #endif | ||
| class FullTextPolicyDefinition | ||
| { | ||
| private readonly ContainerBuilder parent; | ||
| private readonly Action<FullTextPolicy> attachCallback; | ||
| private readonly string defaultLanguage; | ||
| private readonly Collection<FullTextPath> fullTextPaths; | ||
|
|
||
| /// <summary> | ||
| /// Initializes a new instance of the <see cref="FullTextPolicyDefinition"/> class. | ||
| /// </summary> | ||
| /// <param name="parent">The original instance of <see cref="ContainerBuilder"/>.</param> | ||
| /// <param name="defaultLanguage">A string indicating the default language for the inexing policy definition.</param> | ||
| /// <param name="fullTextPaths">List of fullTextPaths to include in the policy definition.</param> | ||
| /// <param name="attachCallback">A callback delegate to be used at a later point of time.</param> | ||
| public FullTextPolicyDefinition( | ||
| ContainerBuilder parent, | ||
| string defaultLanguage, | ||
| Collection<FullTextPath> fullTextPaths, | ||
| Action<FullTextPolicy> attachCallback) | ||
| { | ||
| this.parent = parent ?? throw new ArgumentNullException(nameof(parent)); | ||
| this.attachCallback = attachCallback ?? throw new ArgumentNullException(nameof(attachCallback)); | ||
| this.fullTextPaths = fullTextPaths; | ||
| this.defaultLanguage = defaultLanguage; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Applies the current definition to the parent. | ||
| /// </summary> | ||
| /// <returns>An instance of the parent.</returns> | ||
| public ContainerBuilder Attach() | ||
| { | ||
| FullTextPolicy fullTextPolicy = new () | ||
| { | ||
| DefaultLanguage = this.defaultLanguage, | ||
| FullTextPaths = this.fullTextPaths | ||
| }; | ||
|
|
||
| this.attachCallback(fullTextPolicy); | ||
| return this.parent; | ||
| } | ||
| } | ||
| } |
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
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
61 changes: 61 additions & 0 deletions
61
Microsoft.Azure.Cosmos/src/Resource/Settings/FullTextIndexPath.cs
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
| 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.Linq; | ||
|
|
||
| /// <summary> | ||
| /// DOM for a full text index path. A full text index path is used in a full text index. | ||
| /// </summary> | ||
| /// <example> | ||
| /// <![CDATA[ | ||
| /// "indexingPolicy": { | ||
| /// "includedPaths": [ | ||
| /// { | ||
| /// "path": "/*" | ||
| /// } | ||
| /// ], | ||
| /// "excludedPaths": [ | ||
| /// { | ||
| /// "path": "/embeddings/vector/*" | ||
| /// } | ||
| /// ], | ||
| /// "fullTextIndexes": [ | ||
| /// { | ||
| /// "path": "/v1/path1", | ||
| /// }, | ||
| /// { | ||
| /// "path": "/v2/path2/text2", | ||
| /// }, | ||
| /// { | ||
| /// "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; } | ||
| } | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.