execute nested array return empty result android n1ql query

66 views
Skip to first unread message

djougue basso

unread,
Jun 17, 2018, 3:28:11 AM6/17/18
to Couchbase Mobile
hi i would like to very condition on array json child of document but the result returned by the query is always empty despite the fact that there is some elements satisfaying the condition.
consider the json:
{
  "parcours": [
    {
      "dateArrete": null,
      "dateFinService": null,
      "datePriseService": "15-6-2018",
      "fonction": "CHEF DES TRAVAUX",
      "numeroArrete": null,
      "posteActuel": true,
      "structure": "",
      "structureId": -1,
      "typeStructure": null
    },
    {
      "dateArrete": null,
      "dateFinService": "",
      "datePriseService": "",
      "fonction": "",
      "numeroArrete": null,
      "posteActuel": false,
      "structure": "",
      "structureId": -1,
      "typeStructure": null
    }
  ],
  "personnel": {
    "LangueEnseignement": "Francais",
    "address": null,
    "arrondissementOrigine": "",
    "arrondissementOrigineConjoint": "",
    "birthDate": "15-5-2018",
    "dateIntegration": "15-6-2018",
    "departementOrigine": "NYONG ET KELLE",
    "departementOrigineConjoint": "",
    "email": null,
    "etatSante": null,
    "firstName": "duvduv",
    "fonctionConjoint": "",
    "grade": "PCEG",
    "indice": null,
    "langueEnseignement": "Francais",
    "lastName": null,
    "matricule": "d-012768",
    "nbEnfant": 5,
    "nbEnfantScolarise": 0,
    "nomConjoint": "",
    "phoneNumber": 679494639,
    "picturePath": null,
    "placeBirth": "bertoua",
    "regionOrigine": "LT",
    "regionOrigineConjoint": "",
    "secondPhoneNumber": -1,
    "sexe": "M",
    "situationMatrimoniale": "DIVORCE(E)",
    "specialite": "DROIT"
  },
  "type": "personnel"
}

I wrote the following android query:

VariableExpression varParcoursItem =  ArrayExpression.variable("parcoursItem");
VariableExpression varParcoursItemStructureId = ArrayExpression.variable("parcoursItem.structureId");
Database database = DatabaseManager.getDatabase();

Query query = QueryBuilder
.select(SelectResult.all())
.from(DataSource.database(database))
.where(Expression.property("type").equalTo(Expression.string("personnel")
.and(ArrayExpression.any(varParcoursItem).in(Expression.property("parcours"))
.satisfies(varParcoursItemStructureId.equalTo(Expression.intValue(-1))))));

but the result returned is empty despite the fact that the previous json satifies condition. Please where is the mistake
Reply all
Reply to author
Forward
0 new messages