Replies: 1 comment 2 replies
-
🤖 Hello again, @ggnicolau! I hope your coding journey has been smooth since we last interacted. Let's dive into this new challenge you've brought. To filter by the "received_date" metadata in a specific time window using Qdrant, you can use the Here is an example of how you can filter by a specific time window: from datetime import datetime, timedelta
# Define the time window
start_date = datetime.now() - timedelta(days=7) # One week ago
end_date = datetime.now() # Now
# Convert dates to timestamps
start_timestamp = int(start_date.timestamp())
end_timestamp = int(end_date.timestamp())
# Define the filter
date_filter = {
"received_date": {
"range": {
"from": start_timestamp,
"to": end_timestamp
}
}
}
# Use the filter in a search method
documents = qdrant.similarity_search_with_score(
query="your query",
k=10,
filter=date_filter
) In this example, Please note that this example assumes that the "received_date" metadata field exists and is of type date (stored as a timestamp). If the field does not exist or is of a different type, you will need to adjust the filter accordingly. For more information, you can refer to the LangChain Qdrant vector store implementation and the Qdrant documentation. Sources
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot. |
Beta Was this translation helpful? Give feedback.
-
Dear colleagues,
How can I use a filter by the metadata I've sent to Qdrant in this piece of code?
My metadata at Qdrant currently is something like:
First I want to try to filter by "received_date", in a time window (after something and before something).
Beta Was this translation helpful? Give feedback.
All reactions