Getting document field values from Smart Search results

mun yung kan asked on March 3, 2015 09:05

Hey Guys,

i'm trying to implement a news section for a site. we are migrating quite alot of old content over and i've decided its probably better to use lucene to index the content for filtering.

the problem i am facing is getting a specific text field out of the datarowview.

my code to retrieve the results is as follows. using LUKE i am able to inspect the index and i can see all the content stored there, but after i cant seem to retrieve it from the datarowview in the repeater.

string searchText = SearchSyntaxHelper.CombineSearchCondition(GetType(), condition);

        SearchParameters parameters = new SearchParameters
        {
            SearchFor = searchText,
            SearchSort = "prioritise DESC, ##SCORE##",
            SearchIndexes = "KRSNewsIndex",
            StartingPosition = 0,
            DisplayResults = 10,
            NumberOfProcessedResults = 100,
            NumberOfResults = 0,

        };

        var results = CMS.Search.SearchHelper.Search(parameters);

i set the results in a repeater and databind it.

i am able to get my field called "title" out, but description is never retrieved.

DataRowView drv = e.Item.DataItem as DataRowView;
string title = DataHelper.GetNotEmpty(drv["Title"],"");
string description = DataHelper.GetNotEmpty(drv["Description"],"");

what am i doing wrong?

Recent Answers


Chantale Laberge answered on March 4, 2015 01:53

Have you set the description field on the search fields section of your page type ?

0 votesVote for this answer Mark as a Correct answer

mun yung kan answered on March 4, 2015 02:19

Hi juan,

Yes i have set the description field in the search section of the page type app.

i can see the values being stored when i inspect the index using luke.

0 votesVote for this answer Mark as a Correct answer

Trevor Fayas answered on March 4, 2015 21:05

Can you include a screen shot of the Search Fields for the item in question? May help us.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on March 5, 2015 13:45

You must be using ASPX development mode? In portal mode you enter in the transformation GetSearchValue("ColumnName") and it will return the value of that column in the search results dataset.

0 votesVote for this answer Mark as a Correct answer

mun yung kan answered on March 6, 2015 01:48

Hey brenden,

yes the project was chosen to be run in aspx development mode.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.