The goal of this project is to provide a comprehensive yet easy to use
Elasticsearch client for Swift. The Vapor server side framework has a large
community around it so integrating with Vapor was a logical first step. That
said, this library should be very easy to port to another framework (Perfect,
Kitura) or even use by itself for command line utilities and other such
purposes.
Main priorities are to provide index management (field mapping, settings,
tokenizers and analyzers), CRUD support and search results with support for
aggregations. Currently these goals are all being met on some level.
Warning
This project is under heavy development and the public API has been changing
(with no backward compatability) every week. That said, the changes tend to be
fairly minor as long as you’re diligent with pulling the latest code every week.
High Level Features
Support for creating, updating, requesting and deletion of documents
High level construction of the Elasticsearch Query DSL
Execution of constructed search queries
Execution of many types of aggregations (more are implemented regurally)
Population of object models when fetching a document and search results (via Swift Codable support)
Automatic seralization of object models to Elasticsearch (via Swift Codable support)
Ability to specify the mapping for index creation
Support for bulk operations
Elasticsearch Version
All development and testing is being done using the Elasticsearch 6.x series.
This has implications around document types as they have been depricated in
Elasticsearch 6.0 and will be removed in 7.0. Given that multiple types per
index is a thing of the past and this client is a thing of the future, supporting
multiple types per index didn’t seem like a good fit. If using an older version
of Elasticsearch, keep this limitation in mind.
A Vapor/Swift Elasticsearch Client 🔎
The goal of this project is to provide a comprehensive yet easy to use Elasticsearch client for Swift. The Vapor server side framework has a large community around it so integrating with Vapor was a logical first step. That said, this library should be very easy to port to another framework (Perfect, Kitura) or even use by itself for command line utilities and other such purposes.
Main priorities are to provide index management (field mapping, settings, tokenizers and analyzers), CRUD support and search results with support for aggregations. Currently these goals are all being met on some level.
Warning
This project is under heavy development and the public API has been changing (with no backward compatability) every week. That said, the changes tend to be fairly minor as long as you’re diligent with pulling the latest code every week.
High Level Features
Elasticsearch Version
All development and testing is being done using the Elasticsearch 6.x series. This has implications around document types as they have been depricated in Elasticsearch 6.0 and will be removed in 7.0. Given that multiple types per index is a thing of the past and this client is a thing of the future, supporting multiple types per index didn’t seem like a good fit. If using an older version of Elasticsearch, keep this limitation in mind.
📦 Installation
Package.swift
Add
Elasticsearch
to the Package dependencies:as well as to your target (e.g. “App”):
Getting started 🚀
Make sure that you’ve imported
Elasticsearch
everywhere needed:Adding the Service
Add the
ElasticsearchDatabase
in yourconfigure.swift
file:Enable Logging
Simple search example
Creating an index (with filter)
Deleting an index
Use
bulk
to insert documents