Hi,
I have defined the following view
com.couchbase.lite.View viewItemsByNrInregistrareAn = database.getView(“NrInregistrareAn”);
viewItemsByNrInregistrareAn.setMap(new Mapper() {
@Override
public void map(Map<String, Object> document, Emitter emitter) {
if (document.get(“type”) != null) {
String type = String.valueOf(document.get(“type”));
if (“docreg”.equals(type)) {
String NrInregistrare = String.valueOf(document.get(“NrInregistrare”));
Integer An = Integer.valueOf(document.get(“An”).toString());
emitter.emit(new Object[]{An, NrInregistrare}, document);
}
}
}
}, "8.0");
by means of which I try to find documents using the following query
query.setStartKey(Arrays.asList(intAn));
query.setEndKey(Arrays.asList(intAn, strNrInreg, new HashMap<String, Object>()));
My data for (as string) NrInregistrare=[123, 124, 125, 1251, 130, 131, 140, 1411, 200]
Results for NrInreg/NrInregistrare:
- ‘125’: 123, 124, 125
- ‘126’: 123, 124, 125, 1251
- ‘130’: 123, 124, 125, 1251, 130
It works but not the way I expect…I want to get all the documents for which the property document.get(“NrInregistrare”) starts with NrInreg, something like WHERE NrInregistrare LIKE NrInreg+’%’
Also, for the query
query.setStartKey(Arrays.asList(dtpAn.getYear(), NrInreg));
query.setEndKey(Arrays.asList(dtpAn.getYear(), NrInreg, new HashMap<String, Object>()))
I get only the documents for which the property document.get(“NrInregistrare”) = NrInreg
thanks,
catalin