You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@yashatreya/re-search-js

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@yashatreya/re-search-js

JS client for re-search

0.0.3
latest
npmnpm
Version published
Maintainers
1
Created
Source

re-search-js

Installation

npm install @yashatreya/re-search-js

Usage

const ReSearch = require('re-search');

const client = new ReSearch('projectID', 'admin-apiKey','indexName');

Methods


/**
 *  Method 1: addSchema()
 *  Equivalent to the `SCHEMA` argument in `FT.CREATE` command of the redis search
 *  This helps the search API know which fields to search from.
 * 
 *  SchemaFieldObject: {
 *    type: 'TEXT' | 'NUMERIC'
 *    field: 'fieldName'
 *    sortable: boolean
 *  }
 * 
 *  client.addSchema(array: SchemaFieldObject[])
 *  Takes array of objects as parameter
 */ 

/**
 * @param {array} array - array of objects
 * @return Promise
 */

client.addSchema([
    {
        type: 'TEXT',
        field: 'fieldName',
        sortable: true,
    },
    {
        type: 'NUMERIC',
        field: 'fieldName',
        sortable: true,
    },
    {
        type: 'NUMERIC',
        field: 'fieldName',
        sortable: true,
    }
]);

/**
 *  Method 2: saveObjects
 *  data = {
 *    objectID: 'string' - This is a mandatory field which has the value of type string. It is a unique ID for your object
 *    [key]: [value]
 *    ....
 *  }
 *  client.saveObjects(array: data[]) - Takes array of objects as parameter
 * 
 *  Currently the saveObjects is limited to only 500 objects per request
 */

const array = require("randomArray.json");

/**
 * @param {array} array - array of objects
 * @return Promise
 */

client.saveObjects(array)
/**
 *  Method 3: removeObjects
 *  
 *  client.removeObjects(array: string[]) - Takes array of strings(objectIDs) as parameter
 * 
 *  @param {array} - array of objectID's
 *  @return Promise
 */
const arr = ['123', '2acfe', 'wvr345'];
client.removeObjects(arr);

FAQs

Package last updated on 26 May 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts