dimanche 12 avril 2015

MongoDB Index Not Created After MongoTemplate.insert(batchToSave, entityClass)

I have the following model class:



public class Price extends ModelBase<Price> implements Comparable<Price>{
@Indexed
@Field("cid")
private String companyId;

@Field("dt")
private LocalDate date;

@Field("cp")
private double closePrice;

@Field("vl")
private double volume;

...

}


With indexed 'cid', unfortunately when I run 'db.price.getIndexes()' from the mongo console I get:



> db.price.getIndexes()
[
{
"v" : 1,
"key" : {
"_id" : 1
},
"name" : "_id_",
"ns" : "th.price"
}
]


Which means that 'cid' has not be used as index.


Pices are inserted in batch using MongoTemplate.insert(batchToSave, entityClass)


Is this the reason of this issue? Can I insert multiple prices at once and index the documents at the same time?


Aucun commentaire:

Enregistrer un commentaire