Announcement Announcement Module
Collapse
No announcement yet.
Mongo Document Format Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Mongo Document Format

    Hi is it possible to Group by array contents? I have been stuck for some time trying all manner of things.

    Code:
    @Document
    public class Record {
    	
    	@Id
    	private RecordKey RecordKey;
    	
            private Date recordTimestamp;
    	
    	private List<String> contributors = new ArrayList<String>();
    
            private List<MongoString> languages = new ArrayList<MongoString>();
    
    ...
    
    public class MongoString implements Serializable {
    	
    	private static final long serialVersionUID = 9042077321090421097L;
    	
    	private String value = null;
    ....
    
    // Few of my attempts...
    
    mongoOps.group("languages", GroupBy.key("value").initialDocument("{ count: 0 }").reduceFunction("function(doc, prev) { prev.count++; }"), XObject.class);
    
    mongoOps.group("record", GroupBy.key("languages").initialDocument("{ count: 0 }").reduceFunction("function(doc, prev) { prev.count++; }"), XObject.class);
    I am trying to group by the distinct values in the arrays rather than the actual distinct arrays. I have tried DbRef custom objects etc. They are of an undetermined size so need to be a collection of some sort. I also had a go with map reduce also but that was as much of a success.

    It does appear to be a function of MongoDB
    Last edited by msduk; Mar 22nd, 2012, 08:43 PM.
Working...
X