Services:SearchService
From MacroDeckDevWiki
SearchService will provide tag, description, and title searching. It will be very generic, and able to accept almost every possible data type (Widget, DataItem, DataGroup, etc.).
Contents |
Planned Usage
SearchService.search(items, term)
This method will search through items and return the items which match the criteria.
- items is any ActiveRecord group of objects. Basically, anything that can be returned from DataGroup.find, DataItem.find, Widget.find, and so on.
- term is the search term. This may be several words, a bunch of words, stuff with operators, etc.
We will return the items matching in an Array of Hashes that looks like this:
[
{
:item => ActiveRecordObject,
:relevance => 100.0,
:metadata => MetadataHash
}
]
There either should be some way to figure out what kind of result it is (data group, data item, or file from StorageService?) or separate functions for each.
Operators
Standard search operators will be supported. This means AND and OR basically.
Relevance
Relevance will be decided based on how close the title matches the search term. Optionally, an implementer may also figure some other algorithm out that takes the description into account (this is the preferred method, but title-based relevance is enough).

