internal static Document CreateLuceneDocument(LuceneIndexItem item, FieldConfig config, bool storeSource = false) { Document luceneDoc = new Document(); luceneDoc.Add(new Field(ItemTypeField, item.Type, Field.Store.YES, Field.Index.NOT_ANALYZED)); luceneDoc.Add(new Field(TenantField, item.Tenant, Field.Store.YES, Field.Index.NOT_ANALYZED)); luceneDoc.Add(new Field(ItemIdField, item.Id, Field.Store.YES, Field.Index.NOT_ANALYZED)); if (storeSource) { luceneDoc.Add(new Field(FieldSource, item.ToJson(), Field.Store.YES, Field.Index.NO)); } luceneDoc.Add(new NumericField(FieldTimestamp, Field.Store.YES, true).SetLongValue(DateTime.UtcNow.Ticks)); luceneDoc.Add(new NumericField(FieldCreatedOnDate, Field.Store.NO, true).SetLongValue(item.CreatedOnDate.Ticks)); luceneDoc.Add(new Field(PortalIdField, item.PortalId.ToString(), Field.Store.YES, Field.Index.ANALYZED)); luceneDoc.Add(new Field(FileIdField, item.FileId.ToString(), Field.Store.YES, Field.Index.NOT_ANALYZED)); luceneDoc.Add(new Field(FileNameField, item.FileName, Field.Store.YES, Field.Index.ANALYZED)); luceneDoc.Add(new Field(FolderField, QueryParser.Escape(item.Folder), Field.Store.YES, Field.Index.NOT_ANALYZED)); luceneDoc.Add(new Field(FileContentField, string.IsNullOrEmpty(item.FileContent) ? "" : item.FileContent, Field.Store.YES, Field.Index.ANALYZED)); var objectMapper = new JsonObjectMapper(); objectMapper.AddJsonToDocument(item.Meta, luceneDoc, config); return(luceneDoc); }
internal static LuceneIndexItem CreateLuceneItem(OpenFilesInfo fileInfo, FieldConfig indexConfig) { var luceneItem = new LuceneIndexItem(ItemTypeValue, fileInfo.File.PortalId.ToString(), fileInfo.File.CreatedOnDate, fileInfo.File.FileId.ToString()) { FileName = fileInfo.File.FileName, Folder = fileInfo.File.Folder.TrimEnd('/'), FileContent = DnnFilesRepository.GetFileContent(fileInfo.File) }; JObject custom = fileInfo.JsonAsJToken; custom.MakeSureFieldExists(MetaField, JTokenType.Object); custom[MetaField].HydrateDefaultFields(indexConfig); if (custom[MetaField].HasValues) { luceneItem.Meta = custom[MetaField]; } return(luceneItem); }
internal static LuceneIndexItem CreateLuceneItem(int portalid, int fileid) { var indexData = new LuceneIndexItem(ItemTypeValue, portalid.ToString(), DateTime.Now, fileid.ToString()); return(indexData); }
private static string GetIndexFieldValue(LuceneIndexItem data) { return(data.FileId.ToString()); }
public static Query GetDeleteQuery(LuceneIndexItem data) { var selection = new TermQuery(new Term(LuceneMappingUtils.GetIndexFieldName(), LuceneMappingUtils.GetIndexFieldValue(data))); return(new FilteredQuery(selection, LuceneMappingUtils.GetTypeTenantFilter(ItemTypeValue, data.PortalId.ToString()))); }