Skip to main content

Add Data to Index

After configuring the HoppySearch JavaScript/Node.js client, you can proceed to index your data using the following code:

documents = [
{
"image": "https://static.toiimg.com/thumb/55476463.cms?width=1200&height=900",
"name": "Balu shahi",
"about": "Balu shahi is a traditional sweet from West Bengal, made with a mixture of maida flour, yogurt, and oil...",
"ingredients": "Maida flour, yogurt, oil, sugar",
"state": "West Bengal",
"hs_guid": "1cc12c15-d680-4b73-b5b5-9235b4726ac6",
"url": "https://www.example.com/badusha-recipe"
}
]
optionals = {
configType: "create",
diag: "true"
}
hoppysearch.index(documents, optionals)
.then(res => {
console.log('statusCode:', res.status);
console.log('response text:', res.body);
})
.catch(err => {
console.log(err)
})
  1. In the documents array, add the document(s) you wish to add to your index. You can include as many documents as needed, following the provided format.
  2. In the optionals object:
    1. configType has two options:
      1. "create": This option will clear all data from the index and then add the data you provided.
      2. "append": This option won't clear existing data but will append the new data to the existing index.
    2. diag can be set to "true" if you wish to see extra diagnostics records or "false" if you don't need diagnostics records.

The second argument of hoppysearch.index is not mandatory. You can skip it entirely or skip specific key-value pairs according to your specific requirements.

By following these instructions, you can effectively add data to your HoppySearch index using the JavaScript/Node.js client.