database_adapter_elasticsearch 0.2.1 database_adapter_elasticsearch: ^0.2.1 copied to clipboard
Adapter between 'package:database' and Elasticsearch, a full-featured text search engine based on Apache Lucene.
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');
}