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

Forums / General Discussions / Unable to get Content ID for the search result items

Unable to get Content ID for the search result items

3 posts, 0 answered
  1. Nagendra
    Nagendra avatar
    28 posts
    Registered:
    07 Jun 2010
    02 Sep 2010
    Link to this post
    Hello All,
    I am using Sitefinity 3.x. I am trying to write a code snippet to search inside the documents content present in my CMS.
    I am using the following code snippet:

    public CMSServiceResult GetSearchResults(string searchKeywords)
        {
            //TODO: Get the list of Search Catalogs
            string strCatalogueName = "Search All Site content";//list[0].ToString();
            int startIndex = 0;
            int resultItemCount = 0;
            /*Implementation Comments
             * There are 2 values for Mode:
             * AnyWord == OR
             * Otherwise == AND
             * */
            string strMode = "AnyWord";
            IList<ResultItem> CustomDataSource = SearchManager.Search(
                                       searchKeywords,
                                       strCatalogueName,
                                       startIndex,
                                       0,
                                       strMode,
                                       true,
                                       out resultItemCount);
            DataSet dsArticles = new DataSet();
            DataTable dtArticles = new DataTable("SearchResults");
            dtArticles.Columns.Add(new DataColumn("Id", Type.GetType("System.String")));
            dtArticles.Columns.Add(new DataColumn("Title", Type.GetType("System.String")));
            dtArticles.Columns.Add(new DataColumn("Content", Type.GetType("System.String")));
     
            if (resultItemCount > 0)
            {
                foreach (ResultItem customItem in CustomDataSource)
                {
                    DataRow drArticles = dtArticles.NewRow();
                    //TODO: See how to get the Article ID.
                    drArticles["Id"] = Guid.NewGuid();
                    drArticles["Title"] = customItem.Title;
                    drArticles["Content"] = customItem.Snippet;
                    dtArticles.Rows.Add(drArticles);
                }
            }
            dsArticles.Tables.Add(dtArticles);
            CMSServiceResult res = new CMSServiceResult();
            res.XML = dsArticles.GetXml();
            return res;
        }

    Here, I have two problems:
    1. I am not able to get all the Search Catalogs created.
    2. From the search results, I am not able to get the content Item Id.

    Please help me in this regard.

    Thanks,
    Nagen
  2. Nagendra
    Nagendra avatar
    28 posts
    Registered:
    07 Jun 2010
    02 Sep 2010
    Link to this post
    Hello All,

    I need solution for the 2nd question in my previous post.(From the search results, I am not able to get the content Item Id). Hence please let me know the answer. Your solution will help me a lot.

    Thanks,
    Nagendra
  3. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    02 Sep 2010
    Link to this post
    Hi Nagendra,

    The content item ID is not presented in the snippet by default. You can take a look at Search to Provide Article ID that explains how to get the id.

    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Register for webinar
3 posts, 0 answered