Skip to main content
In this recipe we’ll learn how to update the configuration of a JSON index.

Prerequisites

To follow the code examples in this guide, you must install Docker locally and download recipes.
  1. If you haven’t already, download recipes.
  2. In terminal, go to the recipe by running the following command:

Launch Pinot Cluster

You can spin up a Pinot Cluster by running the following command:
This command will run a single instance of the Pinot Controller, Pinot Server, Pinot Broker, Kafka, and Zookeeper. You can find the docker-compose.yml file on GitHub.

Data generator

This recipe contains a data generator that creates events with data about people. It uses the Faker library, so you’ll first need to install that:
You can generate data by running the following command:
Output is shown below:

Kafka ingestion

We’re going to ingest this data into an Apache Kafka topic using the kcat command line tool. We’ll also use jq to structure the data in the key:payload structure that Kafka expects:
We can check that Kafka has some data by running the following command:
We’ll see something like the following:

Pinot Schema and Table

Now let’s create a Pinot Schema and Table. First, the schema:
schema.json Our schema has only two columns - one for the timestamp and another one that stores the person. Now for the table config:
table.json This highlighted section contains the config for the JSON index. An explanation of each of the config parameters is shown below: So we are including all fields in the JSON index.
Fields included in the JSON index can be filtered using the JSON_MATCH function. If you use this function with a field that isn’t included in the index, it won’t return any records.
We’ll create the table by running the following:

Querying by JSON index

Let’s now try to query this table using the JSON index. JSON indexes support the following predicates: =, <>, IN, and NOT IN
Query Results And one more:
Query Results

Updating JSON index

Now let’s say we want to update the config of the JSON index so that not all fields are indexed. At the moment this must be done in the following steps:
  1. Update the table config to remove the index completely.
  2. Refresh all segments.
  3. Update the table config with the new config.
  4. Refresh all segments.
Let’s first remove the index by calling the AddTable command with the following table config:
table-no-index.json Next, let’s run the command
And let’s refresh all segments:
If we now re-run our last query, we’ll get the following output:
Let’s now add the updated index, based on the table config below:
table-updated-index.json This time we’re not going to index age, any array fields (i.e interests or friend_ids), or address.street_address. Let’s apply that config
Refresh all segments again:
It’s query time! Let’s start with the swimming query:
Query Results This field isn’t indexed anymore, so we don’t get any results. Same thing if we search by street address:
Query Results But we can still search by country:
Query Results