<?php

namespace wpsolr\core\classes\engines\opensearch_vector_php;

use wpsolr\core\classes\engines\opensearch_php\WPSOLR_IndexOpenSearchClient;
use wpsolr\core\classes\WpSolrSchema;

class WPSOLR_IndexOpenSearch_Vector_Client extends WPSOLR_IndexOpenSearchClient {
	use WPSOLR_OpenSearch_Vector_Client;

	protected function search_engine_client_prepare_documents_for_update( array $documents ) {
		$formatted_document = parent::search_engine_client_prepare_documents_for_update( $documents );
		foreach ( $formatted_document as &$document ) {
			if ( ! empty( $document[ WpSolrSchema::_FIELD_NAME_CONTENT ] ) ) {
				$document[ $this->_FIELD_NAME_TEXT_CONCATENATED_FIELDS_EMBEDDING ] = $document[ WpSolrSchema::_FIELD_NAME_CONTENT ];
			}
		}

		return $formatted_document;
	}

}
