Skip to content
This repository has been archived by the owner on Jan 18, 2022. It is now read-only.

Make Queries Configurable #3

Closed
trieloff opened this issue Oct 30, 2019 · 1 comment
Closed

Make Queries Configurable #3

trieloff opened this issue Oct 30, 2019 · 1 comment
Labels
enhancement New feature or request

Comments

@trieloff
Copy link
Collaborator

trieloff commented Oct 30, 2019

In addition to allowing to specify how the index should be populated, the queries.yaml should also specify the queries that can be run against the index. See the example below:

#
# index configuration for theblog (hackathon vii)
#
version: 1

indices:
  blog-posts:
    source: html
    fetch: https://helix-norddal-anfibiacreativa.project-helix.page/{path}
    ranking:
      - "desc(date)"
      - typo
      - words
      - filters 
    properties:
      author:
        select: .blog-author p a
        value: "{textContent}"
        faceted: true
      title:
        select: h1:first-of-type
        value: "{textContent}"
      date:
        select: ".blog-author p:nth-child(2)"
        value: "{parseTimestamp(\"[POSTED ON] MM-DD-YYYY\")}"
      topics:
        select: .blog-topics.default > ul > li
        value: "{textContent}"
        faceted: true
      hero:
        select: main > div > img:first-of-type
        value: "{src}"
    queries:
      all:
        query: *
        hitsPerPage: 25
        cache: 10 minutes
      by-author
        parameters:
          - author
        query: *
        filters: author:{author}
       cache: 5 minutes

This would enable two query endpoints:

  • _query/blog-posts/all
  • _query/blog-posts/by-author?author=Lars+Trieloff

The query configuration would be read during hlx publish and the proper VCL would be generated to forward the query to Algolia or MongoDB.

@trieloff
Copy link
Collaborator Author

@sepehrfakour

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants