Repository: jerryjliu/gpt_index
File: llama-index-integrations/vector_stores/llama-index-vector-stores-azureaisearch/llama_index/vector_stores/azureaisearch/base.py (Python)

Code before:
            vector=self._query.query_embedding,
            k_nearest_neighbors=50,
            fields=self._field_mapping["embedding"],
        )
        vector_queries = [vectorized_query]
        logger.info("Vector search with supplied embedding")
        return vector_queries

    def _create_query_result(
        self, search_query: str, vectors: Optional[List[Any]]
    ) -> VectorStoreQueryResult:
        params = {
            "search_text": search_query,
            "vector_queries": vectors,
            "top": self._query.similarity_top_k,
            "select": self._select_fields,
            "filter": self._odata_filter,
            "semantic_configuration_name": self._semantic_configuration_name,
            "query_type": "semantic",
        }

        search_params = {**self._search_kwargs, **params}

        search_params.pop("odata_filter", None)
        search_params.pop("odata_filters", None)

        results = self._search_client.search(**search_params)

        id_result = []
        node_result = []
        score_result = []
        for result in results:
            node_id = result[self._field_mapping["id"]]
            metadata_str = result[self._field_mapping["metadata"]]
            metadata = json.loads(metadata_str) if metadata_str else {}
            # use reranker_score instead of score
            score = result["@search.reranker_score"]
            chunk = result[self._field_mapping["chunk"]]

            try:
                node = metadata_dict_to_node(metadata)
                node.set_content(chunk)
            except Exception:
                # NOTE: deprecated legacy logic for backward compatibility
                metadata, node_info, relationships = legacy_metadata_dict_to_node(
                    metadata
                )

                node = TextNode(
                    text=chunk,
                    id_=node_id,

Review comment (suggestion):
Hey @federicocaccialanzaabb 
Instead of popping these kwargs in multiple create_query_result function 
I feel it's worth maybe popping them in [here](https://github.com/run-llama/llama_index/pull/19800/files#diff-3fbf222873e40105ff4f70544280197a54f52dbef4e8ae108be327fcf8d3c3ceR1219) line : 1219

def query function, once we have loaded the odata_filter kwargs and then pop those 2 fields from the Kwargs that's initializing the downstream Azure classes 

Code after:
            fields=self._field_mapping["embedding"],
        )
        vector_queries = [vectorized_query]
        logger.info("Vector search with supplied embedding")
        return vector_queries

    def _create_query_result(
        self, search_query: str, vectors: Optional[List[Any]]
    ) -> VectorStoreQueryResult:
        params = {
            "search_text": search_query,
            "vector_queries": vectors,
            "top": self._query.similarity_top_k,
            "select": self._select_fields,
            "filter": self._odata_filter,
            "semantic_configuration_name": self._semantic_configuration_name,
            "query_type": "semantic",
        }

        search_params = {**self._search_kwargs, **params}

        results = self._search_client.search(**search_params)

        id_result = []
        node_result = []
        score_result = []
        for result in results:
            node_id = result[self._field_mapping["id"]]
            metadata_str = result[self._field_mapping["metadata"]]
            metadata = json.loads(metadata_str) if metadata_str else {}
            # use reranker_score instead of score
            score = result["@search.reranker_score"]
            chunk = result[self._field_mapping["chunk"]]

            try:
                node = metadata_dict_to_node(metadata)
                node.set_content(chunk)
            except Exception:
                # NOTE: deprecated legacy logic for backward compatibility
                metadata, node_info, relationships = legacy_metadata_dict_to_node(
                    metadata
                )

                node = TextNode(
                    text=chunk,
                    id_=node_id,
                    metadata=metadata,
                    start_char_idx=node_info.get("start", None),
                    end_char_idx=node_info.get("end", None),
                    relationships=relationships,
                )