本文整理汇总了C#中Lucene.Net.Documents.Document.Get方法的典型用法代码示例。如果您正苦于以下问题:C# Document.Get方法的具体用法?C# Document.Get怎么用?C# Document.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lucene.Net.Documents.Document
的用法示例。
在下文中一共展示了Document.Get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SearchResult
public SearchResult(Document searchDoc,string sample,float score)
{
this.Id = searchDoc.Get("contentid");
this.Type = searchDoc.Get("type");
this.Sample = sample;
this.Score = score;
}
示例2: SearchResult
public SearchResult(Document doc, float score)
{
Fields = new Dictionary<string, string>();
string id = doc.Get("id");
if (string.IsNullOrEmpty(id))
{
id = doc.Get("__NodeId");
}
Id = int.Parse(id);
Score = score;
//we can use lucene to find out the fields which have been stored for this particular document
//I'm not sure if it'll return fields that have null values though
var fields = doc.GetFields();
//ignore our internal fields though
foreach (Field field in fields.Cast<Field>())
{
string fieldName = field.Name();
Fields.Add(fieldName, doc.Get(fieldName));
//Examine returns some fields as e.g. __FieldName rather than fieldName
if (fieldName.StartsWith(LuceneIndexer.SpecialFieldPrefix))
{
int offset = LuceneIndexer.SpecialFieldPrefix.Length;
string tidiedFieldName = Char.ToLower(fieldName[offset]) + fieldName.Substring(offset + 1);
if (!Fields.ContainsKey(tidiedFieldName))
{
Fields.Add(tidiedFieldName, doc.Get(fieldName));
}
}
}
}
示例3: MapSearchResult
private Group MapSearchResult(Document doc)
{
return new Group
{
Id = int.Parse(doc.Get(SearchingFields.Id.ToString())),
Name = doc.Get(SearchingFields.Name.ToString())
};
}
示例4: MapSearchResult
private Project MapSearchResult(Document doc)
{
return new Project
{
Id = int.Parse(doc.Get(SearchingFields.Id.ToString())),
Title = doc.Get(SearchingFields.Name.ToString())
};
}
示例5: LogEntry
public LogEntry(Document document)
{
Id = Guid.Parse(document.Get("Id"));
Text = document.Get("Text");
Timestamp = new DateTime(long.Parse(document.Get("Timestamp")));
SourceHost = document.Get("SourceHost");
SourceFile = document.Get("SourceFile");
}
示例6: _mapLuceneDocumentToData
/// <summary>
/// Maps the lucene document to data.
/// </summary>
/// <returns>The lucene document to data.</returns>
/// <param name="doc">Document.</param>
private static SearchModel _mapLuceneDocumentToData (Document doc)
{
return new SearchModel {
Id = Convert.ToInt64 (doc.Get ("content_id")),
ContentTitle = doc.Get ("content_title"),
ContentSource = Convert.ToInt64(doc.Get ("source_id"))
};
}
示例7: LuceneArticle
public LuceneArticle(Document document)
{
if (document != null)
{
this.Id = Convert.ToInt32(document.Get("Id"));
this.Title = document.Get("Title");
this.Content = document.Get("Content");
}
}
示例8: BuildSearchResult
protected override ISearchResult BuildSearchResult(float score, Document document)
{
var searchResult = base.BuildSearchResult(score, document);
searchResult.Content.Add("author_id", document.Get("author_id"));
searchResult.Content.Add("author_name", document.Get("author_name"));
searchResult.Content.Add("author_firstName", document.Get("author_firstName"));
searchResult.Content.Add("author_lastName", document.Get("author_lastName"));
searchResult.Content.Add("biography", document.Get("biography"));
return searchResult;
}
示例9: BuildSearchResult
protected override ISearchResult BuildSearchResult(float score, Document document)
{
var searchResult = base.BuildSearchResult(score, document);
// searchResult.Content.Add("photo_id", document.Get("photo_id"));
searchResult.Content.Add("owner", document.Get("owner"));
searchResult.Content.Add("title", document.Get("title"));
searchResult.Content.Add("owner_id", document.Get("owner_id"));
searchResult.Content.Add("description", document.Get("description"));
return searchResult;
}
示例10: BuildSearchResult
protected virtual ISearchResult BuildSearchResult(float score, Document document)
{
Guid entityId = Guid.Empty;
Guid.TryParse(document.Get(IdFieldName), out entityId);
var timestamp = DateTime.FromFileTime(long.Parse(document.Get(TimeStampFieldName)));
var documentType = document.Get(TypeFieldName);
string content = document.Get(ContentFieldName);
return new SearchResult(entityId, content, score, timestamp, documentType);
}
示例11: MapSearchResult
private Lecturer MapSearchResult(Document doc)
{
return new Lecturer
{
Id = int.Parse(doc.Get(SearchingFields.Id.ToString())),
FirstName = doc.Get(SearchingFields.FirstName.ToString()),
MiddleName = doc.Get(SearchingFields.MiddleName.ToString()),
LastName = doc.Get(SearchingFields.LastName.ToString()),
Skill = doc.Get(SearchingFields.Name.ToString()) //логин
};
}
示例12: NamespaceModel
public NamespaceModel(Document document)
{
Name = document.Get(NamespaceNameField);
AssemblyName = document.Get(NamespaceAssemblyNameField);
PackageName = document.Get(NamespacePackageNameField);
PackageVersion = document.Get(NamespacePackageVersionField);
var targetFrameworksFieldValue = document.Get(NamespaceTargetFrameworksField);
TargetFrameworks = new List<string>();
if (!string.IsNullOrEmpty(targetFrameworksFieldValue))
{
TargetFrameworks.AddRange(targetFrameworksFieldValue.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries));
}
}
示例13: AddFieldBool
public static void AddFieldBool(JObject obj, Document document, string to, string from)
{
string value = document.Get(from);
if (value != null)
{
obj[to] = value.Equals("True", StringComparison.InvariantCultureIgnoreCase);
}
}
示例14: Highlight
public static void Highlight(Document d, string query, Analyzer analyzer)
{
string contents = d.Get("contents");
SimpleHTMLFormatter formatter = new SimpleHTMLFormatter("<span class=\"highlight\"><b>", "</b></span>");
//SpanGradientFormatter formatter = new SpanGradientFormatter(10.0f, null, null, "#F1FD9F", "#EFF413");
//SimpleHTMLEncoder encoder = new SimpleHTMLEncoder();
SimpleFragmenter fragmenter = new SimpleFragmenter(250);
Highlighter hiliter = new Highlighter(formatter, new QueryScorer(QueryParser.Parse(query, "contents", analyzer)));
hiliter.SetTextFragmenter(fragmenter);
int numfragments = contents.Length / fragmenter.GetFragmentSize() + 1;// +1 ensures its never zero. More than the required number of fragments dont harm.
StringBuilder result = new StringBuilder("<html><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"><style>.highlight{background:yellow;}</style><head><title>Search Results - ");
result.Append(d.Get("filename"));
result.Append("</title></head><body><font face=Arial size=5>");
TokenStream tokenstream = analyzer.TokenStream("contents", new System.IO.StringReader(contents));
TextFragment[] frags = hiliter.GetBestTextFragments(tokenstream, contents, false, numfragments);
foreach (TextFragment frag in frags)
{
if (frag.GetScore() > 0)
{
result.Append(frag.ToString() + "<br/><hr/><br/>");
}
}
string contentspath = System.IO.Path.Combine(System.Windows.Forms.Application.StartupPath, "contents.html");
result.Append("</font><a target=_self href=\"file:///");
result.Append(contentspath);
result.Append("\">View Original Document...</a>");
result.Append("</body></html>");
result.Replace("\n", "<br/>");
string resultspath = System.IO.Path.Combine(System.Windows.Forms.Application.StartupPath, "results.html");
System.IO.File.WriteAllText(resultspath, result.ToString());
//webBrowser1.Url = new Uri("file:///" + resultspath);
Highlighter hiliter2 = new Highlighter(formatter, new QueryScorer(QueryParser.Parse(query, "contents", analyzer)));
hiliter2.SetTextFragmenter(fragmenter);
TokenStream tokstr = analyzer.TokenStream(new System.IO.StringReader(contents));
StringBuilder htmlcontents = new StringBuilder("<html><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"><style>.highlight{background:yellow;}</style><body><font face=Arial size=5>");
htmlcontents.Append(hiliter2.GetBestFragments(tokstr, contents, numfragments, "..."));
htmlcontents.Append("</font></body></html>");
htmlcontents.Replace("\n", "<br/>");
System.IO.File.WriteAllText(contentspath, htmlcontents.ToString());
}
示例15: AddField
public static void AddField(JObject obj, Document document, string to, string from)
{
string value = document.Get(from);
if (value != null)
{
obj[to] = value;
}
}