jolicode / jolicode/elastically

Support for scripted fields

Open
#203 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
257
Forks
43
Avg merge
38m
Merged PRs (30d)
1

Description

Hello

There is option to map scripted field to model class?

I have query:
```
_source' => true,
'script_fields' => [
'likedMe' => [
'script' => [
'source' => "params._source.likedUsers.contains(params.userId)",
'params' => [
'userId' => $user->getId()->toString(),
]
]
]
]
```

Output from ES looks like:
```
{
"took": 9,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 1,
"relation": "eq"
},
"max_score": 1.0,
"hits": [
{
"_index": "users",
"_id": "0193ba7e-21e4-7d68-b4d2-69052c4b4d38",
"_score": 1.0,
"_source": {
"id": "0193ba7e-21e4-7d68-b4d2-69052c4b4d38",
"identifier": "ac3",
"slug": "ac3",
"createdAt": "2024-12-12T10:50:48+00:00",
"likedUsers": [
"019397c5-fff2-7e5d-81e5-6215a2dc2fa6"
],
"likedMe": false,
"data": {
"location": {
"name": "New York",
"lat": 41.12,
"long": -71.34
}
}
},
"fields": {
"likedMe": [
true
]
}
}
]
}
}
```

There is a option to overwrite `_source.likedMe` with custom field from `fields.likedMe`?
Fields `_source.likedMe` its always false because its default PHP model property value.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.