Skip to content

Instantly share code, notes, and snippets.

View lukas-vlcek's full-sized avatar

Lukáš Vlček lukas-vlcek

View GitHub Profile
@lukas-vlcek
lukas-vlcek / gist:931398
Created April 20, 2011 13:58
Is this correct usage of ActionListener ?
ElasticSearchClient.getClient().prepareIndex()
.setIndex(indexName)
.setType("mail")
.setId(mail.getMessageId())
.setSource(mail.getJsonContent())
.execute( new ActionListener<IndexResponse>() {
public void onResponse(IndexResponse indexResponse) {
log.info("Indexing ok: {}", indexResponse);
}
@lukas-vlcek
lukas-vlcek / elasticsearch_highlight.sh
Created April 21, 2011 08:29 — forked from karmi/elasticsearch_highlight.sh
Highligthing in ElasticSearch; number_of_fragments bug
# (Re)create the index
curl -X DELETE "http://localhost:9200/highlight"
curl -X PUT "http://localhost:9200/highlight"
# Put some mapping, do not store the content (so it has to be retrieved from `_source` but you have to set term_vector = with_positions_offsets
curl -X PUT "http://localhost:9200/highlight/document/_mapping" -d '
{
"document" : {
"properties" : {
"body" : {"type" : "string", "store" : "no", "term_vector" : "with_positions_offsets"}
@lukas-vlcek
lukas-vlcek / gist:936267
Created April 22, 2011 08:25
Different API for the same timeout ?
// set timeout in actionGet()
IndexResponse indexResponse = ElasticSearchClient.getClient().prepareIndex()
.setIndex(_myIndexName_)
.setType(_myType_)
.setId(_myID_)
.setSource(_someContent_)
.execute()
.actionGet(5000); // <-- timeout set here
// using setTimeout
@lukas-vlcek
lukas-vlcek / gist:1011913
Created June 7, 2011 08:45
Mapping template for mail type #bbuzz 2011
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:1012051
Created June 7, 2011 11:18
Full search query #BBUZZ 2011
{
"from" : 0,
"query" : {
"filtered" : { "query" : { "query_string" : { "query" : "jboss server" } },
"filter": {
"and" : [
{"range" : { "date" : {"from":"2007-07-25","to":"2010-12-16"}}},
{"terms" : { "_index" : ["weld"]}},
{"terms" : {"mail_list" : ["dev"]}},
{"terms" : {"from.not_analyzed" : [ "Galder Zamarreno <galder.zamarreno@redhat.com>","Pete Muir <pmuir@redhat.com>"]}}
@lukas-vlcek
lukas-vlcek / gist:1012096
Created June 7, 2011 12:05
Document detail query #BBUZZ 2011
{
fields : [ "message_id", "message_id_original", "subject_original", "subject", "date", "from","first_text_message", "first_html_message", "references", "project", "mail_list", "document_url" ],
query : {
bool : {
should : [{
query_string : { query : userQuery }
}],
must : { term : { message_id : documentId }}
}
},
@lukas-vlcek
lukas-vlcek / gist:1012115
Created June 7, 2011 12:17
Thread by references #BBUZZ 2011
{
from : 0, size : count,
fields : [ "date", "subject", "mail_list", "message_id", "message_id_original", "from.not_analyzed", "references" ],
script_fields : {
millis : { script : "doc['date'].date.millis" }
},
query : {
constant_score : {
filter : {
or : {
@lukas-vlcek
lukas-vlcek / gist:1024849
Created June 14, 2011 13:05
Word delimiter and synonym filter in action
// content of analysis/synonym.txt
funny => goofy
curl -XDELETE localhost:9200/test
curl -XPUT 'localhost:9200/test?pretty=1' -d '
{
"settings" : {
"analysis" : {
"analyzer" : {
[2011-06-15 13:39:39,894][WARN ][cluster.metadata ] [Oneg the Prober] [myIndex] failed to create
org.elasticsearch.common.inject.CreationException: Guice creation errors:
1) Error injecting constructor, java.lang.NullPointerException
at org.elasticsearch.index.analysis.AnalysisService.<init>(AnalysisService.java:64)
while locating org.elasticsearch.index.analysis.AnalysisService
for parameter 3 at org.elasticsearch.index.mapper.MapperService.<init>(MapperService.java:95)
while locating org.elasticsearch.index.mapper.MapperService
for parameter 2 at org.elasticsearch.index.mapper.attachment.RegisterAttachmentType.<init>(RegisterAttachmentType.java:35)
while locating org.elasticsearch.index.mapper.attachment.RegisterAttachmentType
@lukas-vlcek
lukas-vlcek / gist:1075067
Created July 10, 2011 22:55
Test of attachments plugin
#!/bin/sh
host=localhost:9200
curl -X DELETE "${host}/test"
curl -X PUT "${host}/test" -d '{
"settings" : { "index" : { "number_of_shards" : 1, "number_of_replicas" : 0 }}
}'