现在有es集群,3台服务器,发现相同的查询条件,返回的结果不同
ip1:9200和ip2:9200返回结果正确,ip3:9200返回结果缺失
ip1和ip2的结果如下:
{
"took": 3,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 7,
"max_score": null,
"hits": [
{
......
ip3的结果如下:
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 3,
"failed": 0
},
"hits": {
"total": 3,
"max_score": null,
"hits": [
{
......
client初始化方式:
Settings settings = Settings.builder()
.put("cluster.name", config.getEsClusterName())
.put("client.transport.sniff", true)
.put("client.transport.ping_timeout", "60s").build();
try {
client = new PreBuiltTransportClient(settings);
String[] ips = config.getEsClusterIp().split(",");
for (String ip : ips) {
client.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(ip), Integer.valueOf(config.getEsClusterPort())));
}
查询方式:
SearchRequestBuilder requestBuilder = client.prepareSearch(config.getIndex()).setTypes(config.getType())
.setPreference("_primary")
.setQuery(boolQueryBuilder)
.setFrom(Integer.valueOf(startIndex))
.setSize(Integer.valueOf(pageSize))
.addSort(sortBuilder);
哪位大神指点一下,困扰我很久了,非常感谢!
ip1:9200和ip2:9200返回结果正确,ip3:9200返回结果缺失
ip1和ip2的结果如下:
{
"took": 3,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 7,
"max_score": null,
"hits": [
{
......
ip3的结果如下:
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 3,
"failed": 0
},
"hits": {
"total": 3,
"max_score": null,
"hits": [
{
......
client初始化方式:
Settings settings = Settings.builder()
.put("cluster.name", config.getEsClusterName())
.put("client.transport.sniff", true)
.put("client.transport.ping_timeout", "60s").build();
try {
client = new PreBuiltTransportClient(settings);
String[] ips = config.getEsClusterIp().split(",");
for (String ip : ips) {
client.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(ip), Integer.valueOf(config.getEsClusterPort())));
}
查询方式:
SearchRequestBuilder requestBuilder = client.prepareSearch(config.getIndex()).setTypes(config.getType())
.setPreference("_primary")
.setQuery(boolQueryBuilder)
.setFrom(Integer.valueOf(startIndex))
.setSize(Integer.valueOf(pageSize))
.addSort(sortBuilder);
哪位大神指点一下,困扰我很久了,非常感谢!
1 个回复
Cheetah
赞同来自: