internal static Document CreateDocument(IndexDocumentInfo info, IndexDocumentData docData)
{
var doc = new Document();
foreach (var fieldInfo in info.fields)
doc.Add(CreateField(fieldInfo));
var path = docData.Path.ToLower();
//doc.Add(new Field(LucObject.FieldName.Name, RepositoryPath.GetFileName(path), Field.Store.YES, Field.Index.ANALYZED));
//doc.Add(new Field(LucObject.FieldName.Path, path, Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS));
doc.Add(CreateStringField(LucObject.FieldName.Name, RepositoryPath.GetFileName(path), NameFieldIndexingInfo));
doc.Add(CreateStringField(LucObject.FieldName.Path, path, NameFieldIndexingInfo));
//LucObject.FieldName.Depth
var nf = new NumericField(LucObject.FieldName.Depth, Field.Store.YES, true);
nf.SetIntValue(DepthIndexHandler.GetDepth(docData.Path));
doc.Add(nf);
//LucObject.FieldName.InTree
//var fields = InTreeIndexHandlerInstance.GetIndexFields(LucObject.FieldName.InTree, docData.Path);
var fields = CreateInTreeFields(LucObject.FieldName.InTree, docData.Path);
foreach (var field in fields)
doc.Add(field);
//LucObject.FieldName.InFolder
doc.Add(CreateInFolderField(LucObject.FieldName.InFolder, path));
//LucObject.FieldName.ParentId
nf = new NumericField(LucObject.FieldName.ParentId, Field.Store.NO, true);
nf.SetIntValue(docData.ParentId);
doc.Add(nf);
// flags
doc.Add(new Field(LucObject.FieldName.IsLastPublic, docData.IsLastPublic ? BooleanIndexHandler.YES : BooleanIndexHandler.NO, Field.Store.YES, Field.Index.NOT_ANALYZED, Field.TermVector.NO));
doc.Add(new Field(LucObject.FieldName.IsLastDraft, docData.IsLastDraft ? BooleanIndexHandler.YES : BooleanIndexHandler.NO, Field.Store.YES, Field.Index.NOT_ANALYZED, Field.TermVector.NO));
// timestamps
nf = new NumericField(LucObject.FieldName.NodeTimestamp, Field.Store.YES, true);
nf.SetLongValue(docData.NodeTimestamp);
doc.Add(nf);
nf = new NumericField(LucObject.FieldName.VersionTimestamp, Field.Store.YES, true);
nf.SetLongValue(docData.VersionTimestamp);
doc.Add(nf);
// custom fields
if (info.HasCustomField)
{
var customFields = CustomIndexFieldManager.GetFields(info, docData);
if (customFields != null)
foreach (var field in customFields)
doc.Add(field);
}
return doc;
}
private static AbstractField CreateField(IndexFieldInfo fieldInfo)