Searching multiple keywords in the Document Library block not possible

I am noticing that you can’t keyword search the document library block with more than one key word - it seems to take in the keywords in the order written with spaces in between. I.e., if a document is named “Cat Bird Lizard” and the user searches for “cat lizard” no results will return. But if the user searches “cat bird” or “bird lizard” it will show in results.

I think users generally expect an AND search without a specified order when they see a keyword search box. Does anyone have any ideas on how to make the keyword search work like most people would expect? Any order, not necessarily consecutive words?

I did see that PHP will make an array of multiple vlaues for one field by appending ‘[]’ behind the field name(i.e., “someurl.php?name[]=aaa&name[]=bbb”) but I’m unsure of how to use this with the document library block.

Hi @kspitzley I’ll see if I can find some help with your developer questions. Your search enhancements suggestion to the document library can be submitted on Github.


@kspitzley looking at the code, it’s not sophisticated like that:

    private function setupKeywordSearch(FolderItemList $list, $keywords)
        $query = $list->getQueryObject();
        $expressions = [
            $query->expr()->like('fv.fvFilename', ':keywords'),
            $query->expr()->like('fv.fvDescription', ':keywords'),
            $query->expr()->like('fv.fvTitle', ':keywords'),
            $query->expr()->like('fv.fvTags', ':keywords'),
            $query->expr()->like('fv.fvTags', ':keywords'),
            $query->expr()->like('n.treeNodeName', ':keywords'),

        $keys = FileAttributeKey::getSearchableIndexedList();
        foreach ($keys as $ak) {
            $cnt = $ak->getController();
            $expressions[] = $cnt->searchKeywords($keywords, $query);

        $query->setParameter('keywords', '%' . $keywords . '%');

        return $list;

You could either submit a pull request to add that functionality, or override the controller and add your own custom setupKeywordSearch() method.