-
Notifications
You must be signed in to change notification settings - Fork 22
Error creating item Invalid index name [items_Randy], must be lowercase
#334
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
Comments
@rhysrevans3 Hi. Can you help out here? |
@pedro-cf sorry just so I'm clear. Previously when you tried to create an index name
And now you still can't create the index but also don't get an exception? |
Greetings @rhysrevans3 , In the past I created a collection with the id But after some time with a couple of environment restarts for both the API and elasticsearch, I was unable to create any more items for that collection due to always getting the error: {
"code": "BadRequestError",
"description": "BadRequestError(400, 'invalid_index_name_exception', 'Invalid index name [items_Randy], must be lowercase')"
} Eventually I was forced to migrate all items in the collection to a new collection in order to work around the issue. I assume this issue is related? #328 I believe this issue occurred after PR #329 was merged and I updated the SFEOS API to v3.2.3 |
#329 should allow You can generate the new syntaxes with these functions from the elasticsearch or opensearch database logic from stac_fastapi.elasticsearch.database_logic import index_alias_by_collection_id, index_by_collection_id
index_alias_by_collection_id(collection_id)
index_by_collection_id(collection_id) This might be having unexpected effects on existing indices? And causing the error you're seeing. Am I right in saying you now have a collection is now called You might need to migrate your indexes again. There are some notes on reindexing in the readme #reindexing But these are the steps I'd take (the script in the reindex is different) Create the new collection record: curl -X "POST" "{STAC API}/collections" \
-H 'Content-Type: application/json' \
-d $'{
"id": "{new collection with uppercase}"
}' you might also want to copy over any meta data from the existing collection. You can then reindex the old collection items into the new index. curl -X "POST" "{ELASTICSEARCH SERVER}:9200/_reindex" \
-H 'Content-Type: application/json' \
-d $'{
"source": {
"index": "{old index}"
},
"dest": {
"index": "{new index}-000001"
},
"script": {
"source": "ctx._id = ctx._id.split('|')[0] + '|{new collection with uppercase}';ctx._source.collection = {new collection with uppercase}",
}
}' Create the new alias curl -X "POST" "{ELASTICSEARCH SERVER}:9200/_aliases" \
-h 'Content-Type: application/json' \
-d $'{
"actions": [
{
"add": {
"index": "{new index}-000001",
"alias": "{new alias}"
}
}
]
}' If you're happy with the new collection you can then remove the old one. For your case moving from
|
Thank you @rhysrevans3 for the help! Since I migrated the items to a new lowercase collection and deleted the old collection I'm not sure I will be able to re-create this issue. It would be cool to alert of "(schema) migrations" / re-indexing if needed in new releases @jonhealy1 |
Describe the bug
In a previously working environment, when trying to create a STAC item in a collection with id
Randy
, I get the following error:This was previously working but now fails with an invalid index name exception.
To Reproduce
I am unable to reproduce this in a fresh environment.
Expected behavior
The STAC item should be successfully created, as it was before. If uppercase names are now restricted, the API should automatically convert them to lowercase or provide a clearer validation error earlier in the process.
Additional context
The text was updated successfully, but these errors were encountered: