I'm using spring-data-couchbase, and I'm trying to create a backing view for a findAll()
query. I've created a document named ClusterCodeXref
, and a view named allClusterCodeXrefs
matching my model class. I need to filter the based on the calling class (did I state that right?), because this bucket will be used for other applications too.
My model looks like this:
package com.company.aad.xref.model;
@Document
public class ClusterCodeXref implements Serializable {
private static final long serialVersionUID = 3072475211055736282L;
@Id
String id;
@Field("SET_NUM")
String setNum;
...
}
This is the repository class:
@Repository
public interface ClusterCodeXrefRepository
extends CrudRepository<ClusterCodeXref, String> {
@View
List<ClusterCodeXref> findAllClusterCodeXrefs();
}
And this is my view:
function (doc, meta) {
if (doc._class == "com.company.aad.xref.model.ClusterCodeXref") {
emit(meta.id, null);
}
}
But when I run the findAllClusterCodeXrefs()
query, no rows are returned. If I take the if-statement out, I get everything I expect. What am I doing wrong?
Apparently the _class
field isn't automatically added to imported data. I need to add _class
to my dataset (which I imported from a CSV file) manually.