📔Interacting with app via API

Getting Started: Loading Data and Querying the API

Once your application is running, you can begin loading data and making queries through the API. Below is a step-by-step guide to help you through the process.

1. Ingest an Entry

To test data ingestion, send a POST request to the /api/v1/ingest/your_schema endpoint. Below is an example using curl:

curl -X POST \
    'http://localhost:8080/api/v1/ingest/your_schema' \
    --header 'Accept: */*' \
    --header 'Content-Type: application/json' \
    --data-raw '{
        "id": "your_id",
        ...
    }'

Note: This is a placeholder example. The request body must be adapted to match the structure required by your schema.

2. Query the System

After ingesting data, you can query the API by sending a POST request to the /api/v1/search/query endpoint. Example:

curl -X POST \
    'http://localhost:8080/api/v1/search/query' \
    --header 'Accept: */*' \
    --header 'Content-Type: application/json' \
    --header 'x-include-metadata: true' \
    --data-raw '{
        "query_text": "your_search_text"
    }'

Note: Including the x-include-metadata: true header will return additional debugging details, such as the search vector, weights, and evaluated NLQ outputs.

3. Load Data from Files

Check Available Data Loaders

To see which data loaders are available, send a request to the following endpoint:

curl 'http://localhost:8080/data-loader/'

Example Response (200 OK):

{
    "result": [
        "<NAME_OF_YOUR_DATA_LOADER>": "DataLoaderConfig(path='https://path-to-your-file.csv', format=<DataFormat.CSV: 2>, name=None, pandas_read_kwargs='{sep: ;}')"
    ]
}

The keys in the response represent the available data loader names that can be used for subsequent requests. Refer to the documentation for details on how these names are defined and how they can be modified.

Initiate the Data Load

To start the data loading process, call the corresponding endpoint. This will create an asynchronous DataLoaderSource task using the name defined in api.py. Use curl to trigger the process:

curl -X POST 'http://localhost:8080/data-loader/<NAME_OF_YOUR_DATA_LOADER>/run'

Example Response (202 Accepted):

{
    "result": "Background task successfully started with name: <NAME_OF_YOUR_DATA_LOADER>"
}

If the provided name does not exist in the system, a 404 NOT FOUND response will be returned. Logs can be checked for additional details regarding the execution of the task.

Last updated