Content search

Appframe supports low level content search. Content search implementation depends on application and filestore layer which is used (Azure or Windows). For Azure FileStore layer we can use Azure indexing, for Wndows, windows search.

Content search is dependent on Appframe365.Web.Core library


To configure content search you need to have the following entries in Web.config file:

    <!--====================[     Content Search Settings     ]====================-->
    <add key="AzureSearchServiceName" value = "" />
    <add key="AzureSearchQueryKey" value="" />
    <add key="AzureSearchIndexName" value="" />
    <add key="FileStoreServerName" value="" />
    <add key="IndexingServiceCatalogName" value="" />
    <add key="SearchType" value="azureblob" />
  • AzureSearchServiceName – name of the azure indexing service name
  • AzureSearchIndexName – azure search index name
  • AzureSearchQueryKey – azure search key (read-only search key is enough)
  • FileStoreServerName – filestore server name, only used when windows search is used
  • IndexingServiceCatalogName – Indexing service catalog name, only used when windows search is used
  • SearchType – type of search if auto detect fails (allowed values azureblob and windowssearch)

Performing search

This will auto pick up search provider, whatever is configured on solution.


    /* Getting correct Search Handler*/
    var vSearchType = GetSearchHandler(pContext,pViewName);
    /* OR just defining*/
    var vSearchType = ContentSearch.ContentSearchType.SearchInAzureSearch;
    /** Parameters
    * - pSearchType ContentSearch.ContentSearchType, defines which search provider to use
    * - pCriteria String, search criteria
    * - pViewName String nullable, if defined it will check returned file ref's if they exists in view
    * - pReturnContent Boolean default false will return content within search criteria is found
    * - pMetadata String, applicable for azure only, if defined, will be passed as filter to limit azure inedex search. (Use only you maintain azure index custom metadata properties)
    /* Initializing content search handler for Azure */
        var vSearchResults = new ContentSearch(pSearchType, pCiteria, pViewName, pReturnContent,pMetadata);
        /* Initializing content search handler for Windows */
        var vSearchResults = new ContentSearch(pSearchType, pCiteria, pViewName, pReturnContent);
    /* Will perform actual search and return results DataTable containing rows with FileRef and FileName */ 
    DataTable vResults = vSearchResults.SearchContent();

Getting correct search provider

        * - Will get default search provider for table/view
        private static LocationInfo GetSearchHandler(RequestContext context, String pViewName)
            var vReturn = new LocationInfo();
            var vProc = new afProcedureCall("sstp_System_Files_GetLocationInfo");
            var vDataSet = context.ConnectionContext.ExecuteProcedure(vProc);
            var vAppSettings = System.Configuration.ConfigurationManager.AppSettings;
            if (vDataSet.Tables[0].Rows[0]["StorageType"].ToString().ToLower() == "azureblob"){
                vReturn.SearchType = ContentSearch.ContentSearchType.SearchInAzureSearch;
            else if (System.Configuration.ConfigurationManager.AppSettings["SearchType"].ToString().ToLower() == "windowssearch")
                vReturn.SearchType = ContentSearch.ContentSearchType.SearchInWSx32;
                vReturn.SearchType = ContentSearch.ContentSearchType.SearchInMSIS;
            if (vDataSet.Tables[1].Rows[0][0] != null) vReturn.SourceTable = vDataSet.Tables[1].Rows[0][0].ToString();
            return vReturn;
        * - Just class representing ContentSearch.ContentSearchType SearchType
        private  class LocationInfo{
            public ContentSearch.ContentSearchType SearchType;
            public String SourceTable;

Currently available api's


  • {Type} - Search type (searchinazuresearch|searchinwsx32|searchinwsx64).
  • {Criteria} - Criteria to search for.
  • {ViewName} - Security view to filter content search results.


  • api/content-search/{Type}/{Criteria}
  • api/content-search/{Type}/{Criteria}/{ViewName}
  • api/content-search/{Criteria}
  • api/content-search/{Criteria}/{ViewName}

Experimental/Prototype api

Code module api/articleContentSearch can be used to replace data object default retrieve handler. Without additional parameters will work same as default. Additional post parameters:

    contentSearchCriteria - search string to search for in file store
    metaDataSearch - additional metadata fields if Azure index is configured to use such

Metadata fields in Azure blob

Usually filestore consists of many files and not all might be relevant to content search performed on specific view. It might return thousands of not related records. For such cases we use views to query and check if record is valid for given search, but this might be quite costly operation. To limit search we can use blob metada fields as well. Typically field, which is already added into Pims365 azure index is metada_sourcetable field. This field can be used to query data in index, but it has to exist in index as well and values should be updated.
When file is added to blob it is added to index as well and it comes without metadata. To update blob index, we can use following api's

  • api/updateAzureBlob/{ArticleID}/{DataSourceID}/{FileRef} - will update one file and add metada_sourcetable value
  • api/updateAzureBlob/files/{TableName} - will update all files in table.

Note: - after updating blob it might take some time until index is updated as well.

Searching in Azure

If you know already that you solution is configured to use Azure content search, so you can create your own code module and get more functionality which is available withing Azure search provider.

Minimal usage example bellow

    /* Creating azure data provider  */
    var vProvider = new IAzureMetaDataProvider();

    /* Performing search, will return DataTable and return all results form index containing search criteria*/
    var vSearchResults = vProvider.SearchContent("some search criteria as string");


Other optional methods

    /* Creating azure data provider.
        You can pass optional parameter string view name to constructor
    new IAzureMetaDataProvider("ViewName");

    /* Performing search, will return DataTable and return all results form index containing search criteria
        Also you can pass top clause, which will return only pTop records
    SearchContent(pSearchText As String, pTop As Integer)

    /* Optional parameter, 
        if you have special folder structure for a table and index defined on it, 
        you can pass directly and avoid additional check for index.
    vProvider.IndexName = "some-index";

        Metadata search paramters can be passed in this way.
        It will be used as aditional Filter.
        Check oficcial azure index documentation what can be used here.
        Example bellow will search only in given file references.
    vProvider.MetaData = ",'FileRef1,FileRef2,...')";

    vProvider.ReturnContent = true; //Default false, will return content from index.

    vProvider.ReturnScore = false; // Default true, will return score for each result.

        View name is used as security view, to filter out azure index results, to check if such FileRef's exists in given view.
        Also view name is used to get specific azure index, if such is configured to be used in Appframe.
    vProvider.ViewName = "ViewName"; // view name is used as security view, to filter out 

    vProvider.UseViewAsSecurity = false; // default is true, will use view as security check.

    vProvider.GetPagedResults = true; //default is false. 

    vProvider.GetNextPage() //method should be used when GetPagedResults is set to true. Will get next top 1000 results each time;


Related articles

Placeholder "LocalizeWeb2016" failed