interop_indexes

command
v1.8.8-0...-edaca3c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 22, 2026 License: MIT Imports: 6 Imported by: 0

README

Interoperability Demo: Secondary Indexes

This example demonstrates how to use SOP's jsondb package to create a "schema-less" store with composite secondary indexes. This approach ensures that your data sorting and indexing rules are compatible across all SOP language bindings (Go, Python, Java, C#, Rust).

Overview

The example creates a database of products and indexes them by:

  1. Category (Ascending)
  2. Price (Descending)

This means products will be grouped by category, and within each category, the most expensive items will appear first.

Key Features

  • jsondb.NewJsonBtreeMapKey: Uses a dynamic map for keys, allowing flexible fields.
  • IndexSpecification: Defines the sorting order for multiple fields.
  • Data Generation: The script automatically generates 500 records across various categories (Electronics, Books, Clothing, Home, Garden) to populate the database for testing and visualization.

Running the Example (Map-based)

This version uses map[string]any for keys, which is useful for dynamic schemas.

go run examples/interop_secondary_indexes/main.go

Data is stored in: ./data/interop_indexes

We recommend using the struct-based approach for most Go applications. This example also serves as the primary data generator for testing the Data Management Suite, creating 500 records.

This allows you to define your key as a struct:

type ProductKey struct {
    Category string  `json:"category"`
    Price    float64 `json:"price"`
    ID       string  `json:"id"`
}

Run the struct-based example to populate the database:

go run examples/interop_secondary_indexes/struct_key_example/main.go

Verifying with Data Management Suite

After running the struct-based example, you can use the SOP Data Management Suite to inspect the data.

  1. Start the Data Management Suite:
    go run tools/httpserver/main.go -registry ./data/struct_key_demo
    
  2. Open http://localhost:8080.
  3. Select the products_struct store.
  4. You can now browse the 500 generated records, navigate through pages, and search for specific items using the complex key search feature.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL