1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Search Index Names

Search Index Names

3 posts, 0 answered
  1. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    15 Dec 2009
    Link to this post
    is there any way to retrieve the search index names that are configured in the site administration? I'm trying to manually run a search at run-time but it requires a Search Index Name. I know what it is, but it would be much better if I could retrieve this name programmatically, so that I can reuse it on other sites with different index names.

    thanks!
  2. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    15 Dec 2009
    Link to this post
    okay I managed to solve this using the file system, since the indexes are stored in folders under app_data/search. here's how I did it, if there is a better way, please let me know!

    var indexes = new DirectoryInfo(Server.MapPath("~/App_Data/Search")).GetDirectories();  
    if (indexes.Length == 0) return results;  
        results = SearchManager.Search(query, indexes[0].Name, 0, MAX_RESULTS, "AnyWord"out count); 

    one idea I can see from this is if there are more than 1 search directory, and the results are empty, proceed down the line and append more results...
  3. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    16 Dec 2009
    Link to this post
    Hi SelArom,

    Thank you for using our services.

    You can actually use the Search API and the search manager to get the desired information. See sample code snippet bellow:
    Telerik.Search.IndexDataManager indexManager = new IndexDataManager();
    IList allIndexingServices = indexManager.GetServices();
    foreach (IIndexingServiceInfo indexingService in allIndexingServices)
    {
        string serviceName = indexingService.Name;
    }


    Regards,
    Radoslav Georgiev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Register for webinar
3 posts, 0 answered