# Searching SPARC Dataset Indices

## Introduction

The SPARC metadata APIs are provided via an ElasticSearch endpoint.  &#x20;

### Access to the metadata APIs

Access to the metadata API is provided via an Elasticsearch pass-through.

## Elasticsearch Pass-Through

<mark style="color:green;">`POST`</mark> `https://api.scicrunch.io/elastic/v1/SPARC_Algolia_pr/_search`

The pass-through is accessible at <https://scicrunch.org/api/1/elastic>.  Similar to standard Elasticsearch APIs you must then supply an index and an action.  In this case the SPARC Portal Dataset metadata (SPARC\_Algolia\_pr) and the search command (\_search).\
\
Documentation on the Elasticsearch Search API is available at <https://www.elastic.co/guide/en/elasticsearch/reference/6.8/search.html&#x20>;

#### Path Parameters

| Name                                    | Type   | Description                                   |
| --------------------------------------- | ------ | --------------------------------------------- |
| index<mark style="color:red;">\*</mark> | String | For SPARC datasets this is SPARC\_Algolia\_pr |

#### Headers

| Name                                     | Type   | Description                         |
| ---------------------------------------- | ------ | ----------------------------------- |
| apikey<mark style="color:red;">\*</mark> | String | Your API key to access the services |

#### Request Body

| Name | Type   | Description     |
| ---- | ------ | --------------- |
| data | String | JSON query body |

{% tabs %}
{% tab title="200: OK Successful response" %}

{% endtab %}
{% endtabs %}

## Elasticsearch Pass-Through

<mark style="color:blue;">`GET`</mark> `https://api.scicrunch.io/elastic/v1/SPARC_Algolia_pr/_search`

The pass-through is accessible at <https://scicrunch.org/api/1/elastic>.  Similar to standard Elasticsearch APIs you must then supply an index and an action.  In this case the SPARC Portal Dataset metadata (SPARC\_Algolia\_pr) and the search query parameter.\
\
Documentation on the Elasticsearch Search API is available at <https://www.elastic.co/guide/en/elasticsearch/reference/6.8/search.html&#x20>;

#### Path Parameters

| Name                                    | Type   | Description                                   |
| --------------------------------------- | ------ | --------------------------------------------- |
| index<mark style="color:red;">\*</mark> | String | For SPARC datasets this is SPARC\_Algolia\_pr |

#### Query Parameters

| Name | Type   | Description   |
| ---- | ------ | ------------- |
| q    | String | Search string |

#### Headers

| Name                                     | Type   | Description                         |
| ---------------------------------------- | ------ | ----------------------------------- |
| apikey<mark style="color:red;">\*</mark> | String | Your API key to access the services |

{% tabs %}
{% tab title="200: OK Successful response" %}

{% endtab %}
{% endtabs %}

### SPARC metadata indices

Management of indices is accomplished via [Elasticsearch aliases](https://www.elastic.co/guide/en/elasticsearch/reference/6.8/indices-aliases.html). Three index aliases are provided:

| SPARC\_Algolia\_pr | Production index for SPARC datasets |
| ------------------ | ----------------------------------- |

Using aliases will allow for testing on updates and enhancements to the metadata index structure.  If needed additional aliases can be constructed for specialized testing.
