How Weaviate uses natural language processing to improve search results

Table of Contents


Weaviate is a natural language search engine that improves search results by using natural language processing (NLP). NLP is a powerful tool that can help a search engine understand the intent behind a search query by analyzing the meaning of the words used. This allows Weaviate to return more accurate search results that are tailored to the user’s needs.

In this article, we will discuss how Weaviate uses NLP to improve search results and provide some code examples using the PHP client. We will also introduce WPSOLR, a plugin that can be used with Weaviate to improve search functionality on WordPress sites.

How Weaviate Uses Natural Language Processing

Weaviate uses NLP to analyze search queries and map them to the most relevant entities in its knowledge graph. The knowledge graph contains information about a wide variety of entities, such as people, places, and things, and how they are related to each other. By analyzing the context of the search query, Weaviate can determine which entities are most relevant to the user’s needs and return search results based on those entities.

To use Weaviate’s natural language search functionality, you first need to index your data. This can be done by creating a schema that defines the data types and relationships between entities in your collection. Once you have created your schema, you can use Weaviate’s REST API to index your data.

Once your data is indexed, you can use Weaviate’s search API to query your data using natural language queries. Weaviate’s search API uses semantic similarity to match search queries to entities in the knowledge graph. This means that even if a search query doesn’t match an exact entity in the knowledge graph, it can still return relevant results based on similar entities.

Here is an example of how you can use the Weaviate PHP client to perform a natural language search:


use Weaviate\Client\Configuration;
use Weaviate\Client\ApiException;
use Weaviate\Client\ObjectResponse;

// Configure the client
$config = Configuration::getDefaultConfiguration()->setApiKey('X-API-KEY', 'your-api-key');
$client = new Weaviate\Client\ApiClient($config);

// Perform a natural language search
$search_query = "What movies has Tom Hanks starred in?";
try {
    $response = $client->graphql->graphqlPost(array('query' => '{Search {Things {Movie {name}}} {Search {Things {Person {name}}}}}', 'variables' => array('search' => $search_query)));
    $result = $response->getData();
    $movies = $result['Search']['Things']['Movie'];
} catch (ApiException $e) {
    echo 'Exception when calling GraphQLApi->graphqlPost: ', $e->getMessage(), PHP_EOL;

In this example, we are performing a search for movies that Tom Hanks has starred in. Weaviate’s natural language processing allows us to use a more conversational query rather than having to manually specify the search terms.

How WPSOLR Can Help

WPSOLR is a WordPress search plugin that can be used with Weaviate to improve search functionality on WordPress sites. WPSOLR allows you to easily integrate Weaviate into your WordPress site and customize the search experience to meet your needs.

With WPSOLR, you can configure Weaviate to index your WordPress content and provide more accurate search results to your users. You can also customize the search interface with filters, facets, and other search features to improve the user experience and help users find what they are looking for faster.


Overall, Weaviate’s use of natural language processing allows for more accurate and relevant search results for users. By analyzing the context of a search query, Weaviate can map the query to relevant entities in its knowledge graph and return search results based on those entities. With the help of WPSOLR, Weaviate can be easily integrated into WordPress sites to provide better search functionality and improve the user experience.

Read more related content