2015-11-08 26 views
0

我就如何建立一個索引谷歌數據存儲做下面的查詢工作不等式過濾谷歌數據存儲指數:如何配置與股權過濾

SELECT * FROM地方類型=「東西」和geohashes> ='XXX'AND geohashes < ='YYY'

我創建了以下索引。然而,當我這樣做查詢,我得到了一個錯誤信息:「沒有匹配的索引中找到」

<?xml version="1.0" encoding="utf-8"?> 
<datastore-indexes 
    autoGenerate="true"> 
    <datastore-index kind="Place" ancestor="false"> 
     <property name="geohashes" direction="asc" /> 
     <property name="geohashes" direction="desc" /> 
     <property name="type" direction="asc" /> 
    </datastore-index> 
    <datastore-index kind="Place" ancestor="false"> 
     <property name="geohashes" direction="asc" /> 
     <property name="type" direction="asc"/> 
    </datastore-index> 
    <datastore-index kind="Place" ancestor="false"> 
     <property name="geohashes" direction="desc" /> 
     <property name="type" direction="asc" /> 
    </datastore-index> 
</datastore-indexes> 

如何建立在數據存儲的索引,這樣我可以做上面的查詢感謝

+0

您是否嘗試過運行在谷歌控制檯查詢? – shivg

+0

是的。但結果是「您需要一個索引來執行此查詢。」 – Kit

+0

感謝您的回覆。我曾嘗試在屬性「geohash」上使用> =,<=同時進行查詢。有用。但是,當我在查詢中添加更多屬性時。他們向我顯示錯誤信息。 – Kit

回答

1

運行嗎?!有資料儲存庫查詢,則必須提供非常具體的指標,這一點很重要,因爲它允許數據存儲,以保證所有的查詢與結果集的大小規模,您的數據集。

在一般情況下,我會建議先運行你的代碼使用本地開發服務器,這將生成appropr用於查詢的iate索引。你可以用命令run the server

appengine-java-sdk/bin/dev_appserver.sh <war-location> 

當您運行數據存儲查詢,文件datastore-indexes-auto.xml將在您的應用程序目錄中生成。這將包含您執行的任何查詢的必要索引。

對於您的特定查詢,您的索引屬性出現故障。

index documentation

的索引表中的行首先被祖先,然後通過分選的屬性值,在在索引定義中指定的順序。

對於您的具體問題,你需要的指數:

<datastore-index kind="Place" ancestor="false"> 
    <property name="type" direction="asc"/> 
    <property name="geohashes" direction="asc" /> 
</datastore-index> 
+0

它的工作原理。謝謝! – Kit

相關問題