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.
## helios.queryBuilder
### init
```js
var queryBuilder = new Helios.queryBuilder();
```
### methods
All the methods can be used together and can be get as a combined query string by using the `toString()` method
simpleQuery
queryBuilder.simpleQuery({
op : 'OR',
df : 'field_name',
q : 'keyword1 keyword2'
})
facetQuery
queryBuilder.facetQuery({
'facet' : 'true',
'facet.date' : 'timestamp',
'facet.date.start' : 'NOW/DAY-5DAYS',
'facet.date.end' : 'NOW/DAY+1DAY',
'facet.date.gap' : '+1DAY'
});
toString
It just returns the query you have made as a string
## 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
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