Quickstart

Simple introduction to glitter.

1.Connection

Connect Glitter network using glitter_js package.

const GlitterSdk = require('glitter-sdk-js')
const client = new GlitterSdk()

2.Data model

In the example below we create a schema which is used to describe data model. After creation success, you will be able to check the detail of schema info here.

# create schema with a url and title
const schema = [
    {
        "name": "url",
        "type": "string",
        "primary": "true",
        "index": {
            "type": "keyword"
        }
    },
    {
        "name": "title",
        "type": "string",
        "index": {
            "type": "text"
        }
    }
]
const res = client.db.create_schema("sample", schema)
# get the schema you create
const client.db.get_schema("sample")

3.Put doc

Once the put_doc success, you will be able to see the details of tx here.

const put_res = client.db.put_doc("sample", {
        "url": "https://glitterprotocol.io/",
        "title": "A Decentralized Content Indexing Network",
    })

5.Another search example

Below is an example for searching rss data.

# standard query for performing a full-text search
client.db.search("rss", "oppo")
# only search title
client.db.search("rss", "oppo", ['title'])
# aggregation by tags
client.db.search("rss", "oppo", ['title', 'description'], filters=[], aggs_field=["tags"])
# search interesting content by tags
client.db.search("rss", "Mobile", ['tags'])