Reputation: 20242
I am trying to confirm whether faceted search is available via node-solr or not. Has anyone used the Solr functionality with nodejs and if so, can you kindly point to an online resource/share sample code that displays the functionality.
Thanks
Upvotes: 5
Views: 1502
Reputation: 712
Even though I couldn't find it in their official documentation- this is what got working for me.
var client = sails.solr;
var query = client.createQuery().q({
'city_id': options.city_id,
'content_auto': options.term,
})
.fl('sku')
.start(0)
.rows(2000)
.facet({'field':'brand'})
.facet({'field':'price'})
.facet({'field':'discount_percentage'})
.facet({'field':'pack_size'})
.facet({'field':'categories'})
var defer = sails.Q.defer();
client.search(query, function(err, obj){
if(err) {
console.log('Error getting data from solr. Error: ' + err);
return defer.reject(err);
}
return defer.resolve(obj);
});
return defer.promise;
Obviously- stumbled across it by good'ol trial and error!
Upvotes: 4
Reputation: 1418
Yeah, there is not very much documentation on this at all for node. You can find bushels of examples and tutorials for solr with java, python, or php, but bloggers the people on the node/end-to-end js train seem pretty quiet. I recommend solr-client. Follow the link on the README as well and the guy has about a dozen simple use examples.
Upvotes: 3