Retrieving the field names from sitecore item -
while searching keyword in sitecore using sitecore.seach returns item name(where located) search keyword. there option field name along item?
i use following code:
using (indexsearchcontext context = searchindex.createsearchcontext()) { searchhits hits = context.search(searchstring, new searchcontext(siteroot)); var results = hits.fetchresults(0, 100); foreach (searchresult result in results) { try { item item = result.getobject<item>(); if (item != null) { results.addresulttocategory(result, categoryname); } } ... } }
if understand goal correctly, want find out exact fields (field names) search string found, right?
if that's case, should collection of item fields (item.fields
), , iterate through checking search string in field value.
as far know, sitecore search shell application works same way when displaying results: item taken form searchresult
, , field collection iterated looking hit using simple text.indexof()
comparison.
and i'm not aware different way accomplish this.
Comments
Post a Comment