ducene 0.5.1

ducene #

An instant search library for Dart.

Pub Build Status License

Demo #

Pub Search : ducene + angular2 + firebase. The loading takes 15+ seconds.

Usage #

A simple usage example:

Future main() async {
  // open an index holder
  IndexHolder index = await DirectoryHolder.open(new RAMIndexHolderDirectory());
  // prepare documents
  List<Document> docs = [new Document()...];
  // add or update documents
  await index.updateDocuments(docs);
  // open a searcher
  IndexSearcher searcher = await index.newIndexSearcher();
  // count by query
  int count = await searcher.count(new BoolQuery()...);
}

Features and bugs #

Please file feature requests and bugs at the issue tracker.

0.5.1 - 2017-08-08 #

0.5.0 - 2017-07-07 #

0.4.0 - 2016-12-20 #

0.3.0 - 2016-12-06 #

0.2.0 - 2016-12-03 #

0.1.0 - 2016-11-20 #

0.0.9 - 2016-10-19 #

0.0.8 - 2016-09-23 #

0.0.7 - 2016-09-14 #

0.0.6 - 2016-09-02 #

0.0.5 - 2016-08-20 #

0.0.4 - 2016-08-16 #

0.0.3 - 2016-08-12 #

0.0.2 - 2016-08-09 #

0.0.1 - 2016-08-04 #

  • Initial version.

example/ducene.dart

// Copyright (c) 2016, Shinichiro Abe. All rights reserved. Use of this source code
// is governed by a BSD-style license that can be found in the LICENSE file.

import 'dart:async';
import 'package:ducene/analysis.dart';
import 'package:ducene/index.dart';
import 'package:ducene/search.dart';
import 'package:ducene/util.dart';

Future<Null> main() async {
  // use Analyzers to split text into tokens
  final Analyzer st = new StandardAnalyzer();
  // open an index holder
  final IndexHolder index =
      await DirectoryHolder.open(new RAMIndexHolderDirectory());
  // create documents
  final List<Document> addDocs = <Document>[
    new Document().append("id", "1").append("text", "White dog", analyzer: st),
    new Document().append("id", "2").append("text", "White cat", analyzer: st)
  ];
  // add documents
  await index.updateDocuments(addDocs);
  // open a searcher
  IndexSearcher searcher = await index.newRealTimeIndexSearcher();
  // count by query
  int count = await searcher.count(new BoolQuery().append("text", "white"));
  assert(count == 2);
  count = await searcher.count(new BoolQuery().append("text", "dog"));
  assert(count == 1);
  count = await searcher.count(new BoolQuery().append("text", "cat"));
  assert(count == 1);
  count = await searcher.count(new BoolQuery().append("text", "fox"));
  assert(count == 0);
  // create new document for update
  final List<Document> updateDocs = <Document>[
    new Document().append("id", "1").append("text", "White fox", analyzer: st)
  ];
  // update the document
  await index.updateDocuments(updateDocs);
  // open a searcher again
  searcher = await index.newRealTimeIndexSearcher();
  // count by query
  count = await searcher.count(new BoolQuery().append("text", "white"));
  assert(count == 2);
  count = await searcher.count(new BoolQuery().append("text", "dog"));
  assert(count == 0);
  count = await searcher.count(new BoolQuery().append("text", "cat"));
  assert(count == 1);
  count = await searcher.count(new BoolQuery().append("text", "fox"));
  assert(count == 1);
  // delete by query
  await index.deleteDocuments(new BoolQuery().append("id", "1"));
  // open a searcher again
  searcher = await index.newRealTimeIndexSearcher();
  // count by query
  count = await searcher.count(new BoolQuery().append("text", "white"));
  assert(count == 1);
  count = await searcher.count(new BoolQuery().append("text", "dog"));
  assert(count == 0);
  count = await searcher.count(new BoolQuery().append("text", "cat"));
  assert(count == 1);
  count = await searcher.count(new BoolQuery().append("text", "fox"));
  assert(count == 0);
  // merge index segments
  await index.forceMerge();
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  ducene: ^0.5.1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:ducene/analysis.dart';
import 'package:ducene/index.dart';
import 'package:ducene/search.dart';
import 'package:ducene/store.dart';
import 'package:ducene/store_firebase.dart';
import 'package:ducene/store_html.dart';
import 'package:ducene/store_sembast.dart';
import 'package:ducene/util.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
--
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
--
Overall:
Weighted score of the above. [more]
0
Learn more about scoring.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Analysis issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see https://dart.dev/dart-2#migration.

Maintenance issues and suggestions

Make sure dartdoc successfully runs on your package's source files. (-10 points)

Dependencies were not resolved.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.24.0 <2.0.0

Admin