I am working with Qdrant, a vector database, and I need to filter data based on datetime values using the Python SDK. However, I encountered an issue where Qdrant expects numerical input but receives datetime, leading to parsing errors.
Here is a simplified version of my code:
from datetime import datetime
from qdrant_client import QdrantClient
# Qdrant client setup
qdrant_client = QdrantClient(...)
# Datetime string to filter
datetime_obj = 2024-02-22 10:04:28.658690
# Filter query
query = {
"bool": {
"filter": {
"range": {
"timestamp": {"gte": datetime_obj }
}
}
}
}
# Execute query
result = qdrant_client.query(query)
The error message I receive is:
Input should be a valid number:
[type=float_type, input_value=datetime.datetime(2024, 2, 22, 10, 5, 46, 966824), input_type=datetime]
Qdrant will support datetime in the upcoming v1.8.0 release.
You can try converting the value to integer timestamps/epochs and use range-based filtering. https://qdrant.tech/documentation/concepts/filtering/#range