Nectar of the Programming Masses
    Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »


    ![]( | width=50)

    <img src=""width="100"/> sails-solr

    Provides easy access to solr from Sails.js & Waterline.

    This module is a Waterline/Sails adapter, an early implementation of a rapidly-developing, tool-agnostic data standard. Its goal is to provide a set of declarative interfaces, conventions, and best-practices for integrating with all sorts of data sources.

    The main goal is a simple usage and integration of a full managaged Solr.

    Build Status Coverage Status Dependency Status



    To install this adapter, run:

    $ npm install sails-solr

    Getting started with sails-solr

    To install/start solr if you not have one running

    make kickstart

    Note: not recommended for production systems! Solr installation Tomcat for more

    Configuring Connections

    Add the solr configuration to the config/connections.js file. The basic options are as follows:

    module.exports.connections = {
      solrConnectionOne: {
        module : 'sails-solr',
        host: 'localhost',
        port: 8983,
        core: 'schemaless',
        schema: true,
        migrate: 'drop'

    Note: you can define multiple solr connections/cores. By default sails-solr will run multiple models inside one core manageCores. Connection Options

    Configuring Models

    And then change default model configuration to the config/models.js:

    module.exports.models = {
      connection: 'solrConnectionOne',
      attributes: {

    Note: you can add more model based configuartion Model Options / Connection Options


    create a user:


    find a user:


    Note: See Waterline Documentation Query Language and Query Methods

    Special Adapter Interfaces


    search suggestion and spellchecked phrase. Known as "Did You Mean: foo?"

      // as sails request  see hooks and blueprint
      // http://localhost:1337/user/suggest/foa
      // in node
      User.suggest('foa', console);
      "responseHeader": {
        "status": 0,
        "QTime": 1
      "spellcheck": {
        "suggestions": [
            "numFound": 1,
            "startOffset": 0,
            "endOffset": 9,
            "origFreq": 0,
            "suggestion": [
                "word": "foo",
                "freq": 1
        "correctlySpelled": false,
        "collations": [
      "suggest": {
        "suggest": {
          "foa": {
            "numFound": 2,
            "suggestions": [
                "term": "foo",
                "weight": 0,
                "payload": ""
                "term": "foo bar",
                "weight": 0,
                "payload": ""

    Layerd Navigation

    Well known as filter. facet for strings and min,max,avg for ìnteger to build Options and Range Slider Elemets. Query Methods

      // as sails request  see hooks and blueprint
      // http://localhost:1337/user/catalog/?name="*"&limit=3&sort=age asc&skip=0
      // in node
          "sort":"percent asc",
      "facet_counts": {
        "facet_queries": {},
        "facet_fields": {
            "name": [
        "facet_dates": {},
        "facet_ranges": {},
        "facet_intervals": {},
        "facet_heatmaps": {}

    Supported Waterline Interfaces

    Type Methods Build
    Semantic create, createEach, find, count, update, destroy Build Status
    Migratable define, describe, drop, alter, addAttributes, remove, attributes, addIndex, removeIndex Build Status
    Queryable where, limit, sort, skip, select Build Status

    Note: See Waterline Documentation

    Special Adapter Interfaces

    Type Methods Build
    Suggest suggest. Return on Object with suggestions and spellecked the requestet term or phrase Build Status
    Catalog catalog. Return an Object with matching results and Layered Navigation as facet and stats Build Status

    Advanced Configuration

    Connection Options

    Params Default Description
    host 'localhost'
    port '8983'
    core 'schemaless'
    manageCores true create cores if not exists CoreAdmin
    schema true allow migrate drop, alter schema manage schema
    single false force manageCores to create a core for each model
    fieldTypeMap fieldTypes Field Type Map
    useFqParam true force query mapping as fq=name:foo param
    schemaDefaultFieldTypes {}
    debugAdapter false
    debugCollection false
    debugQuery false
    debugSolr false

    Model Options

      attributes: {
        first_name: {
          // Overwrite per Field
          schemaDefaultFieldAttributes: {
            indexed: true,
            type: 'text_de'
      // Overwrite per Model
      schemaDefaultFieldAttributes: {
        indexed: false

    Field Type Map

    The following table represents mappings between Sails/Waterline model data types and Solr field types:

    Sails/Waterline Type Solr Type
    string text_general
    text text_general
    binary text_general
    integer int
    float float
    date date
    time date
    datetime date
    boolean boolean
    binary text_general
    array text_general
    json text_general
    point point

    Note: You can even define your custom mapping as fieldTypeMap: inside connection settings and as model option. If you want a field type explicit mapping use fieldType as additional fieldTypeMapattribute

    Solr default field attributes

    The following table represents Solr field attributes:

    Solr Field Attributes Default
    name newField
    type text_general
    indexed true
    stored true
    docValues false
    sortMissingFirst false
    sortMissingLast false
    multiValued false
    omitNorms true
    omitTermFreqAndPositions false
    omitPositions false
    termVectors true
    termPositions false
    termOffsets false
    termPayloads false
    required false
    dynamicField false
    json text_general

    Note: You can even define your custom field attribute default as schemaDefaultFieldAttributes: inside connection settings and as model option. If you want a field attribute explicit you can add this attribute as an additional option inside the Model attribute settings

    Running the tests

    $ npm test


    • more test
    • documentation
    • cleanup and refactoring
    • build an e-commerce like demo application with autocomplete and layerd navigation

    More Resources




    npm i sails-solr

    Downloadsweekly downloads







    last publish


    • avatar