From 764d883b5ea3bdc06abbec548b6df0511e567978 Mon Sep 17 00:00:00 2001
From: linwe <872216996@qq.com>
Date: Tue, 03 Sep 2024 09:46:05 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/binlog' into binlog
---
src/main/java/org/springblade/es/service/ElasticsearchDocumentService.java | 45 ++++++++++++++++++++++++++-------------------
1 files changed, 26 insertions(+), 19 deletions(-)
diff --git a/src/main/java/org/springblade/es/service/ElasticsearchDocumentService.java b/src/main/java/org/springblade/es/service/ElasticsearchDocumentService.java
index 919324f..7fcfe2d 100644
--- a/src/main/java/org/springblade/es/service/ElasticsearchDocumentService.java
+++ b/src/main/java/org/springblade/es/service/ElasticsearchDocumentService.java
@@ -18,7 +18,10 @@
import org.elasticsearch.client.indices.GetIndexRequest;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
-import org.elasticsearch.index.reindex.*;
+import org.elasticsearch.index.reindex.BulkByScrollResponse;
+import org.elasticsearch.index.reindex.DeleteByQueryRequest;
+import org.elasticsearch.index.reindex.UpdateByQueryRequest;
+import org.elasticsearch.script.Script;
import org.elasticsearch.script.ScriptType;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHits;
@@ -46,7 +49,6 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
-import org.elasticsearch.script.Script;
import java.io.IOException;
import java.util.ArrayList;
@@ -173,9 +175,9 @@
// 刷新索引,确保文档可搜索
client.indices().refresh(new RefreshRequest(esParam.getIndexName()), RequestOptions.DEFAULT);
} catch (IOException e) {
- e.printStackTrace();
+// e.printStackTrace();
}
- System.out.println("批量插入结果: " + !bulkResponse.hasFailures());
+// System.out.println("批量插入结果: " + !bulkResponse.hasFailures());
}
}
// 返回
@@ -226,9 +228,9 @@
// 刷新索引,确保文档可搜索
client.indices().refresh(new RefreshRequest(esParam.getIndexName()), RequestOptions.DEFAULT);
} catch (IOException e) {
- e.printStackTrace();
+// e.printStackTrace();
}
- System.out.println("批量插入结果: " + !bulkResponse.hasFailures());
+// System.out.println("批量插入结果: " + !bulkResponse.hasFailures());
}
}
// 返回
@@ -261,6 +263,7 @@
"tableId", household.getId().toString(),
"tableName", "jczz_household",
"title", household.getName(),
+ "relationship", household.getRelationship(),
"name", household.getName(),
"phone", household.getPhoneNumber(),
"idCard", household.getIdCard(),
@@ -277,9 +280,9 @@
// 刷新索引,确保文档可搜索
client.indices().refresh(new RefreshRequest(esParam.getIndexName()), RequestOptions.DEFAULT);
} catch (IOException e) {
- e.printStackTrace();
+// e.printStackTrace();
}
- System.out.println("批量插入结果: " + !bulkResponse.hasFailures());
+// System.out.println("批量插入结果: " + !bulkResponse.hasFailures());
}
}
// 返回
@@ -328,9 +331,9 @@
// 刷新索引,确保文档可搜索
client.indices().refresh(new RefreshRequest(esParam.getIndexName()), RequestOptions.DEFAULT);
} catch (IOException e) {
- e.printStackTrace();
+// e.printStackTrace();
}
- System.out.println("批量插入结果: " + !bulkResponse.hasFailures());
+// System.out.println("批量插入结果: " + !bulkResponse.hasFailures());
}
}
// 返回
@@ -362,7 +365,7 @@
"articleType", article.getArticleType()
);
} catch (IOException e) {
- e.printStackTrace();
+// e.printStackTrace();
}
}
}
@@ -388,7 +391,7 @@
"communityCode", placeService.getCommunityCode(place.getId())
);
} catch (IOException e) {
- e.printStackTrace();
+// e.printStackTrace();
}
}
}
@@ -414,7 +417,7 @@
"communityCode", houseService.getCommunityCode(house.getId())
);
} catch (IOException e) {
- e.printStackTrace();
+// e.printStackTrace();
}
}
}
@@ -428,6 +431,10 @@
@Async
public void addHousehold(EsParam esParam, HouseholdEntity household) {
if (elasticsearchSync) {
+ // 如果关系为空,则默认为19
+ if (household.getRelationship() == null) {
+ household.setRelationship(19);
+ }
try {
indexDocument(esParam.getIndexName(),
"tableId", household.getId().toString(),
@@ -441,7 +448,7 @@
"communityCode", householdService.getCommunityCode(household.getId())
);
} catch (IOException e) {
- e.printStackTrace();
+// e.printStackTrace();
}
}
}
@@ -618,9 +625,9 @@
// 输出操作结果
boolean acknowledged = deleteResponse.isAcknowledged();
- System.out.println("索引删除成功: " + acknowledged);
+// System.out.println("索引删除成功: " + acknowledged);
} catch (IOException e) {
- e.printStackTrace();
+// e.printStackTrace();
}
}
}
@@ -638,7 +645,7 @@
try {
indexDocument(esParam.getIndexName(), str);
} catch (IOException e) {
- e.printStackTrace();
+// e.printStackTrace();
}
return true;
}
@@ -688,7 +695,7 @@
// 刷新索引,确保文档可搜索
client.indices().refresh(new RefreshRequest(esParam.getIndexName()), RequestOptions.DEFAULT);
} catch (IOException e) {
- e.printStackTrace();
+// e.printStackTrace();
}
}
}
@@ -772,7 +779,7 @@
BulkByScrollResponse bulkResponse =
client.deleteByQuery(deleteByQueryRequest, RequestOptions.DEFAULT);
} catch (IOException e) {
- e.printStackTrace();
+// e.printStackTrace();
}
}
return true;
--
Gitblit v1.9.3