Quantcast
Channel: Spring Community Forums - NoSQL
Viewing all articles
Browse latest Browse all 128

MONGODB: index on nested document

$
0
0
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

Viewing all articles
Browse latest Browse all 128

Trending Articles