-
Notifications
You must be signed in to change notification settings - Fork 151
Description
I might be misunderstanding something here, but I’m trying to use list_indexes
to get a list of current indexes, so that I can programmatically create any indexes that are missing, but it doesn’t seem possible to do this in a robust way since compound keys are returned as a Map, which doesn’t keep track of the order of the keys.
For example, I get this:
%{"key" => %{"Created" => -1, "ReportType" => -1}, "name" => "ReportType_-1_Created_-1", "v" => 2}
... for an index that was created with the following command:
%{
createIndexes: "coll",
indexes: [
%{
key: [{"ReportType", -1}, {"Created", -1}],
name: "ReportType_-1_Created_-1"
}
]
}
So this compound key was created with ReportType
first, then Created
, which matters greatly in terms of performance for our use case. But there’s no way to determine the actual ordering in the compound index based on the map I get back from list_indexes
.
It seems my only option at the moment is to use the name
field to deduce which order was used, but that requires a certain fixed naming scheme to work, which I unfortunately can’t rely on.
Is my assessment correct here, and if so, would it be possible to fix this somehow? It might not be feasible to change the format of the data returned from list_indexes
(for compatibility reasons), but perhaps an additional function could be added that returns a keyword list instead?