|
@@ -11,9 +11,7 @@ import org.apache.http.impl.client.BasicCredentialsProvider
|
|
|
import org.apache.http.impl.nio.client.HttpAsyncClientBuilder
|
|
|
import org.apache.http.nio.entity.NStringEntity
|
|
|
import org.apache.http.util.EntityUtils
|
|
|
-import org.elasticsearch.client.{RestClient, RestClientBuilder}
|
|
|
-
|
|
|
-import scala.util.parsing.json.JSON;
|
|
|
+import org.elasticsearch.client.{RestClient, RestClientBuilder};
|
|
|
|
|
|
/**
|
|
|
* @Author: XuJiakai
|
|
@@ -28,7 +26,7 @@ object EsRestUtils {
|
|
|
}
|
|
|
|
|
|
def getIndexResult(json: String): List[Map[String, Any]] = {
|
|
|
- regJson(JSON.parseFull(json))("hits").asInstanceOf[Map[String, Any]]("hits").asInstanceOf[List[Map[String, Any]]]
|
|
|
+ regJson(scala.util.parsing.json.JSON.parseFull(json))("hits").asInstanceOf[Map[String, Any]]("hits").asInstanceOf[List[Map[String, Any]]]
|
|
|
}
|
|
|
|
|
|
def getRestClient(): RestClient = {
|
|
@@ -48,7 +46,7 @@ object EsRestUtils {
|
|
|
s"""
|
|
|
|{
|
|
|
| "_source": {
|
|
|
- | "includes": [ "_id","reg_status","province_code","city_code","county_code","reg_location","estiblish_time","category_code","reg_capital","phones","emails" ]
|
|
|
+ | "includes": [ "_id","reg_status","province_code","city_code","county_code","province_name","city_name","county_name","reg_location","estiblish_time","category_code","category_first","category_second","category_third","reg_capital","phones","emails" ]
|
|
|
| },
|
|
|
| "query": {
|
|
|
| "term": {
|
|
@@ -74,6 +72,9 @@ object EsRestUtils {
|
|
|
|
|
|
val en = indexResponse.getEntity
|
|
|
val res = EntityUtils.toString(en)
|
|
|
+// val id = JSONPath.eval(JSON.parseObject(res), "$.hits.hits[0]._id").asInstanceOf[String]
|
|
|
+// println(id)
|
|
|
+
|
|
|
val list = getIndexResult(res)
|
|
|
if (list.nonEmpty) {
|
|
|
val v = list.head
|
|
@@ -82,11 +83,17 @@ object EsRestUtils {
|
|
|
"cid" -> v("_id").asInstanceOf[String]
|
|
|
, "reg_status" -> map("reg_status")
|
|
|
, "province_code" -> map("province_code")
|
|
|
+ , "province_name" -> map("province_name")
|
|
|
, "city_code" -> map("city_code")
|
|
|
+ , "city_name" -> map("city_name")
|
|
|
, "county_code" -> map("county_code")
|
|
|
+ , "county_name" -> map("county_name")
|
|
|
, "reg_location" -> map("reg_location")
|
|
|
, "estiblish_time" -> map("estiblish_time")
|
|
|
, "category_code" -> map("category_code")
|
|
|
+ , "category_first" -> map("category_first")
|
|
|
+ , "category_second" -> map("category_second")
|
|
|
+ , "category_third" -> map("category_third")
|
|
|
, "reg_capital" -> map("reg_capital")
|
|
|
, "phones" -> map("phones").asInstanceOf[Seq[String]].mkString(",")
|
|
|
, "emails" -> map("emails").asInstanceOf[Seq[String]].mkString(",")
|