Skip to content

Instantly share code, notes, and snippets.

View johtani's full-sized avatar

Jun Ohtani johtani

View GitHub Profile
POST _reindex
{
"source": {
"index": "apache_elk_example_org"
},
"dest": {
"index": "apache_elk_example"
},
"script": {
"inline": "Random rdm = new Random();ctx._source['@timestamp'] = params.dates[rdm.nextInt(params.dates.length)]+ ctx._source['@timestamp'].substring(10);",
String json = "{" +
"\"user\":\"kimchy\"\n," +
"\"postDate\":\"2013-01-30\"," +
"\"message\":\"trying out Elasticsearch\"" +
"}";
BulkRequestBuilder bulkRequest = client.prepareBulk();
bulkRequest.add(client.prepareIndex("test1", "tweet", "id1").setSource(json));
@johtani
johtani / gist:0554f54ae7d9aea375cb
Created November 25, 2015 03:12
Example url search
PUT hoge_index
{
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0
},
"mappings": {
"hoge": {
"properties": {
@johtani
johtani / gist:9687fb3cfb249750910d
Created January 21, 2015 07:17
Terms aggregation filtered the length of terms
DELETE /filtered_aggs
PUT /filtered_aggs
PUT /filtered_aggs/example/1
{
"text" : "this is test doc"
}
PUT /filtered_aggs/example/2
@johtani
johtani / gist:1a844bdd3443fb43fb90
Last active September 11, 2018 13:10
Example using Kuromoji readingform and NGram
DELETE kuromoji_sample
PUT kuromoji_sample
{
"settings": {
"analysis": {
"analyzer": {
"hoge" : {
"type" : "custom",
"tokenizer" : "kuromoji_tokenizer",
@johtani
johtani / check_request
Created October 31, 2014 14:16
Analyze the issue about kibana3 histogram no showing...
GET sensu-metrics-2014.10.31/_search
{
"facets": {
"0": {
"date_histogram": {
"key_field": "@timestamp",
"value_field": "value",
"interval": "1m"
},
"global": true,
@johtani
johtani / command_sample
Last active May 12, 2016 05:56
Does not reproduce the mapping error...
$ curl -XPUT localhost:9200/test_idx -d @config.json
{"error":"MapperParsingException[mapping [test_type]]; nested: IllegalArgumentException[Invalid format: [not_analyze]: Illegal pattern component: n]; nested: IllegalArgumentException[Illegal pattern component: n]; ","status":400}jupiter:ess_env
@johtani
johtani / line_aggregation_sample.json
Last active August 29, 2015 14:01
nested aggregation sample: tested by elasticsearch 1.1.1
DELETE /line_aggs
# create index and mapping
PUT /line_aggs
{
"settings": {
"number_of_shards": 2,
"number_of_replicas": 0
},
"mappings": {
@johtani
johtani / pref_aggregation_sample
Last active August 29, 2015 14:01
pref_aggregation_sample
# delete index
DELETE /pref_aggs
# create index
PUT /pref_aggs
{
"settings": {
"number_of_shards": 2
},
"mappings": {
@johtani
johtani / sample_mapping_data_query.json
Last active August 29, 2015 13:56
nestedなデータのハイライトの奇妙な動作と、再現データ(ES1.0、0.90.11で確認)
DELETE /bookstore
PUT /bookstore
POST /bookstore/books/_mapping
{
"books" : {
"properties": {
"book" : {
"type": "nested",