Skip to content

Instantly share code, notes, and snippets.

View martijnvg's full-sized avatar

Martijn van Groningen martijnvg

  • Elastic
  • Hoofddorp
View GitHub Profile
@martijnvg
martijnvg / bulk.java
Created January 29, 2013 13:09
Java bulk api example
for (...) {
String id = ...;
String source = ...;
BulkRequestBuilder request = client1.prepareBulk();
for (int j = 0; j < BATCH; j++) {
counter++;
request.add(Requests.indexRequest("test").type("type1").id(id).source(source);
}
BulkResponse response = request.execute().actionGet();
@martijnvg
martijnvg / 1.sh
Created January 28, 2013 16:35
Nested type and nested facets
curl -s -XPUT 'localhost:9200/test1' -d '{
"mappings" : {
"records" : {
"properties" : {
"coords" : {
"type" : "nested",
"properties" : {
}
}
}
@martijnvg
martijnvg / gist:4537938
Created January 15, 2013 11:13
The RobinEngine#loadCurrentVersionFromIndex method. Tweaked the BloomFilteringPostingsFormat to make bloom filter accessible for other users.
private long loadCurrentVersionFromIndex(Term uid) {
Searcher searcher = searcher();
try {
List<AtomicReaderContext> readers = searcher.reader().leaves();
Map<String, Map<String, BloomFilter>> testje = BloomFilteringPostingsFormat.testje;
for (int i = 0; i < readers.size(); i++) {
AtomicReaderContext readerContext = readers.get(i);
BloomFilter bloomFilter = testje.get(((SegmentReader)readerContext.reader()).getSegmentName()).get(uid.field());
if (!bloomFilter.isPresent(uid.bytes())) {
continue;
@martijnvg
martijnvg / 11303660.sh
Created January 3, 2013 15:13
Fvh highlighting with egde ngram token filter.
curl -XDELETE 'localhost:9200/test'
echo
curl -XPUT 'localhost:9200/test?pretty' -d '{
"mappings" : {
"test" : {
"properties" : {
"text" : {
"type" : "string",
"term_vector" : "with_positions_offsets",
curl -XDELETE 'localhost:9200/prototype_2013.01.03?pretty'
echo
curl -XPUT 'localhost:9200/prototype_2013.01.03?pretty' -d '{
"mappings" : {
"chow-clfg" : {
"dynamic" : "true",
"_source" : {
"enabled" : true
},
"_ttl" : {
# Create Index
curl -XPUT 'http://localhost:9200/survey/' -d '{
"number_of_shards": 1,
"number_of_replicas": 0
}'
# Put mapping
curl -XPUT 'http://localhost:9200/survey/response/_mapping' -d '{
"response" : {
@martijnvg
martijnvg / example.sh
Created December 19, 2012 14:49
Creating your own all field with multi-field.
curl -XDELETE 'localhost:9200/test?pretty'
curl -XPUT 'localhost:9200/test?pretty' -d '{
"mappings" : {
"test" : {
"properties" : {
"name" : {
"type" : "multi_field",
"path" : "just_name",
"fields" : {
"name" : {"type" : "string"},
@martijnvg
martijnvg / testcase.sh
Created December 17, 2012 09:38
Simple case demonstrating that mlt fails to work when routing is specified.
curl -XPUT 'localhost:9200/a/a/1?routing=2&refresh' -d '{
"field" : "value"
}'
curl -XGET 'localhost:9200/a/a/1/_mlt?routing=2'
@martijnvg
martijnvg / update-threadpool-settings.sh
Created December 14, 2012 11:44
Example updating thread_pool settings.
curl -XPUT 'localhost:9200/_cluster/settings' -d '{
"transient" : {
"threadpool.management.size" : 5
}
}'
curl -XGET 'localhost:9200/_nodes?thread_pool&format=yaml'
@martijnvg
martijnvg / 2262.sh
Created December 12, 2012 10:55
Match query with multiple tokens as query with and without boost.
#!/bin/bash
curl -XDELETE 'http://localhost:9200/status_index'
echo ""
curl -XPUT 'http://localhost:9200/status_index/?pretty=1' -d '{
"mappings" : {
"status" : {
"properties" : {
"id" : {
"type" : "integer"