Skip to content
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

options for create_composite_index is incomplete #74

Open
jacobgumpert opened this issue Jul 24, 2024 · 0 comments
Open

options for create_composite_index is incomplete #74

jacobgumpert opened this issue Jul 24, 2024 · 0 comments

Comments

@jacobgumpert
Copy link

When creating composite_index using firedantic it only supports the order option.
That makes not possible to create index for eg array_contains.

The documentation has three options for creating composite index,
order, array_config, vector_config

see documentation

Maybe expand the second field value to have more values, and toggle the create on the value?

Or make it similar to the filter_ in .find where a single value is assumed to be order but if you set it as dict you can set it how it should be used?

more options

If you add CONTAINS as an option you could toggle the create on that.

eg

OrderDirection = Union[Literal["ASCENDING"], Literal["DESCENDING"], Literal["CONTAINS", Literal["ARRAY_CONFIG_UNSPECIFIED"]]

IndexField = NamedTuple("IndexField", [("name", str), ("order", OrderDirection)])

and set the field_mode based on the value

field_modes = {
    "CONTAINS": "array_config",
    "ARRAY_CONFIG_UNSPECIFIED": "array_config",
    "ASCENDING": "order",
    "DESCENDING": "order",

}
request = CreateIndexRequest(
    {
        "parent": path,
        "index": Index(
            {
                "query_scope": index.query_scope,
                "fields": [
                    {"field_path": field[0], field_modes[field[1]]: field[1]}
                    for field in list(index.fields)
                ],
            }
        ),
    }
)

However, this will not work for the VectorConfig options since that one has two values as input. But I'm not sure, I have never created vector based indexes.

support both str and dict

eg

IndexOptions = Literal["order", "array_config", "vector_config"]
OrderDirection = Union[Literal["ASCENDING"], Literal["DESCENDING"]]

IndexField = NamedTuple("IndexField", [("name", str), ("order", OrderDirection | dict[IndexOptions, any])])

suboptimal since the name is of the field is order

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant