The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/packages/rocketchat-search
Marcos Spessatto Defendi 3b7de77634 Remove /* globals */ wave 3 (#12997) 7 years ago
..
client Remove /* globals */ wave 3 (#12997) 7 years ago
server Remove /* globals */ wave 3 (#12997) 7 years ago
README.md [NEW] Add Search Provider Framework (#10110) 7 years ago
package.js Revert imports of css, reAdd them to the addFiles function (#12934) 7 years ago

README.md

This module enables search for messages and other things within Rocket.Chat. It provides the basic infrastructure for Search Providers, which enables everybody to easily add another search (e.g. with special functions) to the Rocket.Chat infrastructure. In addition it provides a defautl implementation based on MongoDB.

Providers

A new Provider just extends the provider class and registers itself in the SearchProviderService.

class MyProvider extends SearchProvider {
	constructor() {
		super('myProvider'); //a unique id for the provider
	};
	
	search(text, context, payload, callback) {
		//do some search and call the callback with the result
	};
}

searchProviderService.register(new MyProvider());

Settings

In order to enable Settings within the admin UI for your own provider, you can add it (e.g. in the constructor).

this._settings.add('PageSize', 'int', 15, {
			i18nLabel: 'Search_Page_Size'
		});

The setting values are loaded, when you use your provider. The values can be easily accessed.

this._settings.get('PageSize')

Search UI

Search provider can have their own result template. The template is loaded with data.

{
 searching, //reactive var if search results are loading
 result, //reactive var with the result 
 text, //reactive var with the search text
 settings //the settings of the provider,
 parentPayload, //the main search payload (not reset for new searches)
 payload, //the payload (reseted when new search is issed from search field)
 search //the search function
}

Search Result

In order to provide a proper validation of the results the search function of the provider must follow at the following (extendable) format:

{
  message: {
    docs:[{_id},...]
  },
  room: {
    docs:[{_id},...]
  },
  user: {
    docs:[{_id},...]
  }
}