Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
full-text-search-light
Advanced tools
Readme
Full Text Search Light is a pure JS full text search engine with an ultrafast search and the following commands:
You can add every kind of data, also complex objects.
npm install full-text-search-light
npm install git+https://github.com/frankred/node-full-text-search-light.git
var fulltextsearchlight = require('full-text-search-light');
var search = new fulltextsearchlight();
You can also change some configuration values according to the full text search.
var fulltextsearchlight = require('full-text-search-light');
var search = new fulltextsearchlight({
ignore_case: false, // default = true, Ignore case during all search queries
index_amount: 8; // default = 12, The more indexes you have, the faster can be your search but the slower the 'add' method gets
});
// Add values
search.add('Peter');
search.add('Paul');
search.add('Maria');
You can also add objects or arrays to the search. Every child value will be added to the search, no matter if it's an array or object.
// Add objects
var obj = {
name: 'Alexandra',
age: 27,
student: true,
hobbies: ['Tennis', 'Football', 'Party'];
car: {
make: 'Volvo',
year: 2012,
topspeed: 280
}
};
search.add(obj);
If you want to ignore fields you can pass a filter function. If you want to ignore a field or value just return false
. If you return true
or everything else the field is added to the index.
// Add filter, this function will be called on every single field
// If you don't want to add a field to the search just return false
var filter = function (key, val) {
// Return false if you want to ignore field
if (key == 'student' || key == 'topspeed') {
return false; // Ignore field
}
return true; // Accept field
};
search.add(obj, filter);
var results = search.search('p');
// results = ['Peter', 'Paul']
You can remove objects or values out of the search by saving the id
which is returned from the add
method.
// Add returns an id
var f = search.add("Frank");
// With that id you can remove the value from the search
search.remove(f);
// Returns an array with all result objects
var result = search.search('pau');
// result: ['Paul']
var fulltextsearchlight = require('full-text-search-light');
var search = new fulltextsearchlight();
// Add
search.add('Hello World');
// Save current db
search.save('search.json', function(error){
// Load db
fulltextsearchlight.load('search.json', function(error, search_loaded){
var results = search_loaded.search('World');
});
});
var fulltextsearchlight = require('full-text-search-light');
var search = new fulltextsearchlight();
// Add
search.add('Hello World');
// Save current db
search.saveSync('search.json');
// Load db
var search_loaded = fulltextsearchlight.loadSync('search.json');
var results = search_loaded.search('World');
This are all functions that can be used.
search.add('Just a string value')
- Add a string to the search, returns a unique idsearch.add(obj)
- Add a object to the search, returns a unique idIf you add numbers or booleans to the search they will be converted to strings.
search.add(false)
- Add booelan to the search (ok this does not really make sense, but it works.), returns a unique idsearch.add(42)
- Add number to the search, returns a unique idsearch.search('value')
- Search for the string 'value'. Returns the results of the data as an arraysearch.remove(1337)
- Remove the data with the id 1337 from the search. This id was returned by adding a value or obj.search.drop()
- Drops the search database and resets all data. The configuration is kept.search.saveSync('path/to/file.json')
- Save current search db to a json file.fulltextsearchlight.loadSync('path/to/file.json')
- Load a search from a file;You need mocha installed globally:
npm install -g mocha
Now you can run tests if you navigate to project root:
mocha test
##License MIT Free Software, Hell Yeah!
FAQs
A pure in JS written full text search with an easy to use API.
The npm package full-text-search-light receives a total of 401 weekly downloads. As such, full-text-search-light popularity was classified as not popular.
We found that full-text-search-light demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.