-
Notifications
You must be signed in to change notification settings - Fork 150
Python: Added FT.CREATE command
#2413
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
Closed
Closed
Changes from 4 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
e63c5bf
Python - Added [FT.CREATE] command
prateek-kumar-improving 52929c2
Updated changelog.md
prateek-kumar-improving fbcd225
Fix JSON path in test
prateek-kumar-improving df4ce5f
Fix JSON path in JSON field tests
prateek-kumar-improving da52ed8
Python [FT.CREATE] review comments fixed
prateek-kumar-improving 0bcade3
Python [FT.CREATE] cluster client added
prateek-kumar-improving 5ff9872
Merge branch 'main' into python-ft-create-command
prateek-kumar-improving f7943e7
Python [FT.CREATE] file headers added
prateek-kumar-improving 6a9bd26
CHANGELOG.md updated
prateek-kumar-improving 82cd11f
Python [FT.CREATE] exports added
prateek-kumar-improving fa49daa
Python [FT.CREATE] name field made TEncodable
prateek-kumar-improving 648bcc3
Python [FT.CREATE] update name documentation to TEncodable
prateek-kumar-improving 25d21df
Python [FT.CREATE] update return type of toArgs to TEncodable
prateek-kumar-improving d2edc58
Merge branch 'main' into python-ft-create-command
prateek-kumar-improving d61ed73
Added inflightRequestsLimit client config to java (#2408)
GilboaAWS 82ea745
Merge branch 'main' into python-ft-create-command
prateek-kumar-improving a136d1b
Python [FT.CREATE] added exports to init file
prateek-kumar-improving 65778d1
Python [FT.CREATE] documentation updated for constructor
prateek-kumar-improving d9475f8
Python [FT.CREATE] added space in constructor documentation
prateek-kumar-improving c3476b6
Python [FT.CREATE] update vector classes get function name to toArgs
prateek-kumar-improving a2a91af
Merge branch 'release-1.2' into python-ft-create-command
prateek-kumar-improving 3af6719
Python [FT.CREATE] fixed documentation
prateek-kumar-improving 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
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,58 @@ | ||
| # Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0 | ||
| """ | ||
| module for `vector search` commands. | ||
| """ | ||
|
|
||
| from typing import List, Optional, cast | ||
|
|
||
| from glide.async_commands.server_modules.ft_constants import ( | ||
| CommandNames, | ||
| FtCreateKeywords, | ||
| ) | ||
| from glide.async_commands.server_modules.ft_options.ft_create_options import ( | ||
| Field, | ||
| FtCreateOptions, | ||
| ) | ||
| from glide.constants import TOK, TEncodable | ||
| from glide.glide_client import TGlideClient | ||
|
|
||
|
|
||
| async def create( | ||
|
Yury-Fridlyand marked this conversation as resolved.
|
||
| client: TGlideClient, | ||
| indexName: TEncodable, | ||
| schema: List[Field] = [], | ||
|
Yury-Fridlyand marked this conversation as resolved.
Outdated
|
||
| options: Optional[FtCreateOptions] = None, | ||
| ) -> TOK: | ||
| """ | ||
| Creates an index and initiates a backfill of that index. | ||
|
|
||
| See https://valkey.io/commands/ft.create/ for more details. | ||
|
Yury-Fridlyand marked this conversation as resolved.
Outdated
|
||
|
|
||
| Args: | ||
|
Yury-Fridlyand marked this conversation as resolved.
Outdated
|
||
| client (TGlideClient): The client to execute the command. | ||
| indexName (TEncodable): The index name for the index to be created | ||
| schema (List[Field]): The fields of the index schema, specifying the fields and their types. | ||
| options (Optional[FtCreateOptions]): Optional arguments for the [FT.CREATE] command. | ||
|
|
||
| Returns: | ||
| If the index is successfully created, returns OK. | ||
|
prateek-kumar-improving marked this conversation as resolved.
Outdated
|
||
|
|
||
| Examples: | ||
| >>> from glide.async_commands.server_modules import ft | ||
| >>> schema: List[Field] = [] | ||
| >>> field: TextField = TextField("title") | ||
| >>> schema.append(field) | ||
| >>> prefixes: List[str] = [] | ||
| >>> prefixes.append("blog:post:") | ||
| >>> index = "idx" | ||
| >>> result = await ft.create(glide_client, index, schema, FtCreateOptions(DataType.HASH, prefixes)) | ||
| 'OK' # Indicates successful creation of index named 'idx' | ||
|
Yury-Fridlyand marked this conversation as resolved.
Outdated
|
||
| """ | ||
| args: List[TEncodable] = [CommandNames.FT_CREATE, indexName] | ||
| if options: | ||
| args.extend(options.getCreateOptions()) | ||
|
Yury-Fridlyand marked this conversation as resolved.
Outdated
|
||
| if schema and len(schema) > 0: | ||
| args.append(FtCreateKeywords.SCHEMA) | ||
| for field in schema: | ||
| args.extend(field.getFieldArgs()) | ||
|
Yury-Fridlyand marked this conversation as resolved.
Outdated
|
||
| return cast(TOK, await client.custom_command(args)) | ||
29 changes: 29 additions & 0 deletions
29
python/python/glide/async_commands/server_modules/ft_constants.py
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,29 @@ | ||
| class CommandNames: | ||
| """ | ||
| Command name constants for vector search. | ||
| """ | ||
|
|
||
| FT_CREATE = "FT.CREATE" | ||
|
|
||
|
|
||
| class FtCreateKeywords: | ||
| """ | ||
| Keywords used in the [FT.CREATE] command statment. | ||
| """ | ||
|
|
||
| SCHEMA = "SCHEMA" | ||
| AS = "AS" | ||
| SORTABLE = "SORTABLE" | ||
| UNF = "UNF" | ||
| NO_INDEX = "NOINDEX" | ||
| ON = "ON" | ||
| PREFIX = "PREFIX" | ||
| SEPARATOR = "SEPARATOR" | ||
| CASESENSITIVE = "CASESENSITIVE" | ||
| DIM = "DIM" | ||
| DISTANCE_METRIC = "DISTANCE_METRIC" | ||
| TYPE = "TYPE" | ||
| INITIAL_CAP = "INITIAL_CAP" | ||
| M = "M" | ||
| EF_CONSTRUCTION = "EF_CONSTRUCTION" | ||
| EF_RUNTIME = "EF_RUNTIME" |
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.