+
Skip to content
Merged
Changes from all 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
14 changes: 1 addition & 13 deletions lib/sycamore/sycamore/connectors/opensearch/opensearch_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,42 +398,32 @@ def _to_doc(self, slice_query: dict[str, Any]) -> List[dict[str, Any]]:

records = OpenSearchReaderQueryResponse(results, os_client)
docs = records.to_docs(query_params=self._query_params)
# logging.info(f"Sample: {docs[:5]}")
return [{"doc": doc.serialize()} for doc in docs]

def map_reduce_parent_id(self, group: pd.DataFrame) -> pd.DataFrame:
parent_ids = set()
for row in group["parent_id"]:
# logging.info(f"Row: {row}: {type(row)}")
if row not in parent_ids:
parent_ids.add(row)

# logger.info(f"Parent IDs: {parent_ids}")
return pd.DataFrame([{"_source": {"doc_id": parent_id}} for parent_id in parent_ids])

def reconstruct(self, doc: dict[str, Any]) -> dict[str, Any]:
# logging.info(f"Applying on {doc} ({type(doc)}) ...")
client = self.Client.from_client_params(self._client_params)

if not client.check_target_presence(self._query_params):
raise ValueError("Target is not present\n" f"Parameters: {self._query_params}\n")

os_client = client._client
# doc["_source"]["properties"] = json.loads(doc["_source"]["properties"])
doc_id = doc["_source"]["doc_id"]
assert isinstance(
self._query_params, OpenSearchReaderQueryParams
), f"Wrong kind of query parameters found: {self._query_params}"

parent_doc = os_client.get(
index=self._query_params.index_name, id=doc_id
) # , _source_includes=["properties"])["_source"]["properties"]
parent_doc = os_client.get(index=self._query_params.index_name, id=doc_id)
records = OpenSearchReaderQueryResponse([parent_doc], os_client)
docs = records.to_docs(query_params=self._query_params)

# properties[DocumentPropertyTypes.SOURCE] = DocumentSource.DOCUMENT_RECONSTRUCTION_PARENT
# docs[0].update(parent_doc["_source"]) # json.loads(doc["_source"]["properties"])
# docs[0]["properties"] = json.loads(doc["_source"]["properties"])
return {"doc": docs[0].serialize()}

def execute(self, **kwargs) -> "Dataset":
Expand All @@ -455,9 +445,7 @@ def map_reduce_docs_by_slice(self, group: pd.DataFrame) -> pd.DataFrame:
), f"Wrong kind of query parameters found: {self._query_params}"

doc_ids = set()
# logger.info(f"Applying on {group} ({type(group)}) ...")
for row in group["doc_id"]:
# logger.info(row)
doc_ids.add(row)

logger.info(f"No. of IDs: {len(doc_ids)}")
Expand Down
Loading
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载