2012-05-28 125 views
0

這裏的:-) 我們有兩個班,AppointmentHairdresser,兩者具有相同,一個祖先(靜態最終鍵:topParent)的東西代表HairSalon關鍵。該Appointment包含Hairdresser這樣的:
物化谷歌DataSore查詢

@Parent 
    public Key parent; 
    public Key hairdresserKey;` 


但是,當我們試圖篩選出的任命,不拿出一個結果。 hairdresserKey == null中的父母可能是一個線索,但我們現在有點卡住了。

那麼有人可以告訴我們這個查詢有什麼問題嗎?

非常感謝!

 appointment.hairdresserKey = new Key<Hairdresser>(topParent, Hairdresser.class, appointment.hairdresser.id); 
    appointment.parent = topParent; 

    Key<Hairdresser> queryKey = new Key<Hairdresser>(topParent, Hairdresser.class, appointment.hairdresser.id); 

    Objectify ofyTransaction = ObjectifyService.beginTransaction(); 
    try { 

     List<Key<Appointment>> previousTimeSlotOneHour = ofyTransaction.query(Appointment.class) 
       .ancestor(topParent) 
       .filter("hairdresserKey", appointment.hairdresserKey) 
       .filter("timeSlot", appointment.timeSlot.getPreviousTimeSlot()) 
       .filter("LENGTH", 1.0d).listKeys(); 

要clearify更多一些,這是約會如何設置:

@Unindexed 

公共類任用實現Serializable {

@Id 
public Long id; 
@Indexed 
public TimeSlot timeSlot; 

@Transient 
public WorkDay workDay; 

@Transient 
public Customer customer; 
public Key customerKey; 

public int END_TIME_HOUR; 
public int END_TIME_MINUTES; 

@Indexed 
public TREATMENT treatment = TREATMENT.TREATMENT_CUT; 
public int revisionNumber = -1; 

/* QUERY Fields */ 
@Indexed 
private String stringDate; 
private double LENGTH; 

@Parent 
public Key parent; 
private Date date; 

@Transient 
public Hairdresser hairdresser; 
public Key hairdresserKey; 
+0

您是否爲{ancestor,hairdresserKey,timeSlot,LENGTH} *和*單個屬性索引創建了所有這些字段的多屬性索引? – stickfigure

回答

0

發現這一點:

這是幾乎可以肯定索引問題。爲了讓該查詢工作,你必須定義兩個指標:

上referenceKeyToC 在多性能指標{祖先,referenceKeyToC} 單的性能指標在物化3.x中,屬性有單一性能指標默認情況下,但如果您已將@Unindexed添加到類B,則需要將@Indexed放在referenceKeyToC上。 多屬性索引在datastore-indexes.xml中定義。如果你在開發模式下運行這個查詢,環境應該爲你提供所需的XML片段。

這樣做的竅門!感謝您指出正確的方向!