function Resolver(result, index) {
    if (!this || this.constructor !== Resolver) {
        return new Resolver(result, index);
    }

    let boost = 0,
        promises,
        query,
        field,
        highlight,
        _await,
        _return;

    if (result && result.index) {
        const options = /** @type {ResolverOptions} */result;
        index = options.index;
        boost = options.boost || 0;
        if (query = options.query) {
            field = options.field || options.pluck;
            highlight = options.highlight;
            const resolve = options.resolve,
                  async = options.async || options.queue;

            options.resolve = !1;
            options.index = null;
            result = async ? index.searchAsync(options) : index.search(options);
            options.resolve = resolve;
            options.index = index;
            result = result.result || result;
        } else {
            result = [];
        }
    }

    if (result && result.then) {
        const self = this;
        result = result.then(function (result) {
            self.promises[0] = self.result = result.result || result;
            self.execute();
        });
        promises = [result];
        result = [];
        _await = new Promise(function (resolve) {
            _return = resolve;
        });
    }

    /** @type {Index|Document|WorkerIndex|null} */
    this.index = index || null;
    /** @type {IntermediateSearchResults} */
    this.result = /** @type {IntermediateSearchResults} */result || [];
    /** @type {number} */
    this.boostval = boost;
    /** @type {Array<Promise<IntermediateSearchResults>|IntermediateSearchResults|Function>} */
    this.promises = promises || [];
    /** @type {Promise<SearchResults|EnrichedSearchResults>} */
    this.await = _await || null;
    /** @type {Function} */
    this.return = _return || null;

    /** @type {HighlightOptions|null} */
    this.highlight = /** @type {HighlightOptions|null} */highlight || null;
    /** @type {string} */
    this.query = query || "";
    /** @type {string} */
    this.field = field || "";
}
@param {IntermediateSearchResults|ResolverOptions=} result
@param {Index|Document|WorkerIndex=} index
@return {Resolver}
@constructor