class_docstr: Queries a server (eg, search engine) for a set of documents.
  
  This module relies on a running HTTP server. For each retrieval it sends the query
  to this server and receives a JSON; it parses the JSON to create the response.
class_docstr_tok: ["Queries","a","server","(","eg",",","search","engine",")","for","a","set","of","documents",".","This","module","relies","on","a","running","HTTP","server",".","For","each","retrieval","it","sends","the","query","to","this","server","and","receives","a","JSON",";","it","parses","the","JSON","to","create","the","response","."]
code: def _query_search_server(self, query_term, n):
      server = self.server_address
      req = {"q": query_term, "n": n}
      trials = []
      while True:
          try:
              logging.debug(f"sending search request to {server}")
              server_response = requests.post(
                  server, data=req, timeout=self._server_timeout
              )
              resp_status = server_response.status_code
              trials.append(f"Response code: {resp_status}")
              if resp_status == 200:
                  return server_response.json().get("response", None)
          except requests.exceptions.Timeout:
              if len(trials) > self._max_num_retries:
                  break
              trials.append(
                  f"Timeout after {self._server_timeout} seconds."
              )
      logging.error(
          f"Failed to retrieve data from server after  {len(trials)+1} trials."
          f"\nFailed responses: {trials}"
      )
  
file_path: ParlAI/parlai/agents/rag/retrieve_api.py
imports: from abc import ABC, abstractmethod
  import requests
  from typing import Any, Dict, List
  from parlai.core.opt import Opt
  from parlai.utils import logging
label_desc: Use image node_id 2 for calling the SearchEngineRetriever obj's underlying member method code with example usage: obj._query_search_server(query_term, n) and returns: server_response