Search code examples
sqlt-sqlazureindexed-viewazure-cognitive-search

Indexed View with its own rowversion for Azure Search indexer


I'm trying to design the best way to index my data into Azure Search. Let's say my Azure SQL Database contains two tables:

  • products
  • orders

In my Azure Search index I want to have not only products (name, category, description etc.), but also count of orders for this product (to use this in the scoring profiles, to boost popular products in search results).

I think that the best way to do this is to create a view (indexed view?) which will contain columns from products and count of orders for each product, but I'm not sure if my view (indexed view?) can have its own rowversion column, which will change every time the count changes (orders may be withdrawn - DELETED - and placed - INSERTED).

Maybe there is some easier solution to my problem? Any hints are appreciated.

Regards, MJ


Solution

  • A view cannot have its "own" rowversion column - that column should come from either products or orders table. If you make that column indexed, a high water mark change tracking policy will be able to capture new or updated (but not deleted) rows efficiently. If products are deleted, you should look into using a soft-delete approach as described in http://azure.microsoft.com/en-us/documentation/articles/search-howto-connecting-azure-sql-database-to-azure-search-using-indexers-2015-02-28/

    HTH, Eugene