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

Search indexing only supports two levels of JSON nesting #4237

Open
dafeder opened this issue Jul 24, 2024 · 0 comments
Open

Search indexing only supports two levels of JSON nesting #4237

dafeder opened this issue Jul 24, 2024 · 0 comments
Labels

Comments

@dafeder
Copy link
Member

dafeder commented Jul 24, 2024

Current Behavior

If we have a dataset schema that contains more than two levels of nested objects, adding a field to the index from deeper in the tree will produce an error.

Expected Behavior

We should be able to add a field from anywhere in the dataset schema to the DKAN search index without issue.

Steps To Reproduce

  1. Build a site and replace the dataset schema with this file
  2. POST this dataset:
{
    "title": "Test dataset",
    "description": "This is a test dataset",
    "accessLevel": "public",
    "modified": "2019-01-01",
    "keyword": ["test", "dataset"],
    "distribution": [
        {
            "title": "Test distribution",
            "format": "text/csv",
            "downloadURL": "https://example.com/test.csv",
            "dctconformsto": [
                {
                    "dct_standard": "https://www.w3.org/TR/vocab-dcat-2/"
                }
            ]
        }
    ]
}
  1. Go into the search API index configuration, and add the field "dctconformsto" to the index
  2. Re-index

You will see an error that includes

Error: Object of class stdClass could not be converted to string in Drupal\search_api\Plugin\search_api\data_type\StringDataType->getValue() (line 23 of /var/www/html/docroot/modules/contrib/sea
rch_api/src/Plugin/search_api/data_type/StringDataType.php).

Environment

- OS:
- Node:
- npm:

Relevant log output

No response

Anything else?

See the discussion in #4180 where this was discovered. We need a more recursive kind of logic in Drupal\metastore_search\ComplexData\Dataset to allow adding fields that may be nested in objects nested in arrays nested in other objects, etc.

@dafeder dafeder added the bug label Jul 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant