Skip to content

Instantly share code, notes, and snippets.

View lukas-vlcek's full-sized avatar

Lukáš Vlček lukas-vlcek

View GitHub Profile
curl -XPUT 'http://localhost:9200/testdb2/' -d '{index : {number_of_shards : 3, number_of_replicas : 0}}'
@lukas-vlcek
lukas-vlcek / this is fine
Created February 2, 2011 16:37
This is fine
Query:
{
"query" : { "match_all" : {}}, "size" : 0,
"facets" : {
"message-id" : {
"terms" : {
"field" : "message-id",
"size" : 3,
"order" : "count"
@lukas-vlcek
lukas-vlcek / gist:814372
Created February 7, 2011 13:40
some exception
[2011-02-07 14:28:05,821]ERROR186038[Thread-16] - org.jboss.search.client.IndexMboxFile$Batch.execute(IndexMboxFile.java:82) - Indexing failed:
org.elasticsearch.transport.RemoteTransportException: [Janus][inet[/192.168.122.1:9300]][indices/index/shard/index]
Caused by: org.elasticsearch.index.engine.IndexFailedEngineException: [weld][0] Index failed for [mail#db199550911051438p2f675865jc9230bf30a9f8f4email.gmail.comdev615]
at org.elasticsearch.index.engine.robin.RobinEngine.index(RobinEngine.java:396)
at org.elasticsearch.index.shard.service.InternalIndexShard.index(InternalIndexShard.java:273)
at org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:180)
at org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction.performOnPrimary(TransportShardReplicationOperationAction.java:428)
at org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction.access$
require 'rubygems'
require 'net/http'
require 'yaml'
require 'json'
# kill the index
delete = Net::HTTP::Delete.new("/test")
# create again
create_index = Net::HTTP::Post.new("/test")
@lukas-vlcek
lukas-vlcek / gist:827320
Created February 15, 2011 09:45
Client hanging after thread pool refactoring.
Full thread dump OpenJDK 64-Bit Server VM (19.0-b09 mixed mode):
"elasticsearch[cached]-pool-1-thread-7" daemon prio=10 tid=0x00007f678c002800 nid=0x5909 waiting on condition [0x00007f677b8f7000]
java.lang.Thread.State: TIMED_WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x00000000c3e27618> (a java.util.concurrent.SynchronousQueue$TransferStack)
at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:226)
at java.util.concurrent.SynchronousQueue$TransferStack.awaitFulfill(SynchronousQueue.java:453)
at java.util.concurrent.SynchronousQueue$TransferStack.transfer(SynchronousQueue.java:352)
at java.util.concurrent.SynchronousQueue.poll(SynchronousQueue.java:903)
org.elasticsearch.search.SearchParseException: [indexName][2]: query[ConstantScore(*:*)],from[-1],size[-1]: Parse Failure [Failed to parse source [{"query":{"query_string":{"query":"*"}},"facets":{"histogram":{"date_histogram":{"field":"date","interval":"1w"}}}}]]
at org.elasticsearch.search.SearchService.parseSource(SearchService.java:470)
at org.elasticsearch.search.SearchService.createContext(SearchService.java:385)
at org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:215)
at org.elasticsearch.search.action.SearchServiceTransportAction.sendExecuteQuery(SearchServiceTransportAction.java:134)
at org.elasticsearch.action.search.type.TransportSearchCountAction$AsyncAction.sendExecuteFirstPhase(TransportSearchCountAction.java:74)
at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:191)
at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.access$000(TransportSearchTypeActio
curl -XPUT ${host}/_template/template_mail -d '
{
"template" : "*",
"settings" : {
"number_of_shards" : 3,
"number_of_replicas" : 1
},
"mappings" : {
"mail" : {
"_index" : { "enabled" : true },
@lukas-vlcek
lukas-vlcek / gist:869979
Created March 14, 2011 22:08
Fixed highlight query for alheim
// start a fresh ES node with default setup and index a document
curl -PUT 'http://localhost:9200/devalexbk10/usr/1' -d '{
{
"id":2741,
"title":"John Doe",
"creationDate":"2011-02-23 13:44:14",
"login":"jdoe@localhost.com",
"firstName":"John",
"lastName":"Doe",
"locations":["1864","2","1597","1598"]
@lukas-vlcek
lukas-vlcek / gist:903622
Created April 5, 2011 13:47
Histogram count issue
curl -XDELETE http://localhost:9200/indexname
curl -XPUT http://localhost:9200/indexname
echo
curl -XPUT 'http://localhost:9200/indexname/histogram/_mapping?pretty=1' -d '
{
"histogram":
{
"properties":
{
@lukas-vlcek
lukas-vlcek / gist:930958
Created April 20, 2011 10:33
Indexing documents in a batch
public void execute() {
int c = threadCounter.incrementAndGet();
log.info("Starting a batch with {} items. ({} threads are running)", mails.size(), c);
for (JsonMail mail : mails) {
try {
IndexResponse indexResponse = ElasticSearchClient.getClient().prepareIndex()
.setIndex(indexName)
.setType("mail")
.setId(mail.getMessageId())
.setSource(mail.getJsoncontent())