在我的后端应用程序中,我有一个Entity PositionAugmented
@Entity
public class PositionAugmented {
@Id
Long id;
@Index
Position position;
@Index
String username;
...
}
其中职位变量
public class Position{
Date time;
double latitude;
double longitude;
@Index
public Address address;
...
}
和地址由
组成public class Address{
@Index public String city;
...
}
使用objectify,我需要找到属于特定城市的所有PositionAugmented实例。 我正在使用的实际查询如下:
public List<PositionAugmented> getPositionAugmentedsByCity(String aCity){
Query query = ofy().load().type(PositionAugmented.class).
filter("position.address.city=", aCity);
return query.list();
}
不幸的是,这给我一个空列表。 我看到这个后尝试了这个查询:
wiki objectify v5 queries on embedded class
任何帮助将不胜感激
答案 0 :(得分:0)
我认为你错过了indexed-property-name和&#39; =&#39;之间的空格。试试这个:var data = ".xxx[val1, val2, val3, val4, val5]";
var pattern = @"
[^[]+ # Consume anything that is *not* a brace
# but don't match it , (.xxx is the first anchor)
\[ # Starting brace consumed
( # Start of match captures
(?<Token>[^\s,\]]+) # Named Match grouping called `Token` where one or more
# of anything not a space, comma or end brace is captured.
[\s,\]]+ # Consume the token's `,` or space or final bracket.
)+ # End match captures, one or more
] # Ending brace."
;
// IgnorePatternWhitespace allows us to comment the pattern,
// does not affect parser processing.
Regex.Match(data, pattern, RegexOptions.IgnorePatternWhitespace)
.Groups["Token"]
.Captures
.OfType<Capture>()
.Select(cp => cp.Value);