Ejemplo n.º 1
0
 /**
  * 模糊匹配
  *
  * @param keys
  * @return
  */
 private List<LocationIndex> fuzzyQuery(String key) {
   String[] keys = key.trim().split(" ");
   for (int i = 0; i < keys.length; i++) {
     keys[i] = "type_i:" + LocationIndex.TYPE_LEAFLET + " AND description_ss:" + keys[i] + "~";
   }
   return solrService.query(LocationIndex.class, StringUtils.join(keys, " OR "));
 }
Ejemplo n.º 2
0
 /**
  * @param request
  * @return
  */
 @RequestMapping(value = "locateTile", method = RequestMethod.GET)
 public ResponseEntity<JSONObject> locateTile(HttpServletRequest request) {
   JSONObject result = new JSONObject();
   Float x = getFloat(request, "x");
   Float y = getFloat(request, "y");
   Integer size = getInteger(request, "size"); // 这个不会出现flaot, 应该是2的N次幂
   if (x == null || y == null || size == null) {
     result.put("error", "参数有误,坐标或大小无法取得。");
   } else {
     String query = "type_i:" + LocationIndex.TYPE_LEAFLET;
     query += " AND coordX_f:[" + (x - size / 2) + " TO " + (x + size / 2) + "]";
     query += " AND coordY_f:[" + (y - size / 2) + " TO " + (y + size / 2) + "]";
     List<LocationIndex> list = solrService.query(LocationIndex.class, query);
     logger.info("Query area : " + query + " , hits : " + list.size());
     result.put("result", parseJson(list));
   }
   return new ResponseEntity<JSONObject>(result, HttpStatus.OK);
 }