ducene 0.5.1

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 48

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();
}

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';
        
Version Uploaded Documentation Archive
0.5.1 Aug 8, 2017 Go to the documentation of ducene 0.5.1 Download ducene 0.5.1 archive
0.5.0 Jul 7, 2017 Go to the documentation of ducene 0.5.0 Download ducene 0.5.0 archive
0.4.0 Dec 20, 2016 Go to the documentation of ducene 0.4.0 Download ducene 0.4.0 archive
0.3.0 Dec 6, 2016 Go to the documentation of ducene 0.3.0 Download ducene 0.3.0 archive
0.2.0 Dec 3, 2016 Go to the documentation of ducene 0.2.0 Download ducene 0.2.0 archive
0.1.0 Nov 20, 2016 Go to the documentation of ducene 0.1.0 Download ducene 0.1.0 archive
0.0.9 Oct 19, 2016 Go to the documentation of ducene 0.0.9 Download ducene 0.0.9 archive
0.0.8 Sep 23, 2016 Go to the documentation of ducene 0.0.8 Download ducene 0.0.8 archive
0.0.7 Sep 14, 2016 Go to the documentation of ducene 0.0.7 Download ducene 0.0.7 archive
0.0.6 Sep 2, 2016 Go to the documentation of ducene 0.0.6 Download ducene 0.0.6 archive

All 15 versions...

Analysis

We analyzed this package on Apr 23, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.49.0
  • pana: 0.10.6

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
0 / 100
Health:
Code health derived from static analysis. [more]
95 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
97 / 100
Overall score:
Weighted score of the above. [more]
48
Learn more about scoring.

Platforms

Detected platforms: web

Platform components identified in package: html, io.

Suggestions

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 6 errors 14 hints.

    Strong-mode analysis of lib/src/search/index_searcher.dart failed with the following error:

    line: 113 col: 16
    The function expression type '(int) → int' isn't of type '(dynamic) → int'. This means its parameter or return type does not match what is expected. Consider changing parameter type(s) or the returned type(s).

    Run dartfmt to format lib/src/store/sembast/sembast_index_directory.dart.

    Similar analysis of the following files failed:

    • lib/src/store/standard/fs_index_directory.dart (hint)
    • lib/src/util/index_holder.dart (hint)
  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.24.0 <2.0.0
bit_set ^0.1.0 0.1.0
firebase ^3.2.0 3.2.0 4.4.0
lzma ^0.3.0 0.3.0 0.4.0
sembast ^1.3.7 1.7.0
Transitive dependencies
async 2.0.6
browser 0.10.0+3
charcode 1.1.1
collection 1.14.9
fixnum 0.10.7
func 1.0.0
http 0.11.3+16
http_parser 3.1.1
js 0.6.1
logging 0.11.3+1
path 1.5.1
source_span 1.4.0
string_scanner 1.0.2
synchronized 1.4.0
typed_data 1.1.5
Dev dependencies
test >=0.12.0 <0.13.0