Skip to content

Instantly share code, notes, and snippets.

View ofavre's full-sized avatar

Olivier Favre ofavre

  • WonderPush
  • Paris, France
View GitHub Profile
@ofavre
ofavre / gist:998638
Created May 30, 2011 09:15
Testing performance for constant score queries in ElasticSearch 0.16.1

Purpose

I need to perform special ranking based on some criteria.
Before playing with my precise need, I’ve tested different possibilities, namely:

  • Using built-in queries
  • Using custom script in mvel (the fastest scripting facility according to ES documentation)
  • Using a native script plugin written in Java

I present here the results of the comparative performance test

@ofavre
ofavre / gist:1000701
Created May 31, 2011 15:37
Using boolean queries and fields in ElasticSearch 0.16.1
curl -XDELETE 'http://127.0.0.1:9202/test/bool'
{"ok":true}
curl -XPUT 'http://127.0.0.1:9202/test/bool/_mapping' -d '{"bool":{"properties":{"bool":{"type":"boolean"}}}}'
{"ok":true,"acknowledged":true}
curl -XGET 'http://127.0.0.1:9202/test/bool/_mapping'
{"bool":{"properties":{"bool":{"type":"boolean"}}}}
curl -XPOST 'http://127.0.0.1:9202/test/bool' -d '{"bool":"yes"}'
{"ok":true,"_index":"test","_type":"bool","_id":"mC0iSbDGRi6ypBBUBOpe0Q","_version":1}
curl -XPOST 'http://127.0.0.1:9202/test/bool' -d '{"bool":"T"}'
{"ok":true,"_index":"test","_type":"bool","_id":"EUMdXikfQ0apBcS4tIFPFA","_version":1}
@ofavre
ofavre / highlight.sh
Created June 23, 2011 09:42
Problem in highlighting with stemming analyzers using most default parameters
curl -XDELETE 'localhost:9200/index'
{"ok":true,"acknowledged":true}
curl -XPUT 'localhost:9200/index' -d '{"settings":{"index":{"number_of_shards":1,"number_of_replicas":0}}}'
{"ok":true,"acknowledged":true}
# The mapping I would like
curl -XPUT 'localhost:9200/index/type/_mapping' -d '{
"type":{
"_source":{ "enabled":false },
"_analyzer":{ "path":"lang" },
"properties":{
@ofavre
ofavre / recreation.sh
Created June 23, 2011 12:56
include_in_all ignored for multi_fields
curl -XDELETE 'localhost:9200/index'
{"ok":true,"acknowledged":true}
curl -XPUT 'localhost:9200/index' -d '{"settings":{"index":{"number_of_shards":1,"number_of_replicas":0}}}'
{"ok":true,"acknowledged":true}
# The mapping I would like
curl -XPUT 'localhost:9200/index/type/_mapping' -d '{
"type":{
"_source":{ "enabled":false },
"_all":{ "enabled":true },
"properties":{
@ofavre
ofavre / recreation.sh
Created July 5, 2011 12:29
Highlight not working for multi-fields if each subfield is not stored, "main subfield" stored, and _source disabled
set -v
# Delete an eventual previous index
curl -XDELETE 'localhost:9200/bugindex'
# Create an index
curl -XPUT 'localhost:9200/bugindex' -d '{
"settings" : {
"index" : {
"number_of_shards" : 1,
@ofavre
ofavre / recreation.sh
Created July 15, 2011 13:55
ElasticSearch Scroll API (documentation) bug
set -v
curl -XDELETE 'localhost:9200/index'
curl -XPUT 'localhost:9200/index' -d '{"settings":{"index":{"number_of_shards":4,"number_of_replicas":0}}}'
curl -XPUT 'localhost:9200/index/type/_mapping' -d '{
"type":{
[2011-07-28 10:47:08,638][DEBUG][action.index ] [Adaptoid] [index][0], node[h04seeuQQAuniYzZszGDVA], [P], s[STARTED]: Failed to execute [index {[index][type][9223372036854775807], source[{"integer":9223372036854775807}]}]
org.elasticsearch.index.mapper.MapperParsingException: Failed to parse [integer]
at org.elasticsearch.index.mapper.core.AbstractFieldMapper.parse(AbstractFieldMapper.java:309)
at org.elasticsearch.index.mapper.object.ObjectMapper.serializeValue(ObjectMapper.java:565)
at org.elasticsearch.index.mapper.object.ObjectMapper.parse(ObjectMapper.java:440)
at org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:561)
at org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:490)
at org.elasticsearch.index.shard.service.InternalIndexShard.prepareIndex(InternalIndexShard.java:289)
at org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:185)
at
@ofavre
ofavre / DynamicSettings-study.md
Last active December 14, 2015 20:29
Study of Dynamic Settings in ElasticSearch 0.90.0.Beta1

Dynamic Settings in ElasticSearch 0.90.0.Beta1

Sources of dynamic settings

  • org.elasticsearch.index.settings.IndexDynamicSettingsModule
  • org.elasticsearch.cluster.settings.ClusterDynamicSettingsModule
  • org.elasticsearch.node.settings.NodeSettingsService.Listener

Cluster settings

@ofavre
ofavre / frankzappasmoustache-recreation.sh
Created March 15, 2013 11:12
Curl recreation for Combo Analyzer demo with frankzappasmoustache's configuration
#!/bin/bash
# Install ES 0.90.0.Beta1
[ -f elasticsearch-0.90.0.Beta1.tar.gz ] || wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.0.Beta1.tar.gz -O elasticsearch-0.90.0.Beta1.tar.gz
mkdir es-combo-demo
tar xf elasticsearch-0.90.0.Beta1.tar.gz -C es-combo-demo
cd es-combo-demo/elasticsearch-0.90.0.Beta1
# Configure it
cat >config/elasticsearch.yml <<EOF
cluster.name: elasticsearch-demo-combo
@ofavre
ofavre / deletebyquery-has_parent-NPE.sh
Created April 22, 2013 13:38
NPE while using Delete By Query with Has Parent.
#!/bin/sh
curl -XPOST 'localhost:9200/index' -d '{index:{number_of_shards:1,number_of_replicas:0}}'
curl -XPUT 'localhost:9200/index/parent/_mapping' -d '{parent:{properties:{}}}'
curl -XPUT 'localhost:9200/index/child/_mapping' -d '{child:{"_parent":{type:"parent"}}}'
curl -XPUT 'localhost:9200/index/parent/parent1' -d '{name:"super shay"}'