The cl-elastic Reference Manual

Table of Contents

Next: , Previous: , Up: (dir)   [Contents][Index]

The cl-elastic Reference Manual

This is the cl-elastic Reference Manual, version 0.0.1, generated automatically by Declt version 3.0 "Montgomery Scott" on Mon Dec 02 09:24:04 2019 GMT+0.


Next: , Previous: , Up: Top   [Contents][Index]

1 Introduction

Cl-Elastic - Elasticsearch client for Common Lisp

Motivation

This project is supposed to be a simple interface for Elasticsearch. The emphasis is on simple, i.e. this is not supposed to be a DSL on top of another DSL. You should be able go to the Elasticsearch docs and translate that immediatly into working code. If you are looking for a DSL checkout the section about other work.

Installation

Currently the library is not in quicklisp. You need to add the repo to your local quicklisp repos.

Usage

(ql:quicklisp :cl-elastic)
(use :cl-elastic)

(defvar *client* (make-instance '<client> :endpoint "http://localhost:9200"))

;; creates an index named `elasticsearch-test`
(send-request *client* '("elasticsearch-test") :method :put)

You can enable keyword arguments which lets you use keywords as keys in hashtable and parameter plists as well as uri construction. The transformation is always to lowercase.

(setq *enable-keywords* t)
(send-request *client* '(:elasticsearch-test) :method :put)

The library uses the yason library under the hood to map between lisp objects and JSON. As hashtables are therefore ubiquitous for JSON construction the library also exports a simple reader syntax for literal hashmap construction. The syntax is #{key1 value1 key2 value2 ...}. For the enabling and disabling of the syntax the library uses named-readtables.

(in-readtable hashtable-syntax)

(defvar foo "bar")
;; creates a hashmap with ("bar" 1) and ("foo" 2) as key/value pairs
#{foo 1 "foo" 2}

(in-readtable :standard)

For the remaining examples we are assuming that *enable-keywords* is set to true and the above hashtable syntax is enabled. The following examples assume that you are using Elasticsearch version 7.0.0 or above, otherwise you might need to adapt the index settings.

;; create a index with a test field of type text
(send-request *client* :elasticsearch-test :method :put 
              :data #{:settings #{:number_of_shards 1}
                      :mappings #{:properties #{:test #{:type "text"}}}})

;; create a document with id 3
(send-request *client* '(:elasticsearch-test :_doc 3) :method :put
              :data #{:test "toto"})
              
;; find a document by id
(send-request *client* '(:elasticsearch-test :_doc 3) :method :get)

;; search for something
(send-request *client* '(:elasticsearch-test :_search) :method :get
              :data #{:query #{:term #{:test "toto"}}})

;; delete the document
(send-request *client* '(:elasticsearch-test :_doc 3) :method :delete)

;; for bulk requests you can pass a list of operations as data
(send-request *client* :_bulk :method :post
              :data (list
                     #{:index #{:_index :elasticsearch-test :_id 3}}
                     #{:test "foo"}
                     #{:index #{:_index :elasticsearch-test :_id 2}}
                     #{:test "bar"}
                     #{:delete #{:_index :elasticsearch-test :_id 3}}))

Other work

There are a couple of other clients, although non of them are in quicklisp:
clesc
cl-elasticsearch
eclastic

Todo

Author

Licence

MIT Licence

Copyright

Copyright (c) 2019 Finn Völkel (firstname.lastname@gmail.com


Next: , Previous: , Up: Top   [Contents][Index]

2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 cl-elastic

Author

Finn Völkel

License

MIT

Description

Elasticsearch client for Common Lisp

Version

0.0.1

Dependencies
Source

cl-elastic.asd (file)

Component

cl-elastic.lisp (file)


Next: , Previous: , Up: Top   [Contents][Index]

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

3.1 Lisp


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.1 cl-elastic.asd

Location

cl-elastic.asd

Systems

cl-elastic (system)


Previous: , Up: Lisp files   [Contents][Index]

3.1.2 cl-elastic/cl-elastic.lisp

Parent

cl-elastic (system)

Location

cl-elastic.lisp

Packages

cl-elastic

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

4 Packages

Packages are listed by definition order.


Previous: , Up: Packages   [Contents][Index]

4.1 cl-elastic

Source

cl-elastic.lisp (file)

Nickname

elastic

Use List

common-lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

5.1 Exported definitions


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.1 Special variables

Special Variable: *enable-keywords*

If set to a true value, keywords will be transformed to strings in JSON objects and read back as keywords.

Package

cl-elastic

Source

cl-elastic.lisp (file)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.2 Macros

Macro: disable-hashtable-syntax ()
Package

cl-elastic

Source

cl-elastic.lisp (file)

Macro: enable-hashtable-syntax ()
Package

cl-elastic

Source

cl-elastic.lisp (file)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.3 Functions

Function: send-request CLIENT URI &key METHOD DATA PARAMETERS

Sends a request to an Elasticsearch client.

Package

cl-elastic

Source

cl-elastic.lisp (file)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.4 Generic functions

Generic Function: endpoint OBJECT
Package

cl-elastic

Methods
Method: endpoint (<CLIENT> <client>)

automatically generated reader method

Source

cl-elastic.lisp (file)

Generic Function: password OBJECT
Package

cl-elastic

Methods
Method: password (<CLIENT> <client>)

automatically generated reader method

Source

cl-elastic.lisp (file)

Generic Function: user OBJECT
Package

cl-elastic

Methods
Method: user (<CLIENT> <client>)

automatically generated reader method

Source

cl-elastic.lisp (file)


Previous: , Up: Exported definitions   [Contents][Index]

5.1.5 Classes

Class: <client> ()
Package

cl-elastic

Source

cl-elastic.lisp (file)

Direct superclasses

standard-object (class)

Direct methods
Direct slots
Slot: endpoint
Initargs

:endpoint

Initform

"http://localhost:9200"

Readers

endpoint (generic function)

Slot: user
Initargs

:user

Readers

user (generic function)

Slot: password
Initargs

:password

Readers

password (generic function)


Previous: , Up: Definitions   [Contents][Index]

5.2 Internal definitions


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.1 Special variables

Special Variable: *previous-readtables*
Package

cl-elastic

Source

cl-elastic.lisp (file)


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.2 Functions

Function: #{-reader-} STREAM CHAR ARG
Package

cl-elastic

Source

cl-elastic.lisp (file)

Function: concat-with-newlines STRINGS

Concats STRINGS with newlines. Ends in a newline.

Package

cl-elastic

Source

cl-elastic.lisp (file)

Function: create-uri CLIENT URI
Package

cl-elastic

Source

cl-elastic.lisp (file)

Function: encode-json DATA

Transforms a lisp object into a JSON object in string form. A list is transformed into the newline seperated concatenation of JSON objects.

Package

cl-elastic

Source

cl-elastic.lisp (file)

Function: keyword-downcase KEYWORD
Package

cl-elastic

Source

cl-elastic.lisp (file)

Function: keywords-to-strings X
Package

cl-elastic

Source

cl-elastic.lisp (file)

Function: make-keyword NAME

Creates a keyword symbol for a given string NAME.

Package

cl-elastic

Source

cl-elastic.lisp (file)

Function: parse-uri URI

Parses a URI in form of a string, keyword or list.

Package

cl-elastic

Source

cl-elastic.lisp (file)


Previous: , Up: Internal definitions   [Contents][Index]

5.2.3 Conditions

Condition: odd-number-of-forms ()
Package

cl-elastic

Source

cl-elastic.lisp (file)

Direct superclasses

error (condition)


Previous: , Up: Top   [Contents][Index]

Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts

Jump to:   C   F   L  
Index Entry  Section

C
cl-elastic.asd: The cl-elastic․asd file
cl-elastic/cl-elastic.lisp: The cl-elastic/cl-elastic․lisp file

F
File, Lisp, cl-elastic.asd: The cl-elastic․asd file
File, Lisp, cl-elastic/cl-elastic.lisp: The cl-elastic/cl-elastic․lisp file

L
Lisp File, cl-elastic.asd: The cl-elastic․asd file
Lisp File, cl-elastic/cl-elastic.lisp: The cl-elastic/cl-elastic․lisp file

Jump to:   C   F   L  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   #  
C   D   E   F   G   K   M   P   S   U  
Index Entry  Section

#
#{-reader-}: Internal functions

C
concat-with-newlines: Internal functions
create-uri: Internal functions

D
disable-hashtable-syntax: Exported macros

E
enable-hashtable-syntax: Exported macros
encode-json: Internal functions
endpoint: Exported generic functions
endpoint: Exported generic functions

F
Function, #{-reader-}: Internal functions
Function, concat-with-newlines: Internal functions
Function, create-uri: Internal functions
Function, encode-json: Internal functions
Function, keyword-downcase: Internal functions
Function, keywords-to-strings: Internal functions
Function, make-keyword: Internal functions
Function, parse-uri: Internal functions
Function, send-request: Exported functions

G
Generic Function, endpoint: Exported generic functions
Generic Function, password: Exported generic functions
Generic Function, user: Exported generic functions

K
keyword-downcase: Internal functions
keywords-to-strings: Internal functions

M
Macro, disable-hashtable-syntax: Exported macros
Macro, enable-hashtable-syntax: Exported macros
make-keyword: Internal functions
Method, endpoint: Exported generic functions
Method, password: Exported generic functions
Method, user: Exported generic functions

P
parse-uri: Internal functions
password: Exported generic functions
password: Exported generic functions

S
send-request: Exported functions

U
user: Exported generic functions
user: Exported generic functions

Jump to:   #  
C   D   E   F   G   K   M   P   S   U  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables

Jump to:   *  
E   P   S   U  
Index Entry  Section

*
*enable-keywords*: Exported special variables
*previous-readtables*: Internal special variables

E
endpoint: Exported classes

P
password: Exported classes

S
Slot, endpoint: Exported classes
Slot, password: Exported classes
Slot, user: Exported classes
Special Variable, *enable-keywords*: Exported special variables
Special Variable, *previous-readtables*: Internal special variables

U
user: Exported classes

Jump to:   *  
E   P   S   U  

Previous: , Up: Indexes   [Contents][Index]

A.4 Data types

Jump to:   <  
C   O   P   S  
Index Entry  Section

<
<client>: Exported classes

C
cl-elastic: The cl-elastic system
cl-elastic: The cl-elastic package
Class, <client>: Exported classes
Condition, odd-number-of-forms: Internal conditions

O
odd-number-of-forms: Internal conditions

P
Package, cl-elastic: The cl-elastic package

S
System, cl-elastic: The cl-elastic system

Jump to:   <  
C   O   P   S