Troubleshooting Typesense Document Update Error
TLDR Mehdi had an issue with updating Typesense documents which returned a '404 Not Found' error. Kishore Nallan after several debugging steps, discovered Mehdi was using an outdated Typesense version. The issue was resolved after upgrading Typesense.


Jul 28, 2021 (26 months ago)
Mehdi
09:25 AMI'm working on changes streams, which is reflecting data changes in MongoDB documents to Typesense collections
This is my code:
print(_id)
document = insert_change['updateDescription']['updatedFields']
print(document)
print(CLIENT.collections[TYPESENSE_COLLECTION].documents[_id].retrieve())
r = CLIENT.collections[TYPESENSE_COLLECTION].documents[_id].update(document)
print(r)
This is the response
5fae9573f56f4d5f91b8c02d
{'name': 'Le Zii'}
{'_cls': 'Model', 'address': '', 'admin_uuid': {'$uuid': 'f25b39ef25ba11ebb464bc5ff4bfaa62'}, 'categories': ['Fast Food et Pizzerias'], 'city': 'Texas', 'coordinates': {'coordinates': [30.1769166, 40.8368248], 'type': 'Point'}, 'country': 'France', 'created_at': '2020-11-13 14:17:15.782000', 'created_by_uuid': {'$uuid': 'f25b39ef25ba11ebb464bc5ff4bfaa62'}, 'cuisines': [], 'description': 'Best burger in town :)', 'email': '', 'facebook_url': '', 'gallery': [], 'google_maps_url': '', 'has_ordering_service': False, 'has_qr_code': False, 'hours': {'Dimanche': ['0'], 'Jeudi': ['12:00', '23:00'], 'Lundi': ['12:00', '23:00'], 'Mardi': ['12:00', '23:00'], 'Mercredi': ['12:00', '23:00'], 'Samedi': ['12:00', '23:00'], 'Vendredi': ['12:00', '23:00']}, 'id': '5fae9573f56f4d5f91b8c02d', 'instagram_url': '', 'is_activated_by_admin': True, 'is_public': False, 'logo': '', 'menu_items': [], 'more_services': ['Livraison', 'Tickets resto'], 'name': 'Le Z', 'operator': {'_cls': 'BaseModel', '_ref': {'$id': {'$oid': '5fae9573f56f4d5f91b8c02e'}, '$ref': 'base_model'}}, 'price': 3, 'price_range': '$$$', 'private_phone_numbers': [], 'profile_picture': '', 'public_phone_numbers': ['0000'], 'rating': 0, 'reviews_count': 0, 'specialties': ['Burger'], 'state': 'Ariana', 'tagline': '', 'trends': 'Eat Out', 'updated_at': '2021-07-12 14:57:47.548000', 'uuid': 'f25b39ec-25ba-11eb-b464-bc5ff4bfaa62', 'website_url': '', 'zip_code': '0000'}
As you can see, the document exists in my Typesense collection, but when I call
update()
it returns [Errno 404] Not Found
. Any idea why this is happening?Kishore Nallan
09:43 AMprint(CLIENT.collections[TYPESENSE_COLLECTION].documents['5fae9573f56f4d5f91b8c02d'].retrieve())
# Try inserting an empty document to see what error message you are getting now
print(CLIENT.collections[TYPESENSE_COLLECTION].documents['5fae9573f56f4d5f91b8c02d'].update({}))
Kishore Nallan
09:44 AM5fae9573f56f4d5f91b8c02d
in the client code snippet above for both retrieve and update.Mehdi
09:46 AMIt's the same result
Kishore Nallan
09:47 AMMehdi
09:48 AMKishore Nallan
09:48 AMcurl " <COLLECTION>/documents/5fae9573f56f4d5f91b8c02d" -X PATCH \
-H "Content-Type: application/json" \
-H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \
-d '{}'
Kishore Nallan
09:49 AMMehdi
09:50 AM{ "message": "Not Found"}
Kishore Nallan
09:50 AMMehdi
09:53 AMMehdi
09:53 AMKishore Nallan
09:53 AM{"message": "Could not find a document with id: 1a"}
Kishore Nallan
09:54 AM{"message": "Not Found"}
Mehdi
09:59 AMretrieve()
it returns the document 😕Kishore Nallan
09:59 AMTYPESENSE_COLLECTION
variable name as well?Mehdi
10:02 AMMehdi
10:02 AMKishore Nallan
10:05 AMKishore Nallan
10:08 AMKishore Nallan
10:09 AM/debug
Jul 29, 2021 (26 months ago)
Mehdi
06:39 AMMehdi
06:40 AMMehdi
06:40 AMMehdi
06:42 AM/debug
returns {
"state": 1,
"version": "0.15.0"
}
Kishore Nallan
06:44 AMMehdi
06:56 AMNow updating documents works fine !
Mehdi
06:56 AMKishore Nallan
06:57 AMKishore Nallan
06:57 AMKishore Nallan
06:58 AM
Mehdi
07:23 AM
Typesense
Indexed 2764 threads (79% resolved)
Similar Threads
Troubleshooting 400 Error When Upgrading Typesense Firestore Extension
Orion experienced a `400` error after updating the Typesense Firestore extension, causing issues with cloud functions. They traced the issue back to a data type conflict in their Typesense collection schema after updating. With help from Jason and Kishore Nallan, they resolved the issue by recreating the collection.



Issue with Typesense Schema and Ruby Client
Mateo faces issues while creating a schema and using Ruby client for Typesense. Jason suggests using a new field instead of 'id' and provides assistance for Ruby client errors.
Handling Kinesis Stream Event Batching with Typesense
Dui had questions about how to handle Kinesis stream events with Typesense. Kishore Nallan suggested using upsert mode for creation/update and differentiating with logical deletion. After various discussions including identifying and resolving a bug, they finalized to introduce an `emplace` action in Typesense v0.23.


Fixing Corrupted Documents and Upgrading Typesense Cloud Version
gab had issues with corrupted documents in Typesense Cloud. Jason suggested upgrading to version 0.24.1.rc, which resolved the issue. They also discussed CORS domain management.


Typesense Server Bulk Import/Upsert Issue Resolved
Adam was confused about the discrepancy between the successful responses and the actual indexed data while working with a custom WP plugin integrating with Typesense. The issue was a bug related to fetching documents in the wrong order, not a Typesense problem.
