Coder Social home page Coder Social logo

Comments (3)

DiegoPino avatar DiegoPino commented on July 17, 2024

advances for MYSQL

E.g.

Given a strawberry field in DB

mysql> select * from node__field_descriptive_metadata;
  +----------------+---------+-----------+-------------+----------+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  | bundle         | deleted | entity_id | revision_id | langcode | delta | field_descriptive_metadata_value                                                                                                                                                                                                                                 |
  +----------------+---------+-----------+-------------+----------+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  | digital_object |       0 |        45 |          54 | en       |     0 | {"a_uri": {"0": "http://www.wikidata.org/wiki/Q2", "1": "http://www.wikidata.org/wiki/Q1"}, "label": "A new Label", "reasons_and_justifications": "Because i love metadata and repository Workflows", "strawberry_field_widget_source_entity_uuid": ""}          |
  | digital_object |       0 |        46 |          57 | en       |     0 | {"a_uri": {"0": "https://www.wikidata.org/wiki/Q125133", "1": "http://www.wikidata.org/wiki/Q1"}, "label": "The label", "reasons_and_justifications": "Another test here", "strawberry_field_widget_source_entity_uuid": "5e20c237-3f05-4a5c-9c01-9c97ebd3340f"} |
  +----------------+---------+-----------+-------------+----------+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

Get first URIS of a set

mysql> select entity_id, field_descriptive_metadata_value->>'$.a_uri."0"' AS `wikiuri`   FROM `node__field_descriptive_metadata`   WHERE     field_descriptive_metadata_value->"$.a_uri" IS NOT NULL;
+-----------+---------------------------------------+
| entity_id | wikiuri                               |
+-----------+---------------------------------------+
|        45 | http://www.wikidata.org/wiki/Q2       |
|        46 | https://www.wikidata.org/wiki/Q125133 |
+-----------+---------------------------------------+
2 rows in set (0.00 sec)

Now get them all

mysql> select entity_id, field_descriptive_metadata_value->>"$.a_uri" AS `wikiuri`   FROM `node__field_descriptive_metadata`   WHERE     field_descriptive_metadata_value->"$.a_uri" IS NOT NULL;
+-----------+----------------------------------------------------------------------------------------+
| entity_id | wikiuri                                                                                |
+-----------+----------------------------------------------------------------------------------------+
|        45 | {"0": "http://www.wikidata.org/wiki/Q2", "1": "http://www.wikidata.org/wiki/Q1"}       |
|        46 | {"0": "https://www.wikidata.org/wiki/Q125133", "1": "http://www.wikidata.org/wiki/Q1"} |
+-----------+----------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)

In a Drupal SQL pseudo query it would be added via ::addExpression

Super fast!

from strawberryfield.

DiegoPino avatar DiegoPino commented on July 17, 2024

Ok, I got this done. Views can access now, via, SQL, JSON properties. Will commit before code freeze. Right now use I'm giving this is to filter by 'rdf:type' properties directly from the JSON content. I had to access $query directly to avoid the overreacting Drupal escaping of operators. '->>'

from strawberryfield.

DiegoPino avatar DiegoPino commented on July 17, 2024

This is probably not relevant anymore with the whole set of Key Name providers we have and Solr Indexing still, do not want to close it because it demonstrates how SQL can be used to access JSON data too. Means. DO NOT CLOSE

from strawberryfield.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.