Skip to content

Use MongoDB fuzzy search feature to filter the chats list #1

@GromNaN

Description

@GromNaN

This feature requires MongoDB Atlas to use Lucene search.

/**
* @return array{title: string, createdAt: \DateTimeImmutable, id: string}[]
* @todo project only the fields we need, not the whole document with all messages
* also use the atlas search for fuzzy search https://www.mongodb.com/docs/atlas/atlas-search/text/#fuzzy-examples
*/
public function getConversations(): iterable
{
return $this->documentManager->getRepository(Conversation::class)
->createQueryBuilder()
->field('title')->equals(new Regex($this->query ?? '', 'i'))
->sort('createdAt', 'desc')
->limit(20)
->getQuery()
->execute();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions