import Index from 'information-retrieval-boilerplate/node-information-retrieval-boilerplate/src/index/Index.js'
Index
An index
Constructor Summary
Public Constructor | ||
public |
constructor(config: object) Construct a new Index |
Member Summary
Public Members | ||
public |
Information gain. |
|
public |
List of fields it should index. |
|
public |
List of filters supported. |
|
public |
Actual Index. |
|
public |
Field values this index can supply for sorting. |
|
public |
Type of index. |
Protected Members | ||
protected |
List of field values by index. |
Method Summary
Public Methods | ||
public |
async addDocuments(documentIndices: number[], documents: Document[]) Adds a set of documents to Index |
|
public abstract |
addToIndex(index: IndexImplementation, documentIndices: number[], documentValues: string[][]) Add to index. |
|
public |
analyseValue(row: *): * |
|
public abstract |
filterBasedOnIndex(index: IndexImplementation, queryFilter: QueryFilter, results: Results) Filter results based on index |
|
public |
filterDocuments(queryFilter: QueryFilter, results: Results): * Filter results based on query |
|
public |
async removeDocuments(documentIndices: number[]) Removes a set of documents from Index |
|
public abstract |
removeFromIndex(index: IndexImplementation, documentIndices: number[], documentValues: string[][]) Remove from index |
|
public |
Dump current index state. |
Protected Methods | ||
protected |
analyseValues(values: object[][]): object[][] Processing before adding to index. |
|
protected |
createIndex(): IndexImplementation Create an empty index. |
|
protected |
getDocumentValues(document: Document): object[] Extract values out of a document object. |
Public Constructors
Public Members
public entropy: number source
Information gain. TODO: should determine which field to query first etc.
public filters: string source
List of filters supported. These are usually predefined values. Filled in by class.
Protected Members
Public Methods
public async addDocuments(documentIndices: number[], documents: Document[]) source
Adds a set of documents to Index
public abstract addToIndex(index: IndexImplementation, documentIndices: number[], documentValues: string[][]) source
Add to index.
Params:
Name | Type | Attribute | Description |
index | IndexImplementation | ||
documentIndices | number[] | ||
documentValues | string[][] |
public abstract filterBasedOnIndex(index: IndexImplementation, queryFilter: QueryFilter, results: Results) source
Filter results based on index
Params:
Name | Type | Attribute | Description |
index | IndexImplementation | ||
queryFilter | QueryFilter | ||
results | Results |
public filterDocuments(queryFilter: QueryFilter, results: Results): * source
Filter results based on query
Params:
Name | Type | Attribute | Description |
queryFilter | QueryFilter | query to filter with |
|
results | Results | results to filter (modify results object) |
Return:
* |
public async removeDocuments(documentIndices: number[]) source
Removes a set of documents from Index
Params:
Name | Type | Attribute | Description |
documentIndices | number[] | Index of document ids in the list of ids. Indices must store document data by this index. |
public abstract removeFromIndex(index: IndexImplementation, documentIndices: number[], documentValues: string[][]) source
Remove from index
Params:
Name | Type | Attribute | Description |
index | IndexImplementation | ||
documentIndices | number[] | ||
documentValues | string[][] |
Protected Methods
protected analyseValues(values: object[][]): object[][] source
Processing before adding to index.
By default, it turns list of objects into a map of string representation of the objects to their occurance tally.
Params:
Name | Type | Attribute | Description |
values | object[][] | list of values for each documents |
Return:
object[][] |
protected createIndex(): IndexImplementation source
Create an empty index.
Return:
IndexImplementation | default is {} |
protected getDocumentValues(document: Document): object[] source
Extract values out of a document object.
It is set up like this so that we can override this method and filter the values we don't like.
Params:
Name | Type | Attribute | Description |
document | Document |
Example:
{field: ['a', 'b']} should return ['a', 'b']