Created
May 9, 2013 10:18
-
-
Save keung2640/5546721 to your computer and use it in GitHub Desktop.
Shooting Message not fully read (response) for handler org.elasticsearch.search.action.SearchServiceTransportAction
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
// init es client | |
Settings settings = ImmutableSettings.settingsBuilder() | |
.put("cluster.name", "shooting.dfs") | |
.put("client.transport.sniff", true) | |
.build(); | |
TransportClient client = new TransportClient(settings); | |
client.addTransportAddress(new InetSocketTransportAddress( | |
"localhost" /* hostname */, 9300 /* port */)); | |
// searching | |
SearchRequestBuilder request = client.prepareSearch("product") | |
.setTypes("default") | |
.setSearchType(SearchType.DFS_QUERY_THEN_FETCH) | |
.setQuery(QueryBuilders.queryString("dummy name") | |
.defaultOperator(QueryStringQueryBuilder.Operator.AND) | |
.field("searchable_long_productId_searchable") | |
.field("multi_untouched_string_lang/1/name")) | |
.setFrom(0) | |
.setSize(60) | |
.setExplain(false); | |
SearchResponse searchResponse = request.execute().actionGet(); | |
client.close(); |
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
Server settings: | |
starting 3 nodes(version 0.90.0) with cluster name 'shooting.dfs'. | |
Create index : | |
curl -XPUT 'http://localhost:9200/product/' -d '{ | |
"settings" : { | |
"index" : { | |
"number_of_shards" : 3, | |
"number_of_replicas" : 1 | |
}, | |
"analysis" : { | |
"analyzer" : { | |
"default" : { | |
"type" : "custom", | |
"tokenizer": "standard", | |
"filter" : ["standard", "asciifolding", "lowercase", "stop", "kstem"] | |
} | |
} | |
} | |
} | |
}' | |
Update mappings: | |
curl -XPUT 'http://localhost:9200/product/default/_mapping?pretty=true' -d '{ | |
"_default_" : { | |
"dynamic_templates" : [ | |
{ | |
"multi_untouched_string_template" : { | |
"match" : "multi_untouched_string_*", | |
"mapping" : { | |
"type" : "multi_field", | |
"fields" : { | |
"{name}" : {"type": "{dynamic_type}", "index" : "analyzed", "store" : "no", "include_in_all": "true"}, | |
"{name}_untouched" : {"type": "{dynamic_type}", "index" : "not_analyzed", "store" : "no", "include_in_all": "false"} | |
} | |
} | |
} | |
} | |
] | |
} | |
}' | |
curl -XPUT 'http://localhost:9200/product/default/_mapping?pretty=true' -d '{ | |
"_default_" : { | |
"dynamic_templates" : [ | |
{ | |
"searchable_long_template" : { | |
"match" : "searchable_long_*", | |
"mapping" : { | |
"type" : "multi_field", | |
"fields" : { | |
"{name}" : {"type": "{dynamic_type}"}, | |
"{name}_searchable" : {"type": "string", "index" : "not_analyzed", "store" : "no", "include_in_all": "false"} | |
} | |
} | |
} | |
} | |
] | |
} | |
}' | |
Indexing : | |
curl -XPUT 'http://localhost:9200/product/default/1' -d '{ | |
"searchable_long_productId" : "1", | |
"multi_untouched_string_lang/1/name" : "dummy name" | |
}' | |
curl -XPUT 'http://localhost:9200/product/default/2' -d '{ | |
"searchable_long_productId" : "2", | |
"multi_untouched_string_lang/1/name" : "dummy name" | |
}' | |
curl -XPUT 'http://localhost:9200/product/default/3' -d '{ | |
"searchable_long_productId" : "3", | |
"multi_untouched_string_lang/1/name" : "dummy name" | |
}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment