)
        elif self.engine_data_type == 1:
            content_search_spec = None
        else:
            # TODO: Add extra data type handling for type website
            raise NotImplementedError(
                "Only engine data type 0 (Unstructured) or 1 (Structured)"
                + " are supported currently."
                + f" Got {self.engine_data_type}"
            )
        return SearchRequest(
            query=query,
            filter=self.filter,
            serving_config=self._serving_config,
            page_size=self.max_documents,
            content_search_spec=content_search_spec,
            query_expansion_spec=query_expansion_spec,
            spell_correction_spec=spell_correction_spec,
        )
    def _get_relevant_documents(
        self, query: str, *, run_manager: CallbackManagerForRetrieverRun
    ) -> List[Document]:
        """Get documents relevant for a query."""
        from google.api_core.exceptions import InvalidArgument
        search_request = self._create_search_request(query)
        try:
            response = self._client.search(search_request)
        except InvalidArgument as e:
            raise type(e)(
                e.message + " This might be due to engine_data_type not set correctly."
            )
        if self.engine_data_type == 0:
            documents = self._convert_unstructured_search_response(response.results)
        elif self.engine_data_type == 1:
            documents = self._convert_structured_search_response(response.results)
        else:
            # TODO: Add extra data type handling for type website
            raise NotImplementedError(
                "Only engine data type 0 (Unstructured) or 1 (Structured)"
                + " are supported currently."
                + f" Got {self.engine_data_type}"
            )
        return documents