feat(indexing): add time filter

This commit is contained in:
arkohut 2024-07-31 00:41:29 +08:00
parent 83bd59ca80
commit d0cfd91f5a
2 changed files with 9 additions and 1 deletions

View File

@ -174,6 +174,8 @@ def search_entities(
folder_id: int = None,
limit: int = 48,
offset: int = 0,
start: int = None,
end: int = None,
) -> List[EntitySearchResult]:
try:
filter_by = []
@ -181,6 +183,8 @@ def search_entities(
filter_by.append(f"library_id:={library_id}")
if folder_id is not None:
filter_by.append(f"folder_id:={folder_id}")
if start is not None and end is not None:
filter_by.append(f"file_created_at:={start}..{end}")
filter_by_str = " && ".join(filter_by) if filter_by else ""
search_parameters = {

View File

@ -450,10 +450,14 @@ async def search_entities(
folder_id: int = None,
limit: Annotated[int, Query(ge=1, le=200)] = 48,
offset: int = 0,
start: int = None,
end: int = None,
db: Session = Depends(get_db),
):
try:
return indexing.search_entities(client, q, library_id, folder_id, limit, offset)
return indexing.search_entities(
client, q, library_id, folder_id, limit, offset, start, end
)
except Exception as e:
print(f"Error searching entities: {e}")
raise HTTPException(