Skip to content

help, how to get results when using scripts_field #20

Closed
@stoneriverheart

Description

@stoneriverheart

If scripts_field is used, how can we get results of fields execution?

query{
  profile(
    opts: {
      body: {
        script_fields: {
          results:{
            script:{
              lang: "painless"
              inline: "Date n = new Date(); Date b = new Date(doc['birthday'].value); DateFormat f = new SimpleDateFormat('yyyy-MM-dd'); return Period.between(LocalDate.parse(f.format(b)), LocalDate.parse(f.format(n))).getYears();"
            }
          }
        }
    query: {
      bool: {
        must: {
      term: {
        systemId__keyword: {
          value: "test-xxxxxx"
        }
      }
        }
      }
    }
      }
    }
  ) {
    took
    count
    hits {
      _source {
        fields {
          results <--no hits.
        }
      }
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions