Gathering detailed insights and metrics for data-search
Gathering detailed insights and metrics for data-search
Gathering detailed insights and metrics for data-search
Gathering detailed insights and metrics for data-search
functional-red-black-tree
A fully persistent balanced binary search tree
@redis/search
This package provides support for the [RediSearch](https://redis.io/docs/interact/search-and-query/) module, which adds indexing and querying support for data stored in Redis Hashes or as JSON documents with the [RedisJSON](https://redis.io/docs/data-type
tavily-mcp
MCP server for advanced web search using Tavily
@sitecore-search/data
Data Sitecore Search SDK
npm install data-search
Typescript
Module System
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
This is a library that aims to perform a search for data in an array of objects. The parameter for such a search is a manual search for a user in a search bar.
The first step is to generate the data set.
To generate the data set it is necessary to pass an object with some attributes.
I call this object: 'main'.
{
array : [{}]
// array of objects (the id field must exist on each object)..
wordSize : number
// size of the words you want to filter.
nameId : string
// name of the object ID field.
attributes: [string]
// name of the attributes you want to filter in array format.
ignoreInTags: [string]
// The tags ignore any words in the object that look like any words in this array.
}
dataSetGenerate(main)
Code:
const myArray = [{
id: 1,
title: 'Lord of the Rings',
genre: 'ADVENTURE'
},
{
id: 2,
title: 'Fury',
genre: 'WAR'
}
]
const result = dataSetGenerate({
array: myArray,
wordSize: 2,
nameId: 'id',
attributes: ['title', 'genre']
})
console.log(result)
Output:
[
{
id: 1,
title: 'Lord of the Rings',
genre: 'ADVENTURE',
totalSearchesFound: 0,
tags: [ 'lord', 'of', 'the', 'rings', 'adventure' ]
},
{
id: 2,
title: 'Fury',
genre: 'WAR',
totalSearchesFound: 0,
tags: [ 'fury', 'war' ]
}
]
Code
const myArray = [{
id: 1,
title: 'Lord of the Rings',
genre: 'ADVENTURE'
}]
const result = dataSetGenerate({
array: myArray,
attributes: ['title', 'genre'],
ignoreInTags: ['rings', 'lord']
})
console.log(result)
Output
[
{
id: 1,
title: 'Lord of the Rings',
genre: 'ADVENTURE',
totalSearchesFound: 0,
tags: [ 'of', 'the', 'adventure' ]
}
]
{
_array : [{}]
// array with the generated objects..
createdAt : Date
// Data set creation date.
array: [Getter/Setter]
// getters and setters for the array
}
Code:
const info = getDataset();
console.log(info);
Output:
{
_array: [
{
id: 1,
title: 'Lord of the Rings',
genre: 'ADVENTURE',
totalSearchesFound: 0,
tags: [Array]
},
{
id: 2,
title: 'Fury',
genre: 'WAR',
totalSearchesFound: 0,
tags: [Array]
}
],
createdAt: 2020-10-21T13:13:05.238Z,
array: [Getter/Setter]
}
The second step is to use the search function.
So let's say you want to search for one of those objects. For this you type a text in the search function, this search can result in the return of one or more objects.
search(datasetArray, input, all, filterByValue)
For this, in each search function call it is appropriate to pass in the:
It is not necessary to pass the other parameters, but if necessary, in the:
IMPORTANT: The result of this function (datasetGenerate) will always be an array of objects.
Code:
const myArray = [{
id: 1,
title: 'Lord of the Rings',
genre: 'ADVENTURE'
},
{
id: 2,
title: 'Fury',
genre: 'WAR'
}
]
const datasetResult = dataSetGenerate({
array: myArray,
attributes: ['title', 'genre']
})
const result2 = search(datasetResult, 'I want to watch fury');
console.log(result2);
Output:
{
message: 'OK',
result: [
{
id: 2,
title: 'Fury',
genre: 'WAR'
}
]
}
It is possible to define that everything generated by the dataset is returned when nothing is found. The 'all' parameter is of the boolean type so when it is:
IMPORTANT: It is not necessary to pass this parameter 'all' if you don't want to, it will always be false if it is not passed true.
Code:
console.log(search(datasetResult, 'comedy', true));
Output:
{
message: 'NOT_FOUND',
result: [
{ id: 1, title: 'Lord of the Rings', genre: 'ADVENTURE' },
{ id: 2, title: 'Fury', genre: 'WAR' }
]
}
It is used when an object does not have enough information to be returned by the first parameter of the search function, but it needs to be returned, because the object has an attribute and this attribute has the necessary value for the return.
Code:
const myArray = [{
id: 1,
title: 'Lord of the Rings',
genre: 'ADVENTURE'
},
{
id: 2,
title: 'Fury',
genre: 'WAR'
}
]
const datasetResult = dataSetGenerate({
array: myArray,
attributes: ['title', 'genre']
})
console.log(search(datasetResult,'fury war adventure'));
Output:
{
message: 'OK',
result: [
{
id: 2,
title: 'Fury',
genre: 'WAR'
}
]
}
Note that the return will only be from the object with id 2, this happens because the object with id 2 has more information that matches what you are looking for. However, if you still think that the function should return the object with id 1 because the object contains 'adventure' and you also typed 'adventure' in the search, then, you must tell the search what is the value that the search should always bring, whenever the search function finds a value that matches exactly what you typed, this object will be returned along with the others:
Code: in the fourth parameter of the search() function put the name of the present value inside the attribute
console.log(search(datasetResult,'fury war adventure', false, 'adventure'));
Output:
{
message: 'OK',
result: [
{ id: 2, title: 'Fury', genre: 'WAR' },
{ id: 1, title: 'Lord of the Rings', genre: 'ADVENTURE' }
]
}
Now note that both objects have been returned. Even if the first object does not have all the information you typed in, it still has 'ADVENTURE' in the 'genre' so now it is returned.
const res = 'lords ring';
search(datasetResult, res, false, 'war');
Code:
const obj = [{
id: 1,
title: 'Lord of the Rings',
genre: 'ADVENTURE'
},
{
id: 2,
title: 'Fury',
genre: 'WAR'
}
]
const dataSetResult = dataSetGenerate({
array: obj,
attributes: ['title', 'genre']
});
console.log(search(dataSetResult, 'fu'));
Output:
[]
Code:
setSearchDistance(0.60, 0.90);
console.log(search(dataSetResult, 'fu'));
Output:
{
message: 'OK',
result: [
{
id: 2,
title: 'Fury',
genre: 'WAR'
}
]
}
[Recommended] - For a more accurate search, i recommend using 'max' as being greater than 8, and working on 'min' with values between 2 to 7.5.
Code:
console.log(getSearchDistance());
Output:
{ min: 0.3, max: 0.85 }
Code:
getLatestSearchedIds();
Code:
{ ids: [ 2 ] }
Working on sorting and new functions to facilitate the search for objects.
No vulnerabilities found.
No security vulnerabilities found.