Skip to content

Instantly share code, notes, and snippets.

View dadoonet's full-sized avatar
🇪🇺
From Europe with ❤️

David Pilato dadoonet

🇪🇺
From Europe with ❤️
View GitHub Profile
@dadoonet
dadoonet / stacktrace.log
Created April 1, 2012 19:38
Error while updating settings on a closed index
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'esClient2' defined in class path resource [fr/pilato/spring/elasticsearch/xml/es-settings-test-context.xml]: Invocation of init method failed; nested exception is org.elasticsearch.indices.IndexMissingException: [twitter] missing
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.Abstrac
@dadoonet
dadoonet / test.sh
Created June 21, 2012 13:41
Test case for multifield fields
# Remove old data
curl -XDELETE "http://localhost:9200/french"
# Create index with settings
curl -XPOST "http://localhost:9200/french/" -d '
{
"settings":{
"index":{
"analysis":{
"analyzer":{
@dadoonet
dadoonet / result.json
Created June 27, 2012 22:06
Using Terms Stats Facet on "edgeNGram" key field
{
"took" : 3,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 3,
"failed" : 2,
"failures" : [ {
"index" : "dpitestcase",
"shard" : 3,
curl -XPOST 'http://localhost:9200/spokely_development_users' -d '{"mappings":{"user":{"properties":{"id":{"index":"not_analyzed","type":"string"},"first_name":{"type":"string"},"last_name":{"type":"string"},"headline":{"type":"string"},"jobs":{"type":"object"},"educations":{"type":"object"},"skills":{"type":"string"},"linkedin_summary":{"type":"string"},"linkedin_groups":{"type":"string"},"linkedin_certifications":{"type":"string"},"fb_user_id":{"index":"not_analyzed","include_in_all":false,"type":"string"},"fb_connections":{"index":"not_analyzed","include_in_all":false,"type":"string"},"linkedin_id":{"index":"not_analyzed","include_in_all":false,"type":"string"},"linkedin_connections":{"index":"not_analyzed","include_in_all":false,"type":"string"},"is_active":{"type":"boolean","include_in_all":false},"is_email_confirmed":{"type":"boolean","include_in_all":false}}}},"settings":{}}'
curl -XPOST 'http://localhost:9200/spokely_development_users/user/3457' -d '{"fb_connections":[],"fb_user_id":"1314809","first_
@dadoonet
dadoonet / create.sh
Created July 25, 2012 19:00
Count Query with not_analyzed mapping
curl -XDELETE 'http://localhost:9200/myindex'
curl -XPUT 'http://localhost:9200/myindex'
curl -XPUT 'http://localhost:9200/myindex/myindext/_mapping' -d '{
"myindext": {
"properties": {
"user": {
"type": "string"
},
"message": {
@dadoonet
dadoonet / search.sh
Created July 28, 2012 10:33 — forked from anonymous/search more types.
searching on more types but results only for one type, please help!
curl -XDELETE 'http://localhost:9200/pms'
curl -XPUT 'http://localhost:9200/pms/Building/1' -d '
{
"id":11,
"building":{
"address":{
"street2":"test_street2_11",
"region":"test_region_11",
"id":11,
@dadoonet
dadoonet / ex1.java
Created September 17, 2012 19:43
ParisJUG_2012_09_11
public class Client {
public static void main(String[] args) {
int NBTEST = 100;
long all = 0;
for (int i=0; i < NBTEST; i++) {
long start = System.nanoTime();
c1();
all += System.nanoTime() - start;
}
System.out.println("Mean: " + all / NBTEST);
@dadoonet
dadoonet / attachment.sh
Created October 17, 2012 17:49 — forked from lukas-vlcek/gist:1075067
Test of attachments plugin
#!/bin/sh
http://cloud.github.com/downloads/elasticsearch/elasticsearch/elasticsearch-0.19.10.zip
unzip elasticsearch-0.19.10.zip
elasticsearch-0.19.10/bin/plugin -install elasticsearch/elasticsearch-mapper-attachments/1.6.0
elasticsearch-0.19.10/bin/elasticsearch
sleep 10
@dadoonet
dadoonet / restart.sh
Created November 5, 2012 21:00
Restart Twitter River Node on error
#!/bin/bash
file=/usr/local/elasticsearch/elasticsearch-0.19.8/logs/es-twitter.log
if grep -q "TwitterException" $file
then
echo `date +'%Y-%m-%d %H:%M:%S'` ": Restarting ES" >> /home/ec2-user/es.log
/etc/rc.d/init.d/elasticsearch stop
rm $file
/etc/rc.d/init.d/elasticsearch start
fi
@dadoonet
dadoonet / testMust.java
Created November 27, 2012 15:48
Test case for must clause
/**
* @throws Exception
*/
@Test
public void createSuggest() throws Exception {
node.client().prepareIndex("es1index", "type1").setSource("{\"email\" : \"abc@otherdomain.com\", \"firstname\" : \"abc\"}").execute().actionGet();
node.client().prepareIndex("es1index", "type1").setSource("{\"email\" : \"abc@gmail.com\", \"firstname\" : \"abc\"}").execute().actionGet();
node.client().prepareIndex("es1index", "type1").setSource("{\"email\" : \"xyz@gmail.com\", \"firstname\" : \"xyz\"}").execute().actionGet();