I'm trying to add a custom index for searching but the file is not added to the results.
This is my code for rebuild method, is finding docs in the right media library but those are not being retrieved in results.try
{
MediaLibraryInfo library = MediaLibraryInfoProvider.GetMediaLibraryInfo("Documents", SiteContext.CurrentSiteName);
if (library != null)
{
var mediaFiles = MediaFileInfoProvider.GetMediaFiles().WhereEquals("FileLibraryID", library.LibraryID);// all files extension
List@string@ files = new List@string@();
foreach (MediaFileInfo mediafile in mediaFiles)
{
SearchDocumentParameters documentParameters = new SearchDocumentParameters()
{
Index = srchInfo,
Type = SearchHelper.CUSTOM_SEARCH_INDEX,
Id = Guid.NewGuid().ToString(),
Created = mediafile.FileCreatedWhen
};
ILuceneSearchDocument doc = LuceneSearchDocumentHelper.ToLuceneSearchDocument(SearchHelper.CreateDocument(documentParameters));
doc.AddGeneralField(SearchFieldsConstants.CUSTOM_TITLE, mediafile.FileTitle, true, true);
doc.AddGeneralField("NAME", mediafile.FileName, true, true);
doc.AddGeneralField("DESCRIPTION", mediafile.FileDescription, true, true);
iw.AddDocument(doc);
}
iw.Flush();
iw.Optimize();
}
}
catch (Exception ex)
{
EventLogProvider.LogException("CustomTextFileIndex", "Rebuild", ex);
}
// Always close the index writer
finally
{
iw.Close();
}
↧