delete yg_data
put yg_data
,"filename":,
"labels":,
"satellite":,
"sensor":,
"acquisitiontime":,
"cloudiness":,
"resoltion":,
"tracknum":,
"path_":,
"row_":,
"ltlon":,
"ltlat":,
"rtlon":,
"rtlat":,
"rblon":,
"rblat":,
"lblon":,
"geolocation":}
}}put/yg_data/_doc/1}
put/yg_data/_doc/2}
put/yg_data/_doc/
3put
/yg_data/_doc/
4put
/yg_data/_doc/
5put
/yg_data/_doc/
6put
/yg_data/_doc/
7
說明get
/yg_data/_search
}}
get
/yg_data/_search}}
}
get
/yg_data/_search},
,"relation"
:"intersects"}}
},}}
]}}}
get
/yg_data/_search},
,"relation"
:"intersects"}}
},,"relation"
:"intersects"}}
}]}}
]}}}
get
/yg_data/_search},
}]}}
}
/**
* 使用者語句查詢 分頁檢索es
* @param label 標籤資訊
* @param picplaces 地點資訊
* @param pictimest 時間資訊
* @param pictimeed 時間資訊
* @param pageno 分頁 當前頁面
* @param pagesize 分頁 頁面大小
* @return es檢索文件資訊
* @throws ioexception querybuilders.geoshapequery 可能引發polygon不合法異常
*/public pagepicturedoc getimgsbycontentwithesquery
(string label, list
picplaces, string pictimest,
string pictimeed,
int pageno,
int pagesize)
throws ioexception
// es與地區邊界的匹配查詢
geoquery = geoquery.
should
(querybuilders.
geoshapequery
("geolocation"
,new
polygonbuilder
(poly)).
relation
(shaperelation.intersects));
}}}// time match es的acquisitiontime欄位按照yyyy-mm-dd格式與使用者查詢的時間字段匹配
rangequerybuilder timequery = querybuilders.
rangequery
("acquisitiontime").
format
("yyyy-mm-dd"
)// true表示包括邊界 在from中是下界,在to中是上界
.from
(pictimest,
true).
to(pictimeed,
true);
// query
boolean queryflag =
false
; boolquerybuilder boolquerybuilder = querybuilders.
boolquery()
;if(label != null &&!""
.equals
(label))if
(pictimest != null &&!""
.equals
(pictimest))if
(picplaces != null &&
!picplaces.
isempty()
)// 是否為有效查詢
if(queryflag)
else
}
public
class
contextrepo
if(pagesize <0)
int from =
(pageno-1)
* pagesize;
client client =
getclient()
; searchresponse response = client.
preparesearch()
.setfrom
(from)
.setsize
(pagesize)
.setquery
(query)
.execute()
.actionget()
;// 將搜尋結果封裝到itembasedoc持久化物件
list
searchhits = arrays.
aslist
(response.
gethits()
.gethits()
);int totalsize = response.
gethits()
.gettotalhits()
.value;
return searchhits;
}}
es之地理位置查詢
為了方便學習es的地理位置查詢,這裡準備了一些地理座標為測試資料,每一條資料都包含城市名稱和地理座標兩個字段。首先把下面的內容儲存到geo.json檔案中 然後建立乙個索引 put geo settings filter filter filter filter filter 4 查詢geo sha...
ES聚合查詢例項
disable coord false adjust pure negative true boost 1 explain false,aggregations view code disable coord false adjust pure negative true boost 1 expla...
Hibernate 處理查詢 in 字句
在處理hibernate的實體查詢,一般可以採用多種方式處理複雜的查詢,比如hql的靈活使用,query的外部引數化賦值等。但是,對於in字句在sql中的處理,也會出現,不過,一般不建議使用這樣的sql處理,轉而採用關聯條件來處理這種查詢。一般對於可變引數傳入在in字句中,大概有下面幾種總結的方法 ...