-
Notifications
You must be signed in to change notification settings - Fork 65
Add OpenSearch shard related logging #1145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This reverts commit 740a6e3.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. A couple of suggestions.
response = super().search(**kwargs) | ||
shards = response.get("_shards", {}) | ||
if shards.get("total") != shards.get("successful"): | ||
logger.error(f"OpenSearch query skipped shards: {response}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be helpful to fish out "query" from kwargs (if it's present) and log it along with the response? Do you think we need to log the entire response payload? It could be big.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll leave this in for now while we're debugging so we know which results actually got back. If it happens frequently enough and we handle it we can clean
import logging | ||
from typing import Optional, Any | ||
|
||
from opensearchpy import OpenSearch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here's the unconditional import
|
||
@requires_modules("opensearchpy", extra="opensearch") | ||
def query(self, query: OpenSearchQuery) -> OpenSearchQueryResult: | ||
from opensearchpy import OpenSearch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prob need to keep the import sycamore.connectors.opensearch.utils here instead of at the top
llm: Optional[Union[LLM, str]] = None, | ||
query_plan_strategy: Optional[QueryPlanStrategy] = None, | ||
): | ||
from opensearchpy import OpenSearch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also here
@classmethod | ||
@requires_modules("opensearchpy", extra="opensearch") | ||
def from_client_params(cls, params: BaseDBReader.ClientParams) -> "OpenSearchReaderClient": | ||
from opensearchpy import OpenSearch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also here
Signed-off-by: Henry Lindeman <hmlindeman@yahoo.com>
Ran locally and logged the opposite condition to make sure it's working