Skip to content

Instantly share code, notes, and snippets.

View deverton's full-sized avatar

Dan Everton deverton

View GitHub Profile
@deverton
deverton / nested-document.json
Created June 24, 2011 02:54
Nested ES document example
{
"exception" : {
"message" : "Exceptional circumstances",
"stackTrace" : [
{ "file" : "Test.java", "class" : "Test", "method" : "foo", "line" : 100, "native" : false },
{ "file" : "Test.java", "class" : "Test", "method" : "bar", "line" : 99, "native" : false }
],
"causedBy" : {
"message" : "Special Circumstances",
"stackTrace" : [
@deverton
deverton / gist:1094119
Created July 20, 2011 01:04
Invalid Facet Query NPE Test Case
#!/bin/bash
curl -S -XDELETE http://localhost:9200/testindex > /dev/null
curl -S -XPUT http://localhost:9200/testindex > /dev/null
curl -XPOST http://localhost:9200/testindex/_search?pretty=true -d '{
"query" : { "match_all" : {} },
"facets" : {
"tags" : {
"field" : "tag",
"size" : 3
@deverton
deverton / gist:1094125
Created July 20, 2011 01:06
ES 0.17.0 Invalid Facet Query Stack Trace
[2011-07-20 11:03:30,092][DEBUG][action.search.type ] [Legacy] [testindex][2], node[TkPym95HQiCgYGU1qRcX_w], [P], s[STARTED]: Failed to execute [org.elasticsearch.action.search.SearchRequest@fa09c82]
java.lang.NullPointerException
at org.elasticsearch.search.facet.FacetPhase.execute(FacetPhase.java:139)
at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:226)
at org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:223)
at org.elasticsearch.search.action.SearchServiceTransportAction.sendExecuteQuery(SearchServiceTransportAction.java:134)
at org.elasticsearch.action.search.type.TransportSearchQueryThenFetchAction$AsyncAction.sendExecuteFirstPhase(TransportSearchQueryThenFetchAction.java:76)
at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:201)
at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.access$000(TransportSearchTypeAction.java:81)
at org.e
@deverton
deverton / nested-facet-mapping.json
Created August 5, 2011 03:32
Faceting by both document and nested document
{
"rating": {
"properties" : {
"system" : {
"type" : "string",
"index" : "not_analyzed"
},
"value" : {
"type" : "float",
"null_value" : 0,
@deverton
deverton / gist:1474679
Created December 14, 2011 00:49
Test case for ES Issue #1536
curl -XPUT 'http://localhost:9200/nested_test/' -d '
index :
number_of_shards : 5
number_of_replicas : 0
'
curl -XPUT 'http://localhost:9200/nested_test/nested/_mapping' -d '{"type1":{"properties":{"obj1":{"type":"nested"}}}}'
curl -XPOST 'http://localhost:9200/nested_test/nested/' -d '{"obj1":[{"name":"blue",count:4},{"name":"green",count:6}]}'
curl -XGET 'http://localhost:9200/nested_test/nested/_search?pretty=true' -d'{"query":{"nested": { "path":"obj1"}}}}'
curl -XGET 'http://localhost:9200/nested_test/nested/_search?pretty=true' -d'{"query":{"nested": { "path":"obj1", "query": { "match_all":{}}}}}'
@deverton
deverton / gist:1563960
Created January 5, 2012 06:06
Stack trace on delete in Elasticsearch
[2012-01-05 16:02:32,693][WARN ][river.couchdb ] [Asmodeus] [couchdb][database_type1] failed to executefailure in bulk execution:
[0]: index [database], type [type1], id [030cc472426e451a6d5e6b0e15000988], message [VersionConflictEngineException[[database][2] [type1][030cc472426e451a6d5e6b0e15000988]: version conflict, current [-1], required [1]]]
[2012-01-05 16:03:17,193][DEBUG][action.bulk ] [Asmodeus] [database][0] failed to bulk item (delete) delete {[database][type1][030cc472426e451a6d5e6b0e15000c80]}
org.elasticsearch.index.engine.VersionConflictEngineException: [database][0] [type1][030cc472426e451a6d5e6b0e15000c80]: version conflict, current [-1], required [2]
at org.elasticsearch.index.engine.robin.RobinEngine.innerDelete(RobinEngine.java:646)
at org.elasticsearch.index.engine.robin.RobinEngine.delete(RobinEngine.java:597)
at org.elasticsearch.index.shard.service.InternalIndexShard.delete(InternalIndexShard.java:336)
at org.elasticsearch.action.bulk.TransportShardBulkActio
@deverton
deverton / logstash-template.json
Created June 22, 2012 04:49
Logstash Elasticsearch Template
{
"template": "logstash-*",
"settings" : {
"number_of_shards" : 1,
"number_of_replicas" : 0,
"index" : {
"query" : { "default_field" : "@message" },
"store" : { "compress" : { "stored" : true, "tv": true } }
}
},
@deverton
deverton / gist:7743979
Created December 2, 2013 02:22
Customising Jackson to use new lines between root objects and also customise the serialization of a list. Useful when talking to Elasticsearch _msearch endpoint.
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.util.MinimalPrettyPrinter;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import java.io.IOException;
import java.util.Random;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
public class Demo {
private static final Random R = new Random();
static class Producer implements Runnable {
@deverton
deverton / keybase.md
Created October 15, 2014 22:26
Keybase Proof

Keybase proof

I hereby claim:

  • I am deverton on github.
  • I am deverton (https://keybase.io/deverton) on keybase.
  • I have a public key whose fingerprint is C1C5 EF8B EAA0 6FFB 432F 1C64 0092 9E66 11CE D822

To claim this, I am signing this object: