Skip to content

Create Index

Overview

This endpoint allows you to create a new index, which serves as a collection of documents. Subsequently, you can add documents using the Add or Update Document endpoint, and perform searches on the created index using the Search endpoint.

Endpoint

POST https://api.lixiasearch.com/v1/indexes

Request Body

{
    "accountId": int,
    "fields": [
        {
        "name": "string",
        "feature": int,
        "primaryKey": boolean,
        "type": "int64" | "string" | "text"
        },
        ...
    ],
    "name": "string"
}
  • accountId: The unique identifier associated with your account.
  • fields: An array of field objects, each defining the characteristics of a document field.
    • name: The name of the field
    • feature: A boolean indicating whether the field can be used as a feature for custom scoring. See the Search endpoint for more details.
    • primaryKey: A boolean indicating whether the field is a primary key. Exactly one field can be designated as the primary key.
    • type: The data type of the field, which can be "int64", "string" or "text".
      • int64: Represents a 64-bit integer.
      • string: Denotes a non-tokenized string, usually used for constants.
      • text: Refers to tokenized text.
  • name: A descriptive name for the new index.

Example

curl https://api.lixiasearch.com/v1/indexes \
  --header "Authorization: Bearer $ACCESS_TOKEN" \
  --header "Content-Type: application/json" \
  --data @- <<EOF
{
  "accountId": "$ACCOUNT_ID",
  "fields": [
    {"name": "id", "primaryKey": true, "type": "int64"},
    {"name": "body", "type": "text"},
    {"name": "title", "type": "text"}
  ],
  "name": "my_index"
}
EOF

Make sure you replace $ACCESS_TOKEN and $ACCOUNT_ID$ with your actual access token and account ID.

Response Body

{
    "id": int
}
  • id: The unique identifier assigned to the newly created index.