Skip to content

Commit 069c9e0

Browse files
linting
1 parent 0d647a9 commit 069c9e0

File tree

2 files changed

+6
-38
lines changed
  • stac_fastapi
    • core/stac_fastapi/core/extensions
    • sfeos_helpers/stac_fastapi/sfeos_helpers/database

2 files changed

+6
-38
lines changed

stac_fastapi/core/stac_fastapi/core/extensions/query.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from enum import auto
1010
from types import DynamicClassAttribute
1111
from typing import Any, Callable, Dict, Optional
12-
import re
1312

1413
from pydantic import BaseModel, model_validator
1514
from stac_pydantic.utils import AutoValueEnum

stac_fastapi/sfeos_helpers/stac_fastapi/sfeos_helpers/database/query.py

Lines changed: 6 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@
44
"""
55

66
from typing import Any, Dict, List, Optional
7-
from stac_fastapi.types.rfc3339 import rfc3339_str_to_datetime
8-
from stac_fastapi.core.datetime_utils import datetime_to_str
97

8+
from stac_fastapi.core.datetime_utils import datetime_to_str
109
from stac_fastapi.sfeos_helpers.mappings import Geometry
10+
from stac_fastapi.types.rfc3339 import rfc3339_str_to_datetime
1111

1212
ES_MAX_URL_LENGTH = 4096
1313

1414

1515
def is_numeric(val: str) -> bool:
16+
"""Check if an input string value is numeric."""
1617
try:
1718
float(val)
1819
return True
@@ -21,7 +22,7 @@ def is_numeric(val: str) -> bool:
2122

2223

2324
def process_ftq(q: str):
24-
"""Process a date, numeric, or text free-text query"""
25+
"""Process a date, numeric, or text free-text query."""
2526
q = q.strip()
2627
if not q:
2728
return
@@ -37,16 +38,13 @@ def process_ftq(q: str):
3738

3839

3940
def apply_free_text_filter_shared(
40-
search: Any,
41-
free_text_queries: Optional[List[str]],
42-
fields: Optional[List[str]] = [],
41+
search: Any, free_text_queries: Optional[List[str]]
4342
) -> Any:
4443
"""Create a free text query for Elasticsearch/OpenSearch.
4544
4645
Args:
4746
search (Any): The search object to apply the query to.
4847
free_text_queries (Optional[List[str]]): A list of text strings to search for in the properties.
49-
fields: Optional[List[str]]: A list of fields to return
5048
5149
Returns:
5250
Any: The search object with the free text query applied, or the original search
@@ -56,7 +54,6 @@ def apply_free_text_filter_shared(
5654
This function creates a query_string query that searches for the specified text strings
5755
in the entire document. The query strings are joined with OR operators.
5856
"""
59-
6057
if free_text_queries:
6158
processed_queries = [
6259
process_ftq(q.strip()) for q in free_text_queries if q.strip()
@@ -65,35 +62,7 @@ def apply_free_text_filter_shared(
6562
if processed_queries:
6663
free_text_query_string = " AND ".join(processed_queries)
6764

68-
search = search.query(
69-
"query_string", query=free_text_query_string, fields=fields
70-
)
71-
72-
return search
73-
74-
75-
def apply_free_text_filter_shared(
76-
search: Any, free_text_queries: Optional[List[str]]
77-
) -> Any:
78-
"""Create a free text query for Elasticsearch/OpenSearch.
79-
80-
Args:
81-
search (Any): The search object to apply the query to.
82-
free_text_queries (Optional[List[str]]): A list of text strings to search for in the properties.
83-
84-
Returns:
85-
Any: The search object with the free text query applied, or the original search
86-
object if no free_text_queries were provided.
87-
88-
Notes:
89-
This function creates a query_string query that searches for the specified text strings
90-
in all properties of the documents. The query strings are joined with OR operators.
91-
"""
92-
if free_text_queries is not None:
93-
free_text_query_string = '" OR properties.\\*:"'.join(free_text_queries)
94-
search = search.query(
95-
"query_string", query=f'properties.\\*:"{free_text_query_string}"'
96-
)
65+
search = search.query("query_string", query=free_text_query_string)
9766

9867
return search
9968

0 commit comments

Comments
 (0)