---
title: Natural language processing
slug: graph/docs/natural-language-processing
docTags: 
createdAt: 2026-07-30T20:30:19.772Z
---

Optimizely Graph enhances search accuracy using language-specific natural language processing (NLP). NLP lets you retrieve more relevant and semantically meaningful results based on your language preferences and search intent.

## Language-specific search

Use this query to perform a full-text search in a specific language. Optimizely Graph applies language-aware tokenization, stemming, and ranking to return the most relevant results.

The following query searches for the phrase `machine learning algorithms` in English and ranks results using semantic relevance:

```graphql
query LanguageSpecificSearch(
  $searchTerm: String!
  $locale: [Locales!]!
) {
  Content(
    where: {
      _fulltext: { match: $searchTerm }
    }
    locale: $locale
    orderBy: { _ranking: SEMANTIC }
  ) {
    items {
      Name
      _score
      Language {
        Name
        DisplayName
      }
      _concreteType
      ... on ArticlePage {
        TeaserText
        StartPublish
      }
      ... on ProductPage {
        TeaserText
      }
    }
  }
}
```

The following are some example variables:

```json
{
  "searchTerm": "machine learning algorithms",
  "locale": ["en"]
}
```

## Semantic search with language context

Use this query to combine semantic search with language-specific context and content type filtering. It supports synonym expansion and boosts relevance for better precision.

The following query does the following:

- Searches for a term using semantic understanding.
- Applies synonym matching.
- Filters by content type.
- Returns language and type facets for further refinement.

```graphql
query SemanticLanguageSearch(
  $searchTerm: String!
  $locale: [Locales!]!
  $contentTypes: [String!]
) {
  Content(
    locale: $locale
    where: {
      _and: [
        { _fulltext: { 
            match: $searchTerm
            synonyms: ONE
            boost: 8
          }
        }
      ]
    }
    orderBy: { _ranking: SEMANTIC }
    limit: 15
  ) {
    facets {
      Language {
        Name {
          name
          count
        }
      }
      _concreteType(filters:$contentTypes) {
        name
        count
      }
    }
    items {
      Name
      _score
      Language {
        Name
        DisplayName
      }
      _concreteType
      ... on ArticlePage {
        TeaserText
        Category {
          Name
        }
      }
    }
  }
}
```

## Summary

Optimizely Graph's natural language processing capabilities let you deliver smarter, language-aware search experiences. Whether you are targeting a specific locale or using semantic context, these queries help you find the most relevant content in your preferred language.
