|
|
|
import requests |
|
import json |
|
from typing import Dict, List |
|
|
|
class OpenSearchClient: |
|
def __init__(self): |
|
self.base_url = "https://dev-abhinav.ngrok.io" |
|
|
|
def search_jobseekers(self, search_params: Dict) -> List[Dict]: |
|
"""Search for jobseekers using OpenSearch""" |
|
endpoint = f"{self.base_url}/jobseeker_search/inverted_index_search" |
|
|
|
try: |
|
print("\nSending request to OpenSearch...") |
|
print(f"Endpoint: {endpoint}") |
|
print("Request payload:", json.dumps(search_params, indent=2)) |
|
|
|
response = requests.post(endpoint, json=search_params) |
|
|
|
print("\nOpenSearch Response:") |
|
print(f"Status Code: {response.status_code}") |
|
print("Response Headers:", response.headers) |
|
try: |
|
print("Response Body:", json.dumps(response.json(), indent=2)) |
|
except: |
|
print("Response Body:", response.text) |
|
|
|
response.raise_for_status() |
|
return response.json() |
|
except requests.exceptions.RequestException as e: |
|
print(f"Error searching jobseekers: {str(e)}") |
|
return [] |