Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Matt Wanchap 8 posts 89 karma points
    Sep 06, 2019 @ 02:00
    Matt Wanchap
    0

    Querying for content using the backoffice APIs

    I've been asked to build a custom dashboard in the backoffice of a v7.15 site, which is intended to help content editors find stale content to prioritise for review. For my first basic attempt I've been trying to use the various API services in javascript to simply query content that hasn't been published since X days ago. It's is turning out to be more difficult than I thought! I've tried the following:

    • entityResource.searchAll - only finds nodes matching a search term, lucene query syntax doesn't seem to work
    • entityResource.getAll - gets all documents and then have to iterate through them, there's a filter param but it just seems to be a keyword match
    • contentResource.getById - used while iterating through individual documents, gets every property for every document which performs very poorly
    • contentResource.getByIds - as above but in batches, slightly less horrible but still completely unsuited for this purpose

    Are there any API methods where I can specify even basic query parameters to accomplish something like "get content where published date < whatever"? I'd even settle for xpath. My other idea was to use C# to query Examine directly and provide that to the dashboard, but I'm not quite sure how to do that...

    Currently I only have two working solutions

    1. Iterate over every single node using contentResource.getById[s]. Creates loads of GET requests, has awful performance, I don't even want to think about the perf impact later on when we have thousands of items
    2. An SQL query in PowerBI, which sucks because I really wanted this to be easily accessible from within Umbraco. Currently it's just querying on cmsContentVersion.VersionDate and joining that back to umbracoNode etc. Works fine, but it's not a long-term solution.

    Would really appreciate any suggestions or ideas that anyone might have.

  • Marc Goodson 2155 posts 14408 karma points MVP 9x c-trib
    Sep 06, 2019 @ 18:35
    Marc Goodson
    100

    Hi Matt

    Yes there isn't as far as I'm aware a resource that would 'do the job' for the query you need.

    But you could create an API controller inheriting from UmbracoAuthorizedApiController that creates an API endpoint that queries data via examine and exposes the results to be consumed from AngularJS...

    In the dim and distant past I created a similar dashboard for a client so you might find some inspiration here:

    https://github.com/marcemarc/tooorangey.ContentReview

    Regards

    Marc

  • Matt Wanchap 8 posts 89 karma points
    Sep 16, 2019 @ 09:58
    Matt Wanchap
    0

    Yeah, that's pretty much what we ended up doing. Thanks!

Please Sign in or register to post replies

Write your reply to:

Draft