0

GAE にデプロイすると以下のエラーが発生しますが、アプリケーションはローカル サーバーで正常に動作しています。

com.google.appengine.api.datastore.DatastoreNeedIndexException: no matching index found.
The suggested index for this query is:
    <datastore-index kind="Order" ancestor="false" source="manual">
        <property name="employee" direction="asc"/>
        <property name="__key__" direction="asc"/>
        <property name="route" direction="asc"/>
    </datastore-index>

必要なインデックスが GAE で提供されている場合でも

__key__ ?                                           Serving     6202    1 MByte
__key__ ? , route ?                                 Serving     6202    1 MByte
__key__ ? , route ? , __key__ ?                     Serving     6202    2 MBytes
customerName ? , __key__ ?                          Serving     6202    1 MByte
customerName ? , employee ? , oDate ? , __key__ ?   Serving     6202    2 MBytes
customerName ? , oDate ? , __key__ ?                Serving     6202    1 MByte
employee ? , __key__ ? , route ?                    Serving     6202    1 MByte
employee ? , __key__ ?                              Serving     6202    1 MByte
employee ? , oDate ? , __key__ ?                    Serving     6202    1 MByte
oDate ? , __key__ ?                                 Serving     6202    1 MByte
route ? , __key__ ?                                 Serving     6202    1 MByte

また、datastore-indexes.xml の内容もエラーの提案に従って更新されます。

<?xml version="1.0" encoding="utf-8"?>
<datastore-indexes autoGenerate="true">
    <!-- Used 7 times in query history -->
    <datastore-index kind="Order" ancestor="false" source="manual">
        <property name="employee" direction="asc"/>
        <property name="__key__" direction="asc"/>
        <property name="route" direction="asc"/>
    </datastore-index>

    <!-- Used 16 times in query history -->
    <datastore-index kind="LineItem" ancestor="false" source="manual">
        <property name="itemName" direction="asc" />
        <property name="orderID" direction="asc" />
        <property name="quantity" direction="asc" />
    </datastore-index>
</datastore-indexes>

そして、これが私が実行しようとしているクエリです。

Filter employeeFilter = new FilterPredicate("employee",FilterOperator.EQUAL, saleRepID);
Filter startTimeFilter = new FilterPredicate(Entity.KEY_RESERVED_PROPERTY,FilterOperator.GREATER_THAN_OR_EQUAL, startOrderKey);
Filter endTimeFilter = new FilterPredicate(Entity.KEY_RESERVED_PROPERTY,FilterOperator.LESS_THAN_OR_EQUAL, endOrderKey);

logger.warning("Creating a Final filter to find a uniquely visited routes by that employee in that particular time range");
Filter finalFilterForRoutes = CompositeFilterOperator.and(endTimeFilter, CompositeFilterOperator.and(employeeFilter,startTimeFilter));

logger.warning("Finding a uniquely visited routes by that employee on that particular day");
    QueryResultList<Entity> allRoutesVisited = datastore.prepare(new Query("Order").addProjection(
                                    new PropertyProjection("route",String.class)).setDistinct(true)
                                    .setFilter(finalFilterForRoutes))
                                    .asQueryResultList(FetchOptions.Builder.withDefaults());
4

1 に答える 1

1

残念ながら、検証コードにバグがあります (これは既に修正されており、1.8.5 または 1.8.6 でリリースされるはずです)。このクエリは、'__key__' と 'route' の両方をインデックスの並べ替え順序の最初の値にする必要があるため、実際にはサポートされていません (これは不可能です)。このクエリを実行する場合は、メモリ内の「ルート」の個別の値を収集する必要があります。

于 2013-09-29T14:53:22.320 に答える