Skip to content

Instantly share code, notes, and snippets.

View johtani's full-sized avatar

Jun Ohtani johtani

View GitHub Profile
@johtani
johtani / result_of_query.json
Last active August 29, 2015 13:56
Different behavior fields in nested object. If store="yes", Elasticsearch does not return stored data. If store="no", Elasticsearch return stored data from _source.
{
"took": 3,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 1,
public class TermFreqQuerySample {
public static void main(String... args){
Settings settings = ImmutableSettings.settingsBuilder().put("cluster.name","test-es-cluster").build();
Client client = new TransportClient(settings)
.addTransportAddress(new InetSocketTransportAddress("192.168.30.114",9300));
QueryBuilder query = QueryBuilders.queryString("java")
.defaultField("text");
@johtani
johtani / monitoring_cluster_snippet.yml
Last active August 29, 2015 13:55
marvel separate cluster settings
######## Marvel ##########
marvel.agent.enabled: false
@johtani
johtani / wildcard_sample.txt
Last active January 2, 2016 18:49
elasticsearch-ML : "Searching indexed fields without analysing" sample
curl -XPUT "http://localhost:9200/wildcard_sample"
curl -XPOST "http://localhost:9200/wildcard_sample/users/_mapping" -d'
{
"users": {
"properties": {
"User_Name": {
"type": "multi_field",
"fields": {
"User_Name": {
@johtani
johtani / error_schema_snippet.xml
Last active January 1, 2016 11:59
synonymでエラーになるパターン
<fieldType name="text_ja_synonym" class="solr.TextField" positionIncrementGap="100" autoGeneratePhraseQueries="false">
<analyzer>
<tokenizer class="solr.JapaneseTokenizerFactory" mode="search" />
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true" tokenizerFactory="solr.JapaneseTokenizerFactory"/>
</analyzer>
</fieldType>
@johtani
johtani / Solr_4_6_0_CHANGES.txt
Created November 26, 2013 04:38
Solr 4.6.0のChangesを訳してる途中。
## Versions of Major Components
* Apache Tika 1.4
* Carrot2 3.8.0
* Velocity 1.7 and Velocity Tools 2.0
* Apache UIMA 2.3.1
* Apache ZooKeeper 3.4.5
## Upgrading from Solr 4.5.0
@johtani
johtani / range_query_sample_exec.json
Created November 18, 2013 07:41
I execute "sample_exec.json" step by step. I receive response both requests: no prefix and exists prefix.
# create index
curl -XPUT "http://localhost:9200/restful"
# post mapping
curl -XPOST "http://localhost:9200/restful/events/_mapping" -d'
{
"events" : {
"dynamic_templates" : [ {
"template_string" : {
"mapping" : {
@johtani
johtani / double_mapping_test.json
Created November 18, 2013 03:16
Mappingでdoubleを指定して、文字列で数値データ登録してみたらどうなるか。 ※0.90.7で実験
# index作成
curl -XPUT localhost:9200/hoge
# mappingの指定
curl -XPUT localhost:9200/hoge/fuga/_mapping -d '{
"fuga" : {
"numeric_detection" : false,
"properties" : {
"Resp_Time" : {"type" : "double"}
}
}
@johtani
johtani / exact_response.json
Last active December 27, 2015 18:39
rangeフィルタの動作の違い。 string型のフィールドに対して、rangeフィルタで数値範囲で検索するとどうなるか。 文字列として、10から20という範囲で検索するため、100とか2とかもヒットしてしまう。 「register_data.json:登録データ」 「range_query.json:レンジクエリ」 「exact_response.json:無理やりだけど、望んだ結果」
クエリ
curl -XPOST "http://localhost:9200/numeric_test/hoge/_search" -d'
{
"query": {
"bool": {
"should": [
{
"wildcard": {
"fuga": {
"value": "1?"
@johtani
johtani / gist:7248574
Created October 31, 2013 12:04
My local curl command erase single quotation, doc['year'].
curl -XPOST "http://httpbin.org/post" -d'
{
"script_fields": {
"correctYear": {
"script": "doc['year'].value - 1800"
}
},
"query": {
"term": {
"title": "crime"