---
title: Using the Semantic Search Config API
description: Using the WP Engine Smart Search Semantic Search Config API
url: https://developers.wpengine.com/docs/smart-search/graphql-api/semantic-search-config/
image: https://developers.wpengine.com/og/docs/smart-search/graphql-api/semantic-search-config.png
---

# Using the Semantic Search Config API

> **Do you have the WP Engine Smart Search Hybrid addon yet?**
>
> The following example assumes you already have WP Engine Smart Search Hybrid addon.

In order to use Semantic / Hybrid Search, we first need to configure it.

This can be done using the `config` mutation. We can also acquire current `config` settings using the `config` query.

## Authentication

Clients calling the API are required to add an authentication header with the valid authentication token.

```
Authorization: Bearer {ACCESS_TOKEN}
```

## Configuring Semantic Search

In order to use and query Semantic / Hybrid Search we first need to configure it. This can be done using the `config` mutation.

### GraphQL Example to Configure Semantic Search

Let’s say we want to configure the `post_title` field for Semantic Search. We can do this by using the following mutation:

```graphql
mutation ConfigureSemanticSearch {
  config {
    semanticSearch(fields: ["post_title"]) {
      type
      fields
    }
  }
}
```

### GraphQL Response

```json
{
  "data": {
    "config": {
      "semanticSearch": {
        "type": "BASIC",
        "fields": ["post_title"]
      }
    }
  }
}
```

## Getting Semantic Search configuration

This can be donne using the following query:

```graphql
query getSemanticSearchConfiguration {
  config {
    semanticSearch {
      type
      fields
    }
  }
}
```

### GraphQL Response

```json
{
  "data": {
    "config": {
      "semanticSearch": {
        "type": "BASIC",
        "fields": ["post_title"]
      }
    }
  }
}
```

## Complete GraphQL Example ( Configure / Index and Search)<!-- {#complete-semantic-search-example} -->

### 1. Configure Semantic Search

```graphql
mutation ConfigureSemanticSearch {
  config {
    semanticSearch(fields: ["post_title"]) {
      type
      fields
    }
  }
}
```

sample response:

```json
{
  "data": {
    "config": {
      "semanticSearch": {
        "type": "BASIC",
        "fields": ["post_title"]
      }
    }
  }
}
```

### 2. Index Document

```graphql
mutation CreateIndexDocument($input: DocumentInput!) {
  index(input: $input) {
    success
    code
    message
    document {
      id
      data
    }
  }
}
```

with variables:

```json
{
  "input": {
    "data": {
      "ID": 1,
      "post_title": "Rabbit",
      "post_content": "Rabbit is happily running",
      "post_date": "11-06-2023T12:33:00",
      "post_type": "post",
      "post_status": "publish"
    }
  }
}
```

sample response:

```json
{
  "data": {
    "index": {
      "success": true,
      "code": "200",
      "message": "Document indexed successfully",
      "document": {
        "id": "CJfqrI0BxRpQ02smQWSk",
        "data": {
          "ID": 1,
          "post_content": "Rabbit is happily running",
          "post_date": "11-06-2023T12:33:00",
          "post_status": "publish",
          "post_title": "Rabbit",
          "post_type": "post"
        }
      }
    }
  }
}
```

### 3. Search using semantic search:

Search using semantic search can be done using the following query:

```graphql
query FindWithSemanticSearch {
  find(
    query: "eats carrots and is a rodent"
    semanticSearch: { searchBias: 10, fields: ["post_title"] }
  ) {
    total
    documents {
      score
      data
    }
  }
}
```

sample response:

```json
{
  "data": {
    "find": {
      "total": 1,
      "documents": [
        {
          "score": 2.5204816,
          "data": {
            "ID": 1,
            "post_content": "Rabbit is happily running",
            "post_date": "11-06-2023T12:33:00",
            "post_status": "publish",
            "post_title": "Rabbit",
            "post_type": "post"
          }
        }
      ]
    }
  }
}
```

## Was this helpful?

Thanks for the feedback!

```json
{"@context":"https://schema.org","@graph":[{"@type":"WebSite","@id":"https://developers.wpengine.com/#website","name":"WP Engine Product Documentation","url":"https://developers.wpengine.com/","description":"Resources for developing, deploying, and scaling on WP Engine.","inLanguage":"en-US","keywords":["API documentation","product documentation","headless WordPress","managed WordPress hosting"],"publisher":{"@id":"https://wpengine.com/#organization"}}]}
```
