updates
This commit is contained in:
parent
f0cf21791e
commit
deb76ebe63
3 changed files with 5 additions and 8 deletions
|
|
@ -34,9 +34,6 @@ except ImportError:
|
||||||
helpers = None
|
helpers = None
|
||||||
_HAS_OPENSEARCH = False
|
_HAS_OPENSEARCH = False
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from opensearchpy import OpenSearch, helpers
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
DEFAULT_SIZE = 10
|
DEFAULT_SIZE = 10
|
||||||
|
|
@ -166,7 +163,7 @@ class GraphDriver(ABC):
|
||||||
'' # Neo4j (default) syntax does not require a prefix for fulltext queries
|
'' # Neo4j (default) syntax does not require a prefix for fulltext queries
|
||||||
)
|
)
|
||||||
_database: str
|
_database: str
|
||||||
aoss_client: OpenSearch | None
|
aoss_client: OpenSearch | None # type: ignore
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def execute_query(self, cypher_query_: str, **kwargs: Any) -> Coroutine:
|
def execute_query(self, cypher_query_: str, **kwargs: Any) -> Coroutine:
|
||||||
|
|
|
||||||
|
|
@ -62,16 +62,16 @@ class Neo4jDriver(GraphDriver):
|
||||||
if aoss_host and aoss_port and boto3 is not None:
|
if aoss_host and aoss_port and boto3 is not None:
|
||||||
try:
|
try:
|
||||||
session = boto3.Session()
|
session = boto3.Session()
|
||||||
self.aoss_client = OpenSearch(
|
self.aoss_client = OpenSearch( # type: ignore
|
||||||
hosts=[{'host': aoss_host, 'port': aoss_port}],
|
hosts=[{'host': aoss_host, 'port': aoss_port}],
|
||||||
http_auth=Urllib3AWSV4SignerAuth(
|
http_auth=Urllib3AWSV4SignerAuth( # type: ignore
|
||||||
session.get_credentials(), session.region_name, 'aoss'
|
session.get_credentials(), session.region_name, 'aoss'
|
||||||
),
|
),
|
||||||
use_ssl=True,
|
use_ssl=True,
|
||||||
verify_certs=True,
|
verify_certs=True,
|
||||||
connection_class=Urllib3HttpConnection,
|
connection_class=Urllib3HttpConnection,
|
||||||
pool_maxsize=20,
|
pool_maxsize=20,
|
||||||
)
|
) # type: ignore
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning(f'Failed to initialize OpenSearch client: {e}')
|
logger.warning(f'Failed to initialize OpenSearch client: {e}')
|
||||||
self.aoss_client = None
|
self.aoss_client = None
|
||||||
|
|
|
||||||
|
|
@ -246,7 +246,7 @@ def build_aoss_node_filters(group_ids: list[str], search_filters: SearchFilters)
|
||||||
|
|
||||||
|
|
||||||
def build_aoss_edge_filters(group_ids: list[str], search_filters: SearchFilters) -> list[dict]:
|
def build_aoss_edge_filters(group_ids: list[str], search_filters: SearchFilters) -> list[dict]:
|
||||||
filters = [{'terms': {'group_id': group_ids}}]
|
filters: list[dict] = [{'terms': {'group_id': group_ids}}]
|
||||||
|
|
||||||
if search_filters.edge_types:
|
if search_filters.edge_types:
|
||||||
filters.append({'terms': {'edge_types': search_filters.edge_types}})
|
filters.append({'terms': {'edge_types': search_filters.edge_types}})
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue