Home Reference Source
import {SearchResult} from '~/models/Search.js'
public class | source

SearchResult

Represents a given search result as native object

Constructor Summary

Public Constructor
public

constructor(category: SearchCategory, object: Object, result: Object)

Represents search result

Member Summary

Public Members
public
public

Unique foreign id for object

public get

Returns underlying value or object backing this result.

Method Summary

Public Methods
public

Obtains the full highlight

public

highlightSnippetForKey(key: string, predicate: Function, type: string): DocumentFragment

Obtains highlight snippet for key

Public Constructors

public constructor(category: SearchCategory, object: Object, result: Object) source

Represents search result

Params:

NameTypeAttributeDescription
category SearchCategory

A search category

object Object

Formatted object

result Object

the result object from algolia

Public Members

public category: * source

public id: string source

Unique foreign id for object

public get value: Object source

Returns underlying value or object backing this result. This is the formatted local model.

Return:

Object

Public Methods

public highlightForKey(key: string): string source

Obtains the full highlight

Params:

NameTypeAttributeDescription
key string

Key of item eg author.name

Return:

string

string of the value.

Throw:

TypeError

If key not found

public highlightSnippetForKey(key: string, predicate: Function, type: string): DocumentFragment source

Obtains highlight snippet for key

Params:

NameTypeAttributeDescription
key string

Key of item eg author.name

predicate Function
  • nullable: true

If key exists call the predicate and return the results, else fragment.

type string
  • optional
  • default: span

Node type to wrap in

Return:

DocumentFragment

HTML node with <em> for highlights

Throw:

TypeError

If key not found