How to Fix Wrong payload type: expected integer, got string (Qdrant)
Quick Answer: This error occurs when you attempt to insert or filter a payload field in Qdrant with a string value, but the field was previously defined or indexed as an integer. To fix it, ensure your input data matches the expected schema type or update the payload index configuration to accept the correct data type.
What Causes This Error
- Inserting a string value (e.g., '123') into a payload field that expects an integer (e.g., 123).
- Filtering points using a string representation of a number instead of a raw integer in the query condition.
- Schema drift or inconsistent data types across different batches of inserted vectors.
- Implicit type coercion in client applications passing form data or JSON parameters as strings.
Step-by-Step Fixes
Fix 1: Fix 1: Cast Data to Integer Before Insertion
Identify the payload field causing the error from your application logs or Qdrant response.,Modify your ingestion script or data pipeline to explicitly cast the value to an integer (e.g., using `int()` in Python or `parseInt()` in JavaScript/TypeScript).,Re-run the data insertion request with the correctly typed payload.
Fix 2: Fix 2: Correct Query Filter Types
Check your search or retrieve query filters where the payload field is evaluated.,Ensure that match conditions use integer types instead of string types (e.g., `MatchValue(value=42)` instead of `MatchValue(value='42')`).,Execute the updated query against the Qdrant cluster.
Fix 3: Fix 3: Re-index or Update Payload Schema
If the field type needs to be a string permanently, delete the existing payload index for that field using the Qdrant API or client library.,Create a new payload index matching the desired data type (or leave it unindexed if indexing is not required).,Re-ingest the affected points with the correct data types.
Advanced Fixes
Advanced Fix 1: Advanced: Recreating the Collection with Strict Schema Validation
Export existing valid points and payloads from the collection using snapshot or scroll APIs.,Delete the misconfigured collection using the client or REST API.,Recreate the collection and explicitly define payload schemas or payload index types beforehand to prevent type mismatch regressions.
FAQs
Q: Does Qdrant automatically coerce data types during insertion?
A: No, Qdrant enforces strict payload typing based on the payload structure and existing indexes to ensure query performance and data integrity.
Q: Can I change a payload field type without re-creating the index?
A: You must drop the existing payload index for that specific field and recreate it with the correct type configuration, or clean up the mismatched payloads.