本文整理汇总了C#中Lucene.Net.Documents.Document.GetValues方法的典型用法代码示例。如果您正苦于以下问题:C# Document.GetValues方法的具体用法?C# Document.GetValues怎么用?C# Document.GetValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lucene.Net.Documents.Document
的用法示例。
在下文中一共展示了Document.GetValues方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BasicAuditEntry
public BasicAuditEntry(Document doc, int luceneId)
{
User = doc.Get("user");
Role = doc.GetValues("role").ToList();
Id = new ID(doc.Get("id"));
Path = doc.Get("path");
DateTime tmp;
DateTime.TryParse(doc.Get("timestamp"), out tmp);
TimeStamp = tmp;
EventId = doc.Get("event");
Note = doc.Get("note");
Label = doc.Get("label");
Color = doc.Get("color");
Database = doc.Get("database");
Uid = luceneId.ToString();
}
示例2: PopulateDocument
public static void PopulateDocument(Document doc, IEnumerable<IFacetHandler> handlers)
{
StringBuilder tokenBuffer = new StringBuilder();
foreach (var handler in handlers)
{
string name = handler.Name;
string[] values = doc.GetValues(name);
if (values != null)
{
doc.RemoveFields(name);
foreach (string value in values)
{
doc.Add(new Field(name, value, Field.Store.NO, Field.Index.NOT_ANALYZED));
tokenBuffer.Append(' ').Append(value);
}
}
}
}
示例3: PopulateDocument
public static void PopulateDocument(Document doc, FieldConfiguration fConf)
{
var fields = fConf.GetFieldNames();
var tokenBuffer = new StringBuilder();
for (int i = 0; i < fields.Length; ++i)
{
var values = doc.GetValues(fields[i]);
if (values != null)
{
doc.RemoveFields(fields[i]);
for (int k = 0; k < values.Length; ++k)
{
doc.Add(new Field(fields[i], values[i], Field.Store.NO, Field.Index.NOT_ANALYZED));
tokenBuffer.Append(" ").Append(values[i]);
}
}
}
}
示例4: DoAssert
private void DoAssert(Document doc, bool fromIndex)
{
System.String[] keywordFieldValues = doc.GetValues("keyword");
System.String[] textFieldValues = doc.GetValues("text");
System.String[] unindexedFieldValues = doc.GetValues("unindexed");
System.String[] unstoredFieldValues = doc.GetValues("unstored");
Assert.IsTrue(keywordFieldValues.Length == 2);
Assert.IsTrue(textFieldValues.Length == 2);
Assert.IsTrue(unindexedFieldValues.Length == 2);
// this test cannot work for documents retrieved from the index
// since unstored fields will obviously not be returned
if (!fromIndex)
{
Assert.IsTrue(unstoredFieldValues.Length == 2);
}
Assert.IsTrue(keywordFieldValues[0].Equals("test1"));
Assert.IsTrue(keywordFieldValues[1].Equals("test2"));
Assert.IsTrue(textFieldValues[0].Equals("test1"));
Assert.IsTrue(textFieldValues[1].Equals("test2"));
Assert.IsTrue(unindexedFieldValues[0].Equals("test1"));
Assert.IsTrue(unindexedFieldValues[1].Equals("test2"));
// this test cannot work for documents retrieved from the index
// since unstored fields will obviously not be returned
if (!fromIndex)
{
Assert.IsTrue(unstoredFieldValues[0].Equals("test1"));
Assert.IsTrue(unstoredFieldValues[1].Equals("test2"));
}
}
示例5: GetItem
/// <summary>
/// Gets an item from mthe document
/// </summary>
/// <param name="document">The lucene document to use</param>
/// <returns></returns>
protected virtual Item GetItem(Document document)
{
string itemShortId = document.GetValues(SitecoreFields.Id).FirstOrDefault();
if (String.IsNullOrEmpty(itemShortId))
{
return null;
}
ID itemId = new ID(itemShortId);
string language = document.GetValues(SitecoreFields.Language).FirstOrDefault();
if (String.IsNullOrEmpty(language))
{
throw new Exception("The language could not be retrieved from the lucene return");
}
Language itemLanguage = Language.Parse(language);
Item item = DatabaseHelper.GetItem(itemId, itemLanguage);
return item.Versions.Count > 0 ? item : null;
}
示例6: GetSecondarySortString
private string GetSecondarySortString(Document document)
{
return String.Format("{0}_{1}", document.GetValues(BBCFields.SecondarySort).FirstOrDefault(), document.GetValues(BBCFields.Sortable).FirstOrDefault());
}
示例7: MapOffer
private Offer MapOffer(Document doc)
{
int attractivenes;
var strAttractivenes = doc.Get("Attractivenes");
int.TryParse(strAttractivenes, out attractivenes);
return new Offer
{
Id = doc.Get("Id"),
Title = doc.Get("Title"),
Url = doc.Get("Url"),
Price = doc.Get("Price"),
Description = TextHelper.CleanText(doc.Get("Description")),
Pictures = doc.GetValues("Pictures").ToList(),
Date = DateTools.StringToDate(doc.Get("Date")),
Teaser = doc.Get("Teaser")=="1",
PrivateOffer = doc.Get("PrivateOffer") == "1",
Attractivenes = attractivenes,
HaveSeen = doc.Get("HaveSeen") == "1",
Hide = doc.Get("Hide") == "1",
Notes = doc.Get("Notes")
};
}
示例8: CreateSearchResult
protected SearchResult CreateSearchResult(Document doc, float score)
{
string id = doc.Get("id");
if (string.IsNullOrEmpty(id))
{
id = doc.Get(LuceneIndexer.IndexNodeIdFieldName);
}
var sr = new SearchResult()
{
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 (var field in fields.Cast<Field>())
{
var fieldName = field.Name();
var values = doc.GetValues(fieldName);
if (values.Length > 1)
{
sr.MultiValueFields[fieldName] = values.ToList();
//ensure the first value is added to the normal fields
sr.Fields[fieldName] = values[0];
}
else if (values.Length > 0)
{
sr.Fields[fieldName] = values[0];
}
}
return sr;
}