Skip to content

Suggestion how to fix IDs for searchBoolean #336

@dvagas

Description

@dvagas

Current:

tntsearch/src/TNTSearch.php

Lines 222 to 226 in 781e0ee

if (count($stack)) {
$docs = new Collection($stack[0]);
} else {
$docs = new Collection;
}

Suggestion:

        if (count($stack)) {
            $docs = new Collection(array_combine($stack[0],$stack[0]));
        } else {
            $docs = new Collection;
        }

Reason:
When following Build an Index Manually Without a Datastore (no initial seeding of index) you can't get the correct IDs from searchBoolean with driver filesystem otherwise, because:

        if ($this->isFileSystemIndex()) {
            return $this->filesystemMapIdsToPaths($docs)->toArray();
        }

Returns 0,1,2,3, mapped to empty strings instead (unlike for "search" function, where the array key is the correct docId).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions