Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
algoliasearch-helper
Advanced tools
The `algoliasearch-helper` package is a JavaScript library that provides a set of tools to manage search parameters and results when using Algolia's search API. It helps in building complex search interfaces by offering functionalities like managing search states, refining search queries, and handling pagination.
Managing Search Parameters
This feature allows you to manage search parameters such as facets and disjunctive facets. The code sample demonstrates how to initialize the helper with specific facets and add a facet refinement to filter search results.
const algoliasearch = require('algoliasearch');
const algoliasearchHelper = require('algoliasearch-helper');
const client = algoliasearch('YourApplicationID', 'YourAdminAPIKey');
const index = client.initIndex('your_index_name');
const helper = algoliasearchHelper(client, 'your_index_name', {
facets: ['category'],
disjunctiveFacets: ['brand']
});
helper.addFacetRefinement('category', 'Books').search();
Handling Pagination
This feature helps in handling pagination of search results. The code sample shows how to set the page number and listen for the search results.
helper.setPage(2).search();
helper.on('result', function(content) {
console.log(content.hits);
});
Refining Search Queries
This feature allows you to refine search queries. The code sample demonstrates how to set a search query and listen for the search results.
helper.setQuery('Harry Potter').search();
helper.on('result', function(content) {
console.log(content.hits);
});
Managing Search States
This feature allows you to manage the search state. The code sample shows how to get the current search state and set a new search state.
const state = helper.getState();
console.log(state);
helper.setState({
query: 'Harry Potter',
page: 1
}).search();
Elasticlunr.js is a lightweight full-text search engine developed in JavaScript for browser search and offline search. It provides functionalities similar to Algolia but is more suited for smaller datasets and offline use cases.
Lunr.js is a small, full-text search library for use in the browser and Node.js. It offers functionalities for indexing and searching documents, similar to Algolia, but is designed for smaller datasets and does not require a server.
Search-index is a powerful search engine for Node.js that allows you to index and search documents. It provides similar functionalities to Algolia but is more flexible and can be used for a variety of search use cases.
This module is the companion of the algoliasearch-client-js. It helps you keep track of the search parameters and provides a higher level API.
The helper is built on top of algoliasearch-client-js and this version is specifically made to work with the newest V3 versions of it.
A small example that uses Browserify to manage modules.
var algoliasearch = require( "algoliasearch" );
var algoliasearchHelper = require( "algoliasearch-helper" );
var client = algoliasearch( "app_id", "secret" );
var helper = algoliasearchHelper( client, "myMainIndex", {
facets : [ "mainCharacterFirstName", "year" ],
disjunctiveFacets : [ "director" ]
});
helper.on( "result", function( data ){
console.log( data.hits );
} );
helper.addDisjunctiveRefine( "director", "Clint Eastword" );
helper.addDisjunctiveRefine( "director", "Sofia Coppola" );
helper.addRefine( "year", "2003" );
// Search for any movie filmed in 2003 and directed by either C. Eastwood or S. Coppola
helper.search( "" );
(See the examples in action)[http://algolia.github.io/algoliasearch-helper-js/]
npm install algoliasearch-helper
Include this in your page :
<script src="//cdn.jsdelivr.net/algoliasearch.helper/2.0.0-rc1/algoliasearch.helper.min.js"></script>
git clone https://github.com/[your-handle-here]/algoliasearch-helper-js.git
npm run dev
npm run lint
A quick note though, even though we'll make our best to read and integrate your PR, we may be a bit slow. Sorry :). We might also make some comments and discussions too, for the best interest of this library. Thanks in advance for your contribution!
FAQs
Helper for implementing advanced search features with algolia
The npm package algoliasearch-helper receives a total of 820,777 weekly downloads. As such, algoliasearch-helper popularity was classified as popular.
We found that algoliasearch-helper demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 5 open source maintainers 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
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.