Skip to content

Instantly share code, notes, and snippets.

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.elasticsearch.script.AbstractFloatSearchScript;
import org.elasticsearch.script.ExecutableScript;
import org.elasticsearch.script.NativeScriptFactory;
@dav-rob
dav-rob / gist:3145858
Created July 19, 2012 18:31
Attempted Multi-Colum Sort Using Long return value.
package com.cs.cts.crm.elasticsearch.util;
import java.util.List;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.elasticsearch.script.AbstractLongSearchScript;
import org.elasticsearch.script.ExecutableScript;
import org.elasticsearch.script.NativeScriptFactory;
@dav-rob
dav-rob / gist:3145802
Created July 19, 2012 18:21
3 Letters Plus Number String Sort
package com.cs.cts.crm.elasticsearch.util;
import java.util.List;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.elasticsearch.script.AbstractFloatSearchScript;
import org.elasticsearch.script.ExecutableScript;
import org.elasticsearch.script.NativeScriptFactory;
@dav-rob
dav-rob / Elastic Search Curl Commands 1
Created May 22, 2012 15:46
Elastic Search Curl Commands
Token Analysis
===============
curl -XGET '*****110.160:9302/contactalias/_analyze?field=mainEmail' -d 'acker'
curl -XGET '*****110.160:9302/contactindex_2011_10_18_08_59_34/_analyze?text=this+is+a+test'
Get Mapping
===============
Returns which types are mapped into the index, whether the fields are analysed, stored, boosted etc.
e.g.
[2012-05-22 05:39:50,164][INFO ][node ] [Jack-in-the-Box] {elasticsearch/0.17.6}[16014]: initializing ...
[2012-05-22 05:39:50,218][INFO ][plugins ] [Jack-in-the-Box] loaded [], sites []
[2012-05-22 05:39:58,805][INFO ][node ] [Jack-in-the-Box] {elasticsearch/0.17.6}[16014]: initialized
[2012-05-22 05:39:58,807][INFO ][node ] [Jack-in-the-Box] {elasticsearch/0.17.6}[16014]: starting ...
[2012-05-22 05:39:59,372][INFO ][transport ] [Jack-in-the-Box] bound_address {inet[/169.49.110.161:9300]}, publish_address {inet[/169.49.110.161:9300]}
[2012-05-22 05:39:59,691][INFO ][cluster.service ] [Jack-in-the-Box] new_master [Jack-in-the-Box][jXjOjMFzSlmp3xim9cgjBQ][inet[/169.49.110.161:9300]], reason: zen-disco-join (elected_as_master)
[2012-05-22 05:39:59,818][WARN ][discovery.zen.ping.unicast] [Jack-in-the-Box] failed to send ping to [[#zen_unicast_5#][inet[/169.49.110.161:9302]]]
org.elasticsearch.transport.ReceiveTi
@dav-rob
dav-rob / Query
Created January 9, 2012 16:32
Email Tokenizer Problem
{
"bool" : {
"should" : [ {
"filtered" : {
"query" : {
"match_all" : {
}
},
"filter" : {
"bool" : {
@dav-rob
dav-rob / Definition
Created January 9, 2012 16:17
Email Tokenizer Problem
index:
mapper:
dynamic: false
analysis:
analyzer:
default:
type: standard
stopwords: _none_
# sortable is used to enable case-independent sorting
@dav-rob
dav-rob / BaseErrorRecreation
Created November 30, 2011 14:26
Base Recreation Class and Test Class
public class BaseErrorRecreation {
protected static int waitForServerTimeout = 15000;
public static final Logger LOG = Logger.getLogger(BaseErrorRecreation.class.getName());
protected static Client client;
protected static boolean initializing = false;
protected static boolean initialized = false;
/*
* Spring properties Follow
*/
@dav-rob
dav-rob / Week View Map
Created November 28, 2011 15:34
Week View Map
{
"weekViewMap": {
"20111128-day3": {
"numActivities": 3,
"userTypeMap": {
"25120904": "T",
"25801329": "M",
"25867415": "M"
}
},
@dav-rob
dav-rob / ElasticSearch Bulk Indexing
Created October 19, 2011 09:52
ElasticSearch Bulk Indexing from JDBC Input
package ****.elasticsearch.index;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.commons.logging.Log;