Uploaded image for project: 'Planet4'
  1. Planet4
  2. PLANET-5982

Index blocks with attributes

XMLWordPrintable

    • Icon: Task Task
    • Resolution: Won't Fix
    • Icon: Should have Should have
    • None
    • None
    • 5
    • Blocks (all), Search
    • Sprint #156, Sprint #157, Sprint #158, Sprint #159, Sprint #160

      We already sync a post's data to ElasticSearch on each update, and it's relatively easy to sync additional data. The ElasticPress plugin provides hooks for this.

      If we sync the post's blocks with their names and attributes, we could query ElasticSearch for posts that have a certain block, or even a certain block with specific attributes. This would allow us to do efficient targeted purges of Cloudflare cache. For example: if a new post is published, and it has a "foo" tag. We get the id of the tag (e.g. 123), and do an ElasticPress query for all posts that have a Covers block that has tag id 123 in the tags attribute. This query can then directly return the post url to be purged, which we currently already have in ES.

      This involves adding a mapping for the structure of the data we want to sync, which seems the trickiest part since it needs to be set up correctly to make it searchable. Then syncing the data and querying it should be straightforward.

      Structure:

      post
        - title: "The post" // exists
        - description: "The description" // exists
        - post_content: "The post content" // exists
        - blocks: [
          {name: "planet4/covers", attributes: [{name: "tags", value: [123]}, {name: "title", value:"covers title"}]},
          {name: "core/paragraph", attributes: []},
          // ...
        ]

       

            Unassigned Unassigned
            pvincent Pieter Vincent (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: