This repository has been archived by the owner on Mar 24, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1
8‐ jsonverse API Documentation
Marco edited this page Sep 6, 2023
·
1 revision
- Description: Initializes a search index for a specific data set, allowing for efficient searching of data items based on specified options.
-
dataName
(String): The name of the data set for which the search index will be initialized. -
options
(Object): An object containing options for configuring the search index.
// Initialize a search index for the 'products' data set
jsonverse.initSearchIndex('products', {
keys: ['name', 'description'],
includeScore: true,
threshold: 0.6,
});
- Description: Searches for data items within a specific data set based on a given query.
-
dataName
(String): The name of the data set in which the search will be performed. -
query
(String): The search query to match against data items.
- An array of search results containing matched data items.
// Search for products with the query 'product'
const searchResults = jsonverse.searchData('products', 'product');
// Result example:
/*
[
{
item: {
id: '1',
name: 'Product A',
description: 'This is product A.',
},
score: 0.75, // Score indicating the match quality
},
// More matching items...
]
*/
Usage:
- Call
initSearchIndex
to initialize the search index for a specific data set. Provide the data set name and search options. - Use
searchData
to search for data items within the specified data set by providing a search query. - The function will return an array of search results containing matched data items, along with their associated scores.
Notes:
- The
initSearchIndex
function should be called once for each data set you want to enable searching for. - Adjust the search options, such as the keys (properties to search on) and threshold (match threshold), according to your search requirements.
- The
searchData
function allows for fuzzy searching, returning results based on the provided query and search options. - The search results include both the matched data item and a score indicating the match quality.