WPSolr logo
Search
Close this search box.

Table of contents :

Getting started with Weaviate: a beginner’s guide

wpsolr-header-solr-elasticsearch-5

Table of contents :

Introduction

Weaviate is a new kind of search engine developed by SeMI Technologies. It is an open-source search engine that uses machine learning to extract valuable insights from structured or unstructured data stored in JSON format.

Weaviate is built on the concept of semantic vector space, which allows it to understand the context and meaning of data you store. This makes Weaviate an ideal search engine for developers looking to build intelligent applications.

In this beginner’s guide, we’ll walk you through the steps to get started with Weaviate and how you can use it to build intelligent search applications.

Getting Started with Weaviate

Here’s how you can get started with Weaviate:

Step 1: Install Weaviate

The first step is to install Weaviate on your machine. You can download Weaviate from the official website or install it using Docker.

Step 2: Create a schema

Once you’ve installed Weaviate, you need to create a schema. The schema defines the types of data you’ll be storing in Weaviate. You can define the schema using JSON. Here’s an example schema:


{
"classes": [
{
  "class": "Product",
  "description": "A product",
  "properties": [
    {
       "name": "name",
       "dataType": ["string"]
       },
       {
       "name": "description",
       "dataType": ["string"]
       },
       {
       "name": "price",
       "dataType": ["number"]
       }
     ]
   }
 ]
}

This schema defines a class called “Product” with three properties: “name”, “description”, and “price”. You can create as many classes as you need.

Step 3: Add data to Weaviate

Now that you’ve created the schema, it’s time to add data to Weaviate. You can add data using the REST API or using a client library.

Here’s an example code snippet using the PHP client library:


require_once("vendor/autoload.php");

use Weaviate\Client\ApiClient;
use Weaviate\Client\Configuration;
use Weaviate\Client\Api\ThingsApi;
use Weaviate\Client\Model\Thing;
use Weaviate\Client\Model\ThingCreate;

$config = new Configuration();
$config->setHost('https://localhost:8080/v1');

$apiClient = new ApiClient($config);
$thingsApi = new ThingsApi($apiClient);

$thing = new ThingCreate([
"class": "Product",
"name": "iPhone",
"description": "The new iPhone",
"price": 999
]);

$thingsApi->createThing($thing);

This code snippet creates a “Product” object with the name “iPhone”, description “The new iPhone”, and price $999.

Step 4: Search data using Weaviate

Once you’ve added data to Weaviate, you can search the data using the REST API or client library.

Here’s an example code snippet using the PHP client library:


require_once("vendor/autoload.php");

use Weaviate\Client\ApiClient;
use Weaviate\Client\Configuration;
use Weaviate\Client\Api\ThingsApi;
use Weaviate\Client\Model\ThingsListResponse;

$config = new Configuration();
$config->setHost('https://localhost:8080/v1');

$apiClient = new ApiClient($config);
$thingsApi = new ThingsApi($apiClient);

$result = $thingsApi->getThings("Product", "iPhone");

echo json_encode($result->getData());

This code snippet searches for a “Product” object with the name “iPhone”.

How WPSOLR Can Help

WPSOLR is a WordPress plugin that integrates Weaviate into your WordPress site. With WPSOLR, you can easily create intelligent search applications for your WordPress site.

WPSOLR provides a user-friendly interface to create a schema and index data to Weaviate. You can also customize the search experience by adding filters, facets, and sorting options.

Conclusion

Weaviate is a powerful search engine that can help you build intelligent search applications. With its machine learning capabilities, Weaviate can extract valuable insights from your data and help you improve the search experience for your users. Using Weaviate with a client library like the PHP client library, you can easily add data to Weaviate and search for relevant results. And with plugins like WPSOLR, you can integrate Weaviate into your WordPress site and build intelligent search applications without writing any code.

Related posts ... not powered by WPSOLR 😊

Advanced Search Filters for WordPress

Introduction Having an advanced search functionality on a WordPress website is becoming increasingly necessary. As more and more data gets added to a website, it