Socket
Socket
Sign inDemoInstall

algoliasearch-helper

Package Overview
Dependencies
Maintainers
3
Versions
146
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

algoliasearch-helper - npm Package Compare versions

Comparing version 2.0.0-rc4 to 2.0.0-rc5

2

index.js

@@ -21,4 +21,4 @@ /**

*/
helper.version = "2.0.0-rc4";
helper.version = "2.0.0-rc5";
module.exports = helper;
{
"name": "algoliasearch-helper",
"version": "2.0.0-rc4",
"version": "2.0.0-rc5",
"description": "Helper for implementing advanced search features with algolia",

@@ -30,3 +30,3 @@ "main": "index.js",

"devDependencies": {
"algoliasearch": "git://github.com/algolia/algoliasearch-client-js.git#cb15a53b55e64c96f9a1d5a95b50478d153a187c",
"algoliasearch": ">= 3.1",
"browserify": "9.0.3",

@@ -49,3 +49,6 @@ "bulk-require": "0.2.1",

"lodash": "3.5.0"
},
"peerDependencies": {
"algoliasearch" : ">= 3.1 < 4"
}
}

@@ -232,2 +232,3 @@ "use strict";

this.index = name;
this.setCurrentPage( 0 );
return this;

@@ -254,3 +255,9 @@ };

AlgoliaSearchHelper.prototype.isRefined = function( facet, value ) {
return this.state.isFacetRefined( facet, value );
if( this.state.facets.indexOf( facet ) > -1 ) {
return this.state.isFacetRefined( facet, value );
}
else if( this.state.disjunctiveFacets.indexOf( facet ) > -1 ) {
return this.state.isDisjunctiveFacetRefined( facet, value );
}
return false;
};

@@ -301,14 +308,21 @@

var state = this.state;
var queries = [];
this.client.startQueriesBatch();
//One query for the hits
this.client.addQueryInBatch( this.index, state.query, this._getHitsSearchParams() );
queries.push( {
indexName : this.index,
query : state.query,
params : this._getHitsSearchParams()
} );
//One for each disjunctive facets
forEach( state.getRefinedDisjunctiveFacets(), function( refinedFacet ) {
this.client.addQueryInBatch( this.index, state.query, this._getDisjunctiveFacetSearchParams( refinedFacet ) );
queries.push( {
indexName : this.index,
query : state.query,
params : this._getDisjunctiveFacetSearchParams( refinedFacet )
} );
}, this );
this.client.sendQueriesBatch( bind( this._handleResponse, this, state ) );
this.client.search( queries, bind( this._handleResponse, this, state ) );
};

@@ -369,3 +383,3 @@

var facetFilters = this._getFacetFilters( facet );
var numericFilters = this._getNumericFilters();
var numericFilters = this._getNumericFilters( facet );
var additionalParams = {

@@ -398,7 +412,9 @@ hitsPerPage : 1,

*/
AlgoliaSearchHelper.prototype._getNumericFilters = function() {
AlgoliaSearchHelper.prototype._getNumericFilters = function( facetName ) {
var numericFilters = [];
forEach( this.state.numericRefinements, function( operators, attribute ) {
forEach( operators, function( value, operator ) {
numericFilters.push( attribute + operator + value );
if( facetName !== attribute ) {
numericFilters.push( attribute + operator + value );
}
} );

@@ -405,0 +421,0 @@ } );

"use strict";
var keys = require( "lodash/object/keys" );
var intersection = require( "lodash/array/intersection" );
var forEach = require( "lodash/collection/forEach" );

@@ -224,2 +225,11 @@ var reduce = require( "lodash/collection/reduce" );

/**
* Return the current refinement for the ( attribute, operator )
* @param {string} attribute of the record
* @param {string} operator applied
* @return {number} value of the refinement
*/
getNumericRefinement : function( attribute, operator ){
return this.numericRefinements[ attribute ] && this.numericRefinements[ attribute ][ operator ];
},
/**
* Clear numeric filters.

@@ -480,3 +490,7 @@ * @method

getRefinedDisjunctiveFacets : function getRefinedDisjunctiveFacets() {
return keys( this.disjunctiveFacetsRefinements );
var disjunctiveNumericRefinedFacets = intersection(
keys( this.numericRefinements ),
this.disjunctiveFacets
);
return keys( this.disjunctiveFacetsRefinements ).concat( disjunctiveNumericRefinedFacets );
},

@@ -483,0 +497,0 @@ /**

"use strict";
var forEach = require( "lodash/collection/forEach" );
var compact = require( "lodash/array/compact" );
var find = require( "lodash/collection/find" );
/**
* @typedef Facet
* @type {object}
* @property {string} name name of the attribute in the record
* @property {object.<string, number>} data the facetting data : value, number of entries
* @property {object} stats undefined unless facet_stats is retrieved from algolia
*/
function getIndices( obj ) {

@@ -160,4 +169,17 @@ var indices = {};

this.disjunctiveFacets = compact( this.disjunctiveFacets );
this._state = state;
};
/**
* Get a facet object with its name
* @param {string} name name of the attribute facetted
* @return {Facet} the facet object
*/
SearchResults.prototype.getFacetByName = function( name ) {
var isName = function( facet ) { return facet.name === name; };
var indexInFacets = find( this.facets, isName );
return indexInFacets || find( this.disjunctiveFacets, isName );
};
module.exports = SearchResults;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc