Well, this is a little neater version of the already available nodejs-solr clients.
I figured out that a lot of problems lies in creating queries and documents.
The powerful thing of this library would be the queryBuilder
& document
class.
NOTES: Use 'set' when you want to update a field value and use 'add' for add a value to multivalue fields.
## helios.document
This class will ease the steps required to make a document to be added to solr.
init
var solr_doc = new helios.document();
methods
getBoost()
This returns the document
's boost
setBoost
This sets the document
's boost to a given float
solr_doc.setBoost(2.112);
setMultiValue
It accepts the following arguments:
field_name
value
the value of the field_name
boost
the boost to be set for field_name
This method is helpful in adding values to a multi=true
field
solr_doc.setMultiValue('field_name', 'value1', 2);
solr_doc.setMultiValue('field_name', 'value2', 1.5);
note that adding boost every time in the setMultiValue
for the same field_name
actually results in a compound
value which is the multiplication of the boosts added
eg. for the above case: 2 * 1.5 = 3
getField
This method returns the value set for field_name
solr_doc.getField('field_name');
setField
This methods adds field_name
whose value is value
and boost is boost
.
solr_doc.setField('field_name1', 'value1', 1.21);
solr_doc.setField('field_name2', 2121);
getFieldBoost
This method returns the boost of field_name
solr_doc.getFieldBoost("field_name");
setFieldBoost
This method sets the boost for field name field_name
solr_doc.setFieldBoost('field_name', 2.121);
getFieldBoosts
Returns a key-value object of all the fields and their boosts
getFieldUpdate - For Solr 4.x
This method returns the update type ('set' or 'add') of field_name
solr_doc.getFieldUpdate("field_name");
setFieldUpdate - For Solr 4.x
This method sets the update type ('set' or 'add') for field name field_name
solr_doc.setFieldUpdate('field_name', 'set');
getFieldUpdates - For Solr 4.x
Returns a key-value object of all the fields and their update types
getFieldDelete - For Solr 4.x
This method returns the delete setup for a field_name
solr_doc.getFieldDelete("field_name");
setFieldDelete - For Solr 4.x
This method sets the field name field_name
to delete from the Solr doc
solr_doc.setFieldDelete('field_name');
getFieldDeletes - For Solr 4.x
Returns a key-value object of all the fields to delete from the Solr doc
clear
This clears the all the fields
, fieldBoosts
as well as the documentBoost
toXML
This method converts the current helios.document
into a solr readable XML
solr_doc.toXML();
Issues