Announcement Announcement Module
Collapse
No announcement yet.
MONGODB: index on nested document Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • MONGODB: index on nested document

    I have a need to have one document which contains a nested document. The nested document contains a field for which I would like an index. Here is an example:

    First Document:

    Code:
    @Entity
    @Table(name="logItems")
    public class LogItem {
        @Id
        private ObjectId id;
        private String level;
        private String message;
        private StackTrace stackTrace;
    .
    .
    .
    }
    
    @Document
    public class StackTrace {
        @Index
        private string exceptionName;
        private String[] stack;
    .
    .
    .
    }
    What I would expect is the following index definition

    db.logItems.ensureIndex({ "stackTrace.exceptionName" : 1 },{ "name" : "StacktraceExceptionNameIndex" });

    The above is how I can do this in mongo shell.

    I need a way to do this using spring-data and mongo

    Thanks in advance
Working...
X