I have a relatively "simple" collection and query requirement.... I need help with the right syntax. :)
Here is the document definition in Java.
public class Entity {
private String _id = null;
private String name = null;
private Map<String, Object> attributes = new Hashmap<String, Object>();
}
Sample data inserted are like
{
"_id": "pk1",
"name": "Item 1",
"attributes": {
"en": { "attr1": "value 1 in English", "attr2": "value 2 in English"},
"es": { "attr1": "value 1 in Spanish", "attr2": "value 2 in Spanish"}
}
}
{
"_id": "pk2",
"name": "Item 2",
"attributes": {
"en": { "attr1": "value 1 in English", "attr2": "value 2 in English"},
"ms": { "attr1": "value 1 in Malay", "attr2": "value 2 in Malay"}
}
}
The language (key) of the map is an example of user provided (thus unpredictable) keys. I want a simple query syntax to be able fetch documents based on the attributes. For example, I want to put in a criteria "'attr1' contains 'value 1'" and query returns both docs, 'Item 1' and 'Item 2'.
Thanks in advance.