London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!

Trigger Optimizely Graph sync for specific item

Vote:
 

Is there a way to trigger an Optimizley Graph sync for a specific content item programmatically?

Basically hoping to make the same call as the 'Synchronize with Optimizely Graph' link under the Publish button in the EditUI,

Thanks in advance,

Joe Mayberry

#337829
Edited, Apr 15, 2025 16:12
Vote:
 

Hello Joe,

I had been looking at potentially having to do this as well but realised I didn't need to do it.  Content is sync'd to graph on a near real time basis when the content is published through the front end, however most queries will be running with caching for performance purposes.

If you want to programmatically index content into graph, you could use the IContentIndexer which is part of the Optimizely.ContentGraph.Cms.Core namespace.  This has index methods that take either a single or a collection of content references.

Here is the interface for IContentIndexer

public interface IContentIndexer
{
    ContentIndexingScope? IndexingScope { get; }
    Task<Response> IndexAsync(ContentReference contentReference, bool throughEventHub = true, CancellationToken cancellationToken = default(CancellationToken));
    Task<IEnumerable<Response>> IndexToNewDeploymentAsync(IEnumerable<ContentReference> contentReferences, bool throughEventHub = true, CancellationToken cancellationToken = default(CancellationToken));
    Task<IEnumerable<Response>> IndexAsync(IEnumerable<ContentReference> contentReferences, bool throughEventHub = true, CancellationToken cancellationToken = default(CancellationToken));
    Task<Response> DeleteAsync(DeleteItemModel deleteItem);
    Task<Response> DeleteAsync(IEnumerable<DeleteItemModel> deleteItems, CancellationToken cancellationToken = default(CancellationToken));
    Task<Response> DeleteAsync(IEnumerable<DeleteByPathModel> deleteItems, CancellationToken cancellationToken = default(CancellationToken));
    Task<Response> DeleteAsync(DeleteByPathModel deleteItem);
    Task BufferedIndexAsync(ContentReference contentReference, CancellationToken cancellationToken = default(CancellationToken));
    Task BufferedIndexAsync(IEnumerable<ContentReference> contentReferences, CancellationToken cancellationToken = default(CancellationToken));
}
#337844
Edited, Apr 16, 2025 8:04
Joe Mayberry - Apr 16, 2025 13:30
The IContentIndexer IndexAsync function worked like a champ! Thank you!
Vote:
 

Thank you for the response Mark. I will take a look at that interface, and see what I can figure out. 

One thing I forgot to mention, is that the content in question is coming in from a DAM provider, and the way it was implemented uses stored procedures to make the updates, so there are not any content events, like publish, that are triggered. Hopefully this will give me what I need though.

#337861
Apr 16, 2025 12:32
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.