Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with falsy value in setting mappings #923

Open
tung-huynh opened this issue Mar 2, 2020 · 0 comments
Open

Issue with falsy value in setting mappings #923

tung-huynh opened this issue Mar 2, 2020 · 0 comments

Comments

@tung-huynh
Copy link

tung-huynh commented Mar 2, 2020

I see that we had the issue with the falsy value caused by the misuse of array_filter function.

For my case i am using this mapping

/**
 * @var string
 * @ES\Property(type="text", settings={"index"=false})
 */
 private $url;

The actual result which is not expected (please ignore the nested type)

{
    "properties": {
        "url": {
            "type": "text"
        }
     }
}

The expected result should be

{
    "properties": {
        "url": {
            "type": "text",
            "index": false #<-----this_is_what_we_want
        }
     }
}

I believe the root cause was this line https://github.com/ongr-io/ElasticsearchBundle/blob/v6.2.2/Mapping/DocumentParser.php#L169

When changing it to this, it works fine

$mapping[$annotation->getName() ?? Caser::snake($name)] = array_filter(
    $fieldMapping,
    function ($value) {
        return null !== $value;
    }
);
- PHP version: 7.3
- Elasticsearch version: 6.x
- Bundle version: 6.x
- Symfony version: 5.x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant