Website logo
⌘K
🖐️Introduction to hyper cloud
🍎Getting Started
😍What's New
Legacy Get Migration Guide
Blueberry Migration Guide
💪Workshops
Deno Workshops
NodeJS Workshops
⚡Quickstarts
NodeJS Quickstarts
🔌API Reference (hyper cloud)
🍎Basics
⚡hyper connect
🔑JWT Auth
💾Data API
🏎️Cache API
🔎Search API
🗄️Storage API
🤓Queue API
🔓Sign In
⚡Applications
⚙️Settings
🔑App Keys
👥Teams
Switching Between Accounts
Application Services
Application Service Instances
Adding a Queue Service
Adding a Search Service
Subscriptions
🤑Upgrade
📕Terminology
Parameters
💳Billing
Payment and Pricing Terms
💼Legal
Terms of Service
Acceptable Use Policy
Privacy Policy
🕶️Hyper Vision
Docs powered by Archbee
API Reference (hyper cloud)
Search API

Add document to search index

8min

POST /{appname}/search/{servicename}

This command adds a document to your search index. The document must have the fields specified by the mapping object when you created the index.

Parameters

Path Parameters

  • appname - string - the name of your hyper cloud application.
  • servicename - string - the name of your hyper cloud service.

Request Body

The request body contains two properties:

  • key - string - this is the unique identifier for the search index
  • doc - object - this is the document that will be added to the index.
JSON
{
    "key": "book-3", 
    "doc": { 
        "_id": "book-3", 
        "type": "book", 
        "name": "Dune", 
        "author": "Frank Herbert", 
        "published": "1965" 
    }
}


Examples

Creates a document in the search index named "default".

You'll need a search service

Be sure to add a search service and provide the following details within the Add Search Service form. This will create a search service instance named default and create an index based on the author field. This way we can search for books by the author.

Example Add Search Service configuration:

Field

Value

Service Name

default

Fields to index

author

Fields to store

name, published

Don't forget!

Be sure to set your HYPER environment variable with the value of your hyper app's connection string.

Node.js
Curl
import { connect } from 'hyper-connect'

const hyper = connect(process.env.HYPER)

const doc = {
  _id: 'book-3',
  type: 'book',
  name: 'Dune',
  author: 'Frank Herbert',
  published: '1965',
}

const result = await hyper.search.add(doc._id, doc)

console.log(result)


Responses

Status Code

Description

Example Response

201

Success

{"ok": true}

500

Error

{"ok": false, "msg": "..."}

Need Help?

You can always reach out to our support team for any additional assistance on slack.



Updated 03 Mar 2023
Did this page help you?
PREVIOUS
Search API
NEXT
Search Index
Docs powered by Archbee
TABLE OF CONTENTS
POST /{appname}/search/{servicename}
Parameters
Path Parameters
Request Body
Examples
You'll need a search service
Don't forget!
Responses
Need Help?
Docs powered by Archbee