Class: SearchableData

SearchableData

Makes an array of objects searchable

Constructor

new SearchableData(options)

Parameters:
Name Type Description
options Object SearchableData expects these properties:
Properties
Name Type Description
data object Array of data or a function that returns an array of data.
searchProperties Array.<string> Array of property names in the data array to search in. If not added, all properties will be used
displaynameProperty string The name of the property in the data array that should be used as displayname
descriptionProperty string The name of the property in the data array that should be used as description
useAND boolean Use AND and not OR when multiple terms is added by the user. Default true
Source:

Members

data

Array of data or a function that returns an array of data. If data is a function it will be called each time fetchData is called. This way the client could change the data on the fly and not keep them static. This could be used when adding an external filter.
Source:

descriptionProperty

The name of the property in the data array that should be used as description.
Source:

displaynameProperty

The name of the property in the data array that should be used as displayname.
Source:

plural

Plural phrase, eg.: "features"
Source:

searchProperties

Array of property names in the data array to search in. If not added, all properties will be used
Source:

singular

Singular phrase, eg.: "feature"
Source:

useAND

Use AND and not OR when multiple terms is added by the user. Set to false to use OR
Source:

Methods

getDescription() → {String}

Used for getting the description
Source:
Returns:
Type
String

getDisplayname() → {String}

Used for getting the displayname
Source:
Returns:
Type
String

getScore() → {Integer}

Get the score for a single string
Source:
Returns:
Type
Integer

match() → {Integer}

Method that defines what to search in
Source:
Returns:
Type
Integer