Giter Site home page Giter Site logo

algoliasearch-client-node's Introduction

deprecated

This repository previously hosted the AlgoliaSearch node.js client (named algolia-search in npm).

We recently released a new JavaScript client that can be used with Node.js and the browser.

If you want to upgrade to the new version, read the migration guide.

You can still use the 1.x.x version of the algolia-search, the readme is in the V1 branch.

algoliasearch-client-node's People

Contributors

bobylito avatar darkhogg avatar dessaigne avatar fulmicoton avatar jbpionnier avatar jrmgx avatar lperrin avatar peterdavehello avatar redox avatar seafoox avatar speedblue avatar vvo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

algoliasearch-client-node's Issues

deleteByQuery crashes if the callback is null

If no callback is specified, then the function crashes.

algolia-search\algoliasearch-node.js:723
callback(false, {});
^
TypeError: undefined is not a function
at algolia-search\algoliasearch-node.js:723:19
at _jsonRequest.callback (algolia-search\algoliasearch-node.js:346:21)
at opts.callback algolia-search\algoliasearch-node.js:374:21)
at IncomingMessage. (algolia-search\algoliasearch-node.js:488:1
3)
at IncomingMessage.g (events.js:180:16)
at IncomingMessage.emit (events.js:117:20)
at _stream_readable.js:929:16
at process._tickCallback (node.js:419:13)

It should work since the callback argument is documented as being optional.

deleteObject() deleted whole index

image

algoliasearch-node.js:589
There is a check for (objectID.length === 0), then the objectID should be an array,
but the index was deleted completely after this call,
rather than deleting a single object

Unhandled exception thrown by JSON.parse

I've been occasionally getting the following exception from the JSON.parse call in _jsonRequestByHost_do, on v1.5.11:

SyntaxError: Unexpected end of input
  at Object.parse (native)
  at IncomingMessage.<anonymous> (/app/node_modules/algolia-search/algoliasearch-node.js:484:29)
  at IncomingMessage.g (events.js:180:16)
  at IncomingMessage.emit (events.js:117:20)
  at _stream_readable.js:943:16
  at /app/node_modules/newrelic/node_modules/continuation-local-storage/node_modules/async-listener/glue.js:177:31
  at process._tickCallback (node.js:419:13)

Non-standard callbacks

The client passes (success, response) to the final callback, while other node.js modules usually pass (error, response). This makes it unnecessarily complicated to integrate with modules like async, which bail out when the first parameter is not falsy.

Would you accept a pull request to fix that ?

Query not properly escaped

While writing the tests, I realized, that you were not escaping the query. https gets something like:

path: '/1/indexes/cities?query=loz anqel',

While I would expect:

path: '/1/indexes/cities?query=loz%20anqel',

I don't remember that https does it for you, but I can't verify it without setting up a mitm proxy.

Better Node.JS conventions for errors

Hi,

It seems most methods from this module are behaving this way:

index.saveObject(obj, cb);

function cb(err, res) {
  // success: err = falsy, res = algoliasearch response
  // error: err = truthy, res = actual Error object
}

While in Node.JS, most of the modules, including core API, will do it this way:

index.saveObject(obj, cb);

function cb(err, res) {
  // success: err = falsy, res = algoliasearch response
  // error: err = Error object, res = undefined
}

There are many reasons to do it the Node.JS way like not messing up with Node.JS developers interested in your product and showing them you know Node.JS!

But another interesting usecase is that algoliasearch-client-node would be Promiseable.

Promises are a great way to handle asynchronous flow control in JavaScript and will be the de-facto way to handle complex asynchronous code very soon for most JavaScript developers.

Right now we cannot easily wrap algoliasearch-client-node with Promises because the error object.

Using https://github.com/then/promise which is a Promise polyfill we should be able to:

var saveObject = Promise.denodeify(index.saveObject.bind(index));

saveObject(obj)
  .then(fn) // then called when everything is ok
  .catch(fn) // catch called when first param is an Error object

At the moment, doing this will result in having catch called with "true" and you can't have any other info on the error.

Note that my usecase is not the point, following Node.JS conventions on errors is the point.

Thanks

Allow to turn off error logging

As every error that happens is passed to a callback at some point, it's possible to handle every error. I'm personally using a logging framework (winston) to log errors, so console.log logging by Algolia is nothing but noise.

Please either add an option to turn logging off completely or allow for custom handling of error logging.

Batch is broken.

I just saw this commit: 69b09fa, _batch is called with 4 parameters.

But in the current implementation:
https://github.com/algolia/algoliasearch-client-node/blob/V1/src/algoliasearch-node.js#L1350

_batch: function(objects, action, callback) {
  var postObj = {requests:[]};
  for (var i = 0; i < objects.length; ++i) {
    var request = { action: action,
    body: objects[i] };
    if (!_.isUndefined(objects[i].objectID)) {
      request.objectID = objects[i].objectID;
    }
    postObj.requests.push(request);
  }
  this.as._request('POST', '/1/indexes/' + encodeURIComponent(this.indexName) + '/batch', postObj, 'write', callback);
},

Batch is accepting just 3 parameters. This gives me TypeError: string is not a function when I try to call the function that use _batch. Are you guys are on the ongoing of new implementation?

Sorry for my English :).

JSON.parse wrap by try catch

I'm using the module and 1 response from algolia triggered:

SyntaxError: Unexpected end of input at Object.parse (native) at IncomingMessage.<anonymous> (/node_modules/algolia-search/algoliasearch-node.js:422:29) at IncomingMessage.g (events.js:180:16) at

At line 465 and line 484, better wrap with try catch and handle the error gracefully

Request return whereas task is not finished

Hey there, I'm not sure this is a bug, I'm using latest 1.7.5.

When I try to call saveObject, the request return whereas the data is not saved yet into algolia. This means if I refresh my data, it still shows the old value whereas I received a confirm, I have to wait for about 5 seconds before the new value shows up.

algoliaanalytics-node is not found in the npm registry -- Error

I am trying to use the algolia seach capability in my meteor app and was able to add the meteor-search package from atmosphere (acemtp:algolia). All is well when i run the project locally.

The issue occurs when i try to deploy the app on Modulus. It has a dependency on the algoliaanalytics-node and wants the author to publish to npm registry.

Do you have any work around as in can i install the algolia-search locally and deploy them without the algoliaanalytics-node dependency...

Any help with this is greatly appreciated. :)

Method Parameter Ordering

Is there a reason why there is a non-standard ordering of parameters for the algolia.addObject() function? What I mean is that generally callback functions appear last in the list of parameters for readability's sake, and it is the middle parameter in this function call. Is this a change that is possible to make?

saveObject problem

When I call saveObject (without passing objectID) I'd expect the entity to be created per documentation. But a PUT call is being made:
/1/indexes/dev_CHANNELS/undefined

My code:

function indexChannel(channel, callback) {
  var index = client.initIndex(prefix+'_CHANNELS');
  var indexedObj = {
    _id : channel._id,
    name : channel.name,
    thumb50x50 : channel.thumbnails && channel.thumbnails.small50x50.url,
    urlName : channel.urlName,
    subscribers : channel.statistics.subscribers,

  };

  if(channel.indexObjectId) {
    indexedObj.objectID = channel.indexObjectId;
  }
  console.log(indexedObj);

  index.saveObject(indexedObj, function(err, content) {
    if(err) {
      logger.error(err);
    }
    console.log(content);
    callback(err, content);
  });
}

API to get object ids from task id

I am using this API to get the status of my task but in case if some tasks are completed means status is not completed then i want to update those objects present in that task ids

currently what i observed for around 1700 objects its created 2 task ids, and for 16K objects its creating 17 task ids
so if some of the tasks are not completed successfully i want to get objects from those tasks and update again

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.