Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions stac_fastapi/opensearch/stac_fastapi/opensearch/database_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
from stac_fastapi.types.stac import Collection, Item

logger = logging.getLogger(__name__)
ES_MAX_URL_LENGTH = 4096


async def create_index_templates() -> None:
Expand Down Expand Up @@ -546,6 +547,17 @@ async def execute_search(

index_param = indices(collection_ids)

if len(index_param) > ES_MAX_URL_LENGTH - 300:
index_param = ITEM_INDICES
index_filter = {"terms": {"collection": collection_ids}}
if "bool" not in search_body["query"]:
search_body["query"]["bool"] = {}
if "filter" not in search_body["query"]["bool"]:
search_body["query"]["bool"]["filter"] = [index_filter]
filters = search_body["query"]["bool"]["filter"]
if index_filter not in filters:
filters.append(index_filter)

max_result_window = MAX_LIMIT

size_limit = min(limit + 1, max_result_window)
Expand Down