Skip to content

Instantly share code, notes, and snippets.

@peschlowp
peschlowp / elasticsearch-lessons-learned-sense-examples
Last active August 29, 2015 14:07
Elasticsearch Sense contents shown in my "Elasticsearch Lessons Learned" talk. Just copy paste into Sense and run the statements top to bottom.
###################################################
###################################################
# Elasticsearch Lessons Learned
###################################################
###################################################
# Delete the "books" index, just in case it is still there from previous experiments.
DELETE /books
@peschlowp
peschlowp / transactions-nested-sense-example
Created October 8, 2014 13:23
Elasticsearch Sense contents to demonstrate how transactions with respect to search visibility may be implemented with nested objects. Just copy paste into Sense and run the statements top to bottom.
# Delete the index, just in case it still exists.
DELETE /myindex
# Create the index with a mapping declaring a nested field.
PUT /myindex
{
"mappings": {
"document": {
"properties": {
"common_id": {
@peschlowp
peschlowp / transactions-counters-sense-example
Created October 6, 2014 14:55
Elasticsearch Sense contents to demonstrate how transactions with respect to search visibility may be implemented with parent-child relationships using counters. Just copy paste into Sense and run the statements top to bottom.
# Transactions with parent-child relationships using counters.
# Delete the index, just in case it still exists.
DELETE /myindex
# Create the index with a mapping for the actual documents and a mapping for the parent transaction type.
PUT /myindex
{
"mappings": {
"transaction": {
@peschlowp
peschlowp / transactions-sense-example
Last active November 21, 2019 04:00
Elasticsearch Sense contents to demonstrate how transactions with respect to search visibility may be implemented with parent-child relationships. Just copy paste into Sense and run the statements top to bottom.
# Transactions with parent-child relationships.
# Delete the index, just in case it still exists.
DELETE /myindex
# Create the index with a mapping for the actual documents and a mapping for the parent transaction type.
PUT /myindex
{
"mappings": {
"transaction": {
@peschlowp
peschlowp / elasticsearch-sense-examples
Last active November 10, 2015 09:58
Elasticsearch Sense contents to demonstrate various basic and advanced features of Elasticsearch. Just copy paste into Sense and run the statements top to bottom.
###################################################
###################################################
# Crash course
###################################################
###################################################
En
###################################################
# Quickstart
###################################################
@peschlowp
peschlowp / Aggregations.java
Created June 12, 2014 08:58
Aggregations example for calculations involving the duration of different document processing stages. Just run its main method with Elasticsearch 1.2 on the classpath.
package peschlowp.test.elasticsearch;
import java.io.IOException;
import java.util.Date;
import java.util.Map;
import java.util.Random;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.common.settings.ImmutableSettings;
@peschlowp
peschlowp / Experiment.java
Created January 9, 2014 09:24
Java program that demoes a possible bug in ElasticSearch 0.90.9 leading to an update request blocking forever on the client. Steps needed to run the program: 1. Set the cluster name of your choice and start up an ElasticSearch server. The index and mapping will be created dynamically. 2. Put ElasticSearch 0.90.9 library on the classpath.
package ppe.test.elasticsearch;
import java.io.IOException;
import org.elasticsearch.action.ActionFuture;
import org.elasticsearch.client.Client;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.node.Node;
import org.elasticsearch.node.NodeBuilder;