How can we initialize DataChangeDetectionPolicy using .netsdk?

367 Views Asked by At

I have created a new index that is populated using an indexer. The indexer's datasource is a SQL view that has a Timestamp column of type datetime. Since we don't want a full reindexing each time the indexer runs, this column should be used to determine which data have changed since the last indexer run.

According to the documentation we need to create or update the datasource by setting the HighWatermarkColumnName and ODataType to the DataChangeDetectionPolicy object. The example in the documentation uses the REST API and there is also way to do it using the azure search portal directly.

However I want to do it using .netsdk and so far I haven't been able to do so. I am using Azure.Search.Documents(11.2.0 - beta.2). Here is the part of the code I use to create the datasource:

SearchIndexerDataSourceConnection CreateIndexerDataSource()
        {
            var ds = new SearchIndexerDataSourceConnection(DATASOURCE,
                          SearchIndexerDataSourceType.AzureSql,
                          this._datasourceConStringMaxEvents,
                          new SearchIndexerDataContainer(SQLVIEW));
            //ds.DataChangeDetectionPolicy = new DataChangeDetectionPolicy();

            return ds;
        }

The commented code is what I tried to do to initialize the DataChangeDetectionPolicy but there is no ctor exposed. Am I missing something?

Thanks in advance.

1

There are 1 best solutions below

0
On

Instead of using DataChangeDetectionPolicy, you will need to use HighWaterMarkChangeDetectionPolicy which is derived from DataChangeDetectionPolicy.

So your code would be something like:

ds.DataChangeDetectionPolicy = new HighWaterMarkChangeDetectionPolicy("Timestamp");