Class: Indexer

Indexer()

new Indexer()

Represents an Indexer instance
Do not call constructor directly.
Source:
See:

Methods

clear(entity) → {Object}

clear all documents in an entity
Parameters:
Name Type Description
entity string entity name
Source:
Returns:
[result] - document getting re-indexed
Type
Object
Example
api.indexer (request).clear ('Orders');
	  
	  

create(entity, definiton) → {Object}

create a type with a mapping data definition
Parameters:
Name Type Description
entity string entity name
definiton Object mapping definiton
Source:
Returns:
[result] - entity created
Type
Object
Example
api.indexer (request).create ('Orders', {
	    properties: {
	        description: {
	            type: 'text',
	            fields: {
	                keyword: {
	                    type: 'keyword'
	                }
	            }
	        },
	        price: {
	            type: 'double'
	        }
	    }
	  });
	  

delete(entity, id) → {Object}

delete a document by id
Parameters:
Name Type Description
entity string entity name
id string document id
Source:
Returns:
[result] - delete feedback
Type
Object
Example
api.indexer (request).delete ('Orders', '123456789');
	  
	  

get(entity, id) → {Object}

get a document by id
Parameters:
Name Type Description
entity string entity name
id string document id
Source:
Returns:
[result] - document data
Type
Object
Example
api.indexer (request).get ('Order', '123456789');
	  
	  

put(entity, doc) → {Object}

put/index a document
Parameters:
Name Type Description
entity string entity name
doc Object document
Source:
Returns:
[result] - document getting indexed
Type
Object
Example
api.indexer (request).put ('Orders', {
	  	id: '123456789',
	  	customer: 'john@bluenimble.com',
	  	price: 400,
	  	date: '2014/10/09T08:33:50'
	  });
	  
search documents by query
Parameters:
Name Type Attributes Description
query Object query
entities Array <optional>
array of entities names
Source:
Returns:
[result] - delete feedback
Type
Object
Example
api.indexer (request).search ({
	  	term: { price : '400' }
	  }, [
	  	'Orders'
	  ]);
	  
	  // search in all entities
	  api.indexer (request).search ({
	  	term: { customer: 'john@bluenimble.com' }
	  });
	  
	  

update(entity, doc, partial) → {Object}

re-index fully or partially a document
Parameters:
Name Type Description
entity string entity name
doc Object document
partial boolean true to partially update the document
Source:
Returns:
[result] - document getting re-indexed
Type
Object
Example
api.indexer (request).update ('Orders', {
	  	id: '123456789',
	  	price: 500
	  }, true );