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

Configuration

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

/* 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"); vProc.Parameters.Add("ViewName",pViewName); 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; } else { 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

Parameters

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

Url's

  • 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.