No field found for [] in mapping with types []

I have following query

{
  "query": {
    "function_score": {
      "query": {
        "match_all": {}
      },
      "functions": [
        {
          "script_score": {
            "script": {
              "lang": "painless",
              "source": """
              if (doc['likedBy'].length>0) { return 1;} else {return 0;}"""
            }
          },
          "weight": 100
        }
      ]
    }
  }
}

Where likedBy is nested field and contains values like

 [
            {
              "userId" : "5f50928d4d1395228e5c1c42",
              "updatedTime" : 1599183429,
              "_id" : "5f519a454439702cd42ab2de"
            },
            {
              "userId" : "5f6ecae581a21f046aaa8d5a",
              "updatedTime" : 1601098376,
              "_id" : "5f6ed28881a21f046aaa8de9"
            }
]

and [] for empty . But above query shows error saying No field found for [likedBy] in mapping with types []

1 Like

hi, I have the same problem. were you able to fix it?

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.