I have 3 servers,i find that same query has different result
ip1:9200 and ip2:9200 return right result,but ip3:9200 return wrong result.
ip1 and ip2 result:
{
"took": 3,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 7,
"max_score": null,
"hits": [
{
......
ip3 result:
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 3,
"failed": 0
},
"hits": {
"total": 3,
"max_score": null,
"hits": [
{
......
client initmode :
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())));
}
query mode:
SearchRequestBuilder requestBuilder = client.prepareSearch(config.getIndex()).setTypes(config.getType())
.setPreference("_primary")
.setQuery(boolQueryBuilder)
.setFrom(Integer.valueOf(startIndex))
.setSize(Integer.valueOf(pageSize))
.addSort(sortBuilder);
This problem has been bothering me for a long time. Please help me,thanks!