Subscribe to our list to receive the latest updates on Node on Fire

Class: SearchSystem

SearchSystem

new SearchSystem()

The search system module implements Model#search to allow you to do a full text search on your models.

To configure a model to be searchable, you need to create a search config.

Recipe.prototype.searchConfig = function() {
    return {
        lang: 'english',
        parser: function(searchText) {
            return searchText.split(' ').join(' & ');
        },
        properties: ['title', 'description']
    };
};

The search config method should return an object with the following keys:

properties: an array of property names as strings. Which properties to search through when searching. Required. lang: a string which is the language config passed to Postgres. Default value is english. parser: a function which takes one argument, the search text, and transforms it to a Postgres search query.

Do you have any questions or comments on this page? Start a discussion below.

comments powered by Disqus
Subscribe to our list to receive the latest updates on Node on Fire