locked
What is the best way to achieve Full Text Search with Azure table storage? RRS feed

  • Question

  • User1644485212 posted

    Hi,

    I am looking for some robust solution to achieve full text search with Azure table storage not with Azure SQL. As per the update Azure table storage does not support Full text search of its own. You have to implement your custom solution. So want to now what is the best way to achive full text search with azure table storage.

    Wednesday, January 22, 2014 6:38 AM

Answers

  • User-1002628304 posted

    How to Consume AzureSearch.

    1. Define What do you want to have in Search Index 2. Add Reference to AzureSearch Library 3. Instead of using CloudTableClient, use SearchCloudTableClient 4. Search the Indexes.

    Detailed Steps

    1. Specify the blob account for Search Index < Setting name=”SearchAccount” value=”DefaultEndpointsProtocol=https;AccountName=ACCOUNTNAME” />

    2. Define the Search index

    SearchIndex definition is a config file where each line represents a tableEntity and is of the form

    tablename:column1,column2,column3

    Define the Tables that has to be Search Indexed and the Columns that needs to be search indexed.

    Create a config file called luceneindex.config in the SearchAccount – BlobStorage that you have mentioned in the ServiceConfiguration

    3. Add Reference to AzureSearch Library – Download it from http://sundararajan001.appspot.com/live1

    3. Use SearchCloudTableClient instead of the CloudTableClient. This takes care of pushing the storage to indexes.

     public class NewsEntityDataEntry
       {
            private string _connectionString;
            private CloudStorageAccount storageAccount;
            private SearchCloudTableClient tableClient;
            public NewsEntityDataEntry()
            {
                _connectionString = RoleEnvironment.GetConfigurationSettingValue("StorageConnectionString");              
                storageAccount = CloudStorageAccount.Parse(_connectionString);
                tableClient = storageAccount.CreateTestCloudTableClient(true);        
    
            }
    
            public void PushNews(int lineId, string header, string line)
            {
                TableServiceContext tableServiceContext = tableClient.GetDataServiceContext();
                NewsEntity ne = new NewsEntity(lineId,line  ) ;
                ne.NewsHeader = header;
                tableServiceContext.AddObject("NewsEntity", ne);
                tableServiceContext.SaveChangesWithRetries();               
    
            }       
        }

    4. All your Columns are Indexed – That’s it

    Searching In the Index

    1. Just 2 lines of Code

    ISearch ts = new TableStorageSearch();

    List<String> list=ts.Search(TextBox1.Text);

    [Disclaimer: This is currently a 3 hour effort and is a pre-alpha release. ]

    Current Issues

    1. Performance of Index Write is not up to the mark

    2. Lucene Index is not compressed.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, February 10, 2014 2:19 AM

All replies

  • User188200844 posted

    This link will help you

    http://code.msdn.microsoft.com/AzureDirectory

    Friday, January 24, 2014 7:03 AM
  • User-1002628304 posted

    How to Consume AzureSearch.

    1. Define What do you want to have in Search Index 2. Add Reference to AzureSearch Library 3. Instead of using CloudTableClient, use SearchCloudTableClient 4. Search the Indexes.

    Detailed Steps

    1. Specify the blob account for Search Index < Setting name=”SearchAccount” value=”DefaultEndpointsProtocol=https;AccountName=ACCOUNTNAME” />

    2. Define the Search index

    SearchIndex definition is a config file where each line represents a tableEntity and is of the form

    tablename:column1,column2,column3

    Define the Tables that has to be Search Indexed and the Columns that needs to be search indexed.

    Create a config file called luceneindex.config in the SearchAccount – BlobStorage that you have mentioned in the ServiceConfiguration

    3. Add Reference to AzureSearch Library – Download it from http://sundararajan001.appspot.com/live1

    3. Use SearchCloudTableClient instead of the CloudTableClient. This takes care of pushing the storage to indexes.

     public class NewsEntityDataEntry
       {
            private string _connectionString;
            private CloudStorageAccount storageAccount;
            private SearchCloudTableClient tableClient;
            public NewsEntityDataEntry()
            {
                _connectionString = RoleEnvironment.GetConfigurationSettingValue("StorageConnectionString");              
                storageAccount = CloudStorageAccount.Parse(_connectionString);
                tableClient = storageAccount.CreateTestCloudTableClient(true);        
    
            }
    
            public void PushNews(int lineId, string header, string line)
            {
                TableServiceContext tableServiceContext = tableClient.GetDataServiceContext();
                NewsEntity ne = new NewsEntity(lineId,line  ) ;
                ne.NewsHeader = header;
                tableServiceContext.AddObject("NewsEntity", ne);
                tableServiceContext.SaveChangesWithRetries();               
    
            }       
        }

    4. All your Columns are Indexed – That’s it

    Searching In the Index

    1. Just 2 lines of Code

    ISearch ts = new TableStorageSearch();

    List<String> list=ts.Search(TextBox1.Text);

    [Disclaimer: This is currently a 3 hour effort and is a pre-alpha release. ]

    Current Issues

    1. Performance of Index Write is not up to the mark

    2. Lucene Index is not compressed.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, February 10, 2014 2:19 AM