search 0.3.0 copy "search: ^0.3.0" to clipboard
search: ^0.3.0 copied to clipboard

unlisted

A small search engine middleware for 'package:database'. Meant for applications that want to do basic searches without an external search engine like ElasticSearch/Lucene.

Pub Package Github Actions CI

Overview #

This is a simple information retrieval engine for the package database.

Licensed under the Apache License 2.0.

How it works #

Iteration #

SearchableDatabase wraps any other Database and intercepts search requests that contain one or more KeywordFilter instances.

The current implementation then simply visits every document in the collection and calculates score for each document. This is very inefficient strategy for large collections / many concurrent requests. However, for typical mobile and web applications, this is fine!

Preprocessing #

In the preprocessing step, we simplify both the keyword and the inputs.

The following transformations are done:

  • String is converted to lowercase.
    • "John" --> " john "
  • Some extended Latin characters are replaced with simpler characters.
    • "Élysée" --> " elysee "
  • Some suffixes are removed.
    • "Joe's coffee" --> " joe coffee "
  • Multiple whitespace characters are replaced with a single space.
    • "hello,\n world" --> " hello world "

Scoring #

The document scoring algorithm is very basic.

The high-level idea is to raise score for:

  • More matches
  • Sequential matches
  • Matches of non-preprocessed strings

Contributing #

Getting started #

In pubspec.yaml:

dependencies:
  database: any
  search: any

In lib/main.dart:

import 'package:database/database.dart';
import 'package:search/search.dart';

void main() {
  final database = SearchableDatabase(
    master: MemoryDatabaseAdapter(),
  ).database();
  final collection = database.collection('employee');
  final result = await collection.search(
    query: Query.parse(
      '(Hello OR Hi) world!',
      skip: 0,
      take: 10,
    ),
  );
}
23
likes
30
pub points
32%
popularity

Publisher

verified publisherdint.dev

A small search engine middleware for 'package:database'. Meant for applications that want to do basic searches without an external search engine like ElasticSearch/Lucene.

Repository (GitHub)
View/report issues

License

Apache-2.0 (license)

Dependencies

charcode, database, meta

More

Packages that depend on search