相关文章推荐
买醉的伏特加  ·  【Mongoose 7.x ...·  7 小时前    · 
大鼻子的领带  ·  ConvertOperators.ToStr ...·  7 小时前    · 
谦虚好学的椰子  ·  C#Winform ...·  6 小时前    · 
瘦瘦的山羊  ·  android - ...·  1 年前    · 
    Query query1 = OfyService.ofy().load().type(CargoEntity.class).
       project("imageUrl", "latitude", "longitude").distinct(false); //filter("group", group);
    // Execute the query:
    List<Entity> results = query1.list();
    logger.warning("(Query from datastore results.isEmpty()) : " + (results.isEmpty()));
    logger.warning("(Group = ) : " + group);
    if (!results.isEmpty()) {
        logger.warning("(Query from datastore results.size()) : " + (results.size()));
        //Create STRTree-Index.
        STRtree strTree = new STRtree();
        GeometryFactory gf = new GeometryFactory();
        //Loop through the  result list from DataStore.
        for (Entity result : results) {
            STRLeaf leaf = new STRLeaf((float)result.getProperty("latitude"), (float)result.getProperty("longitude"), (String)result.getProperty("imageUrl"));
            Coordinate coord = new Coordinate(leaf.getLongitude(), leaf.getLatitude());
            Point point = gf.createPoint(coord);
            //Add result to index.
            strTree.insert(point.getEnvelopeInternal(), leaf);

我真的是个新手,所以可能是我漏掉了什么明显的东西。 不过我确实在开发者控制台中看到了索引。 这是我的实体中的属性看起来像什么。

@Entity
@Index
@Cache
public class CargoEntity {
//datastore key
private String imageUrl;
private float latitude;
private float longitude;
private String group;
@Unindex
private int rating;
@Unindex
private Blob image;
@Unindex
private String email;
@Unindex
private String userName;
@Unindex
private String description;
@Unindex
private Date date;
@Unindex
private String blobKey;
@Unindex
private String type;
@Unindex
private boolean flag;
@Unindex
private int photoOrientation;
public CargoEntity() {
//getters and setters below