This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# (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"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -XPUT ${host}/_template/template_mail -d ' | |
{ | |
"template" : "*", | |
"settings" : { | |
"number_of_shards" : 3, | |
"number_of_replicas" : 1 | |
}, | |
"mappings" : { | |
"mail" : { | |
"_index" : { "enabled" : true }, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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>"]}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
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 }} | |
} | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
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 : { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// content of analysis/synonym.txt | |
funny => goofy | |
curl -XDELETE localhost:9200/test | |
curl -XPUT 'localhost:9200/test?pretty=1' -d ' | |
{ | |
"settings" : { | |
"analysis" : { | |
"analyzer" : { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 }} | |
}' |