database_adapter_elasticsearch 0.2.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 66

Pub Package Github Actions CI

Overview #

This package enables you to use the package database with Elasticsearch, a text search engine based on Apache Lucene.

Getting started #

Add dependency #

dependencies:
  database: any
  database_adapter_elasticsearch: any

A simple example #

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

// Set up
final Database database = ElasticSearch(
  credentials: ElasticSearchPasswordCredentials(
    user: 'example user',
    password: 'example password'
  ),
);

Future main() async {
  // Insert a document
  final document = await database.collection('example').insert({
    'greeting': 'Hello world!'
  });

  // Search documents
  final results = await database.collection('example').search(
    query: Query.parse(
      'hello',
      skip: 0,
      take: 10,
    )',
  });
}

[0.2.2] - March 10, 2020 #

  • Updates dependencies.
  • Uses vendorData fields for exposing raw JSON responses from Elasticsearch.

[0.2.1] - January 21, 2020 #

  • Improved documentation

[0.2.0] - January 21, 2020 #

  • Uses 'package:database' version 0.3.0.

[0.1.0] - January 14, 2020 #

  • Initial release

example/example.dart

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

Future main() async {
  // Set up
  final database = ElasticSearch(
    host: 'localhost',
    credentials: ElasticSearchPasswordCredentials(
      user: 'example user',
      password: 'example password',
    ),
  ).database();
  final collection = database.collection('example');

  // Insert a document
  final document = await collection.insert(data: {'greeting': 'Hello world!'});
  print('Inserted ID: ${document.documentId}');

  // Search documents
  final results = await collection.search(
    query: Query.parse(
      'world hello',
      skip: 0,
      take: 10,
    ),
  );
  print('Found ${results.items} results');
}

Use this package as a library

1. Depend on it

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


dependencies:
  database_adapter_elasticsearch: ^0.2.2

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

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

3. Import it

Now in your Dart code, you can use:


import 'package:database_adapter_elasticsearch/database_adapter_elasticsearch.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
33
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
66
Learn more about scoring.

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

  • Dart: 2.7.1
  • pana: 0.13.6

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.6.0 <3.0.0
built_value >=5.0.0 <8.0.0 7.0.9
collection ^1.14.0 1.14.12
database ^0.3.2 0.3.3
meta ^1.1.0 1.1.8
universal_io >=0.8.5 <2.0.0 1.0.1
Transitive dependencies
async 2.4.1
built_collection 4.3.2
charcode 1.1.3
csslib 0.16.1
fixnum 0.10.11
html 0.14.0+3
matcher 0.12.6
path 1.6.4
protobuf 1.0.1
quiver 2.1.3
source_span 1.7.0
stack_trace 1.9.3
term_glyph 1.1.0
typed_data 1.1.6
universal_html 1.2.2
zone_local 0.1.2
Dev dependencies
pedantic ^1.9.0
test ^1.8.0