本文整理汇总了C#中Lucene.Net.Search.SortField类的典型用法代码示例。如果您正苦于以下问题:C# SortField类的具体用法?C# SortField怎么用?C# SortField使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SortField类属于Lucene.Net.Search命名空间,在下文中一共展示了SortField类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: FieldSortedHitQueue
/// <summary> Creates a hit queue sorted by the given list of fields.</summary>
/// <param name="reader"> Index to use.
/// </param>
/// <param name="fields">Fieldable names, in priority order (highest priority first). Cannot be <c>null</c> or empty.
/// </param>
/// <param name="size"> The number of hits to retain. Must be greater than zero.
/// </param>
/// <throws> IOException </throws>
public FieldSortedHitQueue(IndexReader reader, SortField[] fields, int size)
{
int n = fields.Length;
comparators = new ScoreDocComparator[n];
this.fields = new SortField[n];
for (int i = 0; i < n; ++i)
{
System.String fieldname = fields[i].GetField();
comparators[i] = GetCachedComparator(reader, fieldname, fields[i].GetType(), fields[i].GetParser(), fields[i].GetLocale(), fields[i].GetFactory());
// new SortField instances must only be created when auto-detection is in use
if (fields[i].GetType() == SortField.AUTO)
{
if (comparators[i].SortType() == SortField.STRING)
{
this.fields[i] = new SortField(fieldname, fields[i].GetLocale(), fields[i].GetReverse());
}
else
{
this.fields[i] = new SortField(fieldname, comparators[i].SortType(), fields[i].GetReverse());
}
}
else
{
System.Diagnostics.Debug.Assert(comparators [i].SortType() == fields [i].GetType());
this.fields[i] = fields[i];
}
}
Initialize(size);
}
开发者ID:sinsay,项目名称:SSE,代码行数:37,代码来源:FieldSortedHitQueue.cs
示例2: ParseSort
public Sort ParseSort(string sortSpec)
{
if (sortSpec == null || sortSpec.Length == 0) return null;
string[] parts = sortSep.Split(sortSpec.Trim());
if (parts.Length == 0) return null;
SortField[] lst = new SortField[parts.Length];
for (int i = 0; i < parts.Length; i++)
{
string part = parts[i].Trim();
bool top = true;
int idx = part.IndexOf(' ');
if (idx > 0)
{
string order = part.Substring(idx + 1).Trim();
if ("desc".Equals(order) || "top".Equals(order))
{
top = true;
}
else if ("asc".Equals(order) || "bottom".Equals(order))
{
top = false;
}
else
{
throw new ArgumentException("Unknown sort order: " + order);
}
part = part.Substring(0, idx).Trim();
}
else
{
throw new ArgumentException("Missing sort order.");
}
if ("score".Equals(part))
{
if (top)
{
// If thre is only one thing in the list, just do the regular thing...
if (parts.Length == 1)
{
return null; // do normal scoring...
}
lst[i] = SortField.FIELD_SCORE;
}
else
{
lst[i] = new SortField(null, SortField.SCORE, true);
}
}
else
{
lst[i] = new SortField(part, SortField.STRING, top);
}
}
return new Sort(lst);
}
开发者ID:yao-yi,项目名称:BoboBrowse.Net,代码行数:59,代码来源:BoboDefaultQueryBuilder.cs
示例3: GetHitsByFiled
private Hits GetHitsByFiled(string filedname,Analyzer analyzer, string searchStr, IndexSearcher searcher)
{
MultiFieldQueryParser parser = new MultiFieldQueryParser(Lucene.Net.Util.Version.LUCENE_CURRENT, new string[] { filedname}, analyzer);
Query query = parser.Parse(searchStr);
Sort sort = new Sort();
SortField f = new SortField("publish_time", SortField.STRING, true);//按照publish_time字段排序,true表示降序
sort.SetSort(f);
Hits hits = searcher.Search(query, sort);
return hits;
}
开发者ID:andylaudotnet,项目名称:StockFoo,代码行数:10,代码来源:search1.aspx.cs
示例4: SetFields
/// <summary> Allows redefinition of sort fields if they are <code>null</code>.
/// This is to handle the case using ParallelMultiSearcher where the
/// original list contains AUTO and we don't know the actual sort
/// type until the values come back. The fields can only be set once.
/// This method is thread safe.
/// </summary>
/// <param name="">fields
/// </param>
internal virtual void SetFields(SortField[] fields)
{
lock (this)
{
if (this.fields == null)
{
this.fields = fields;
this.collators = HasCollators(fields);
}
}
}
开发者ID:vikasraz,项目名称:indexsearchutils,代码行数:19,代码来源:FieldDocSortedHitQueue.cs
示例5: ApplySort
public void ApplySort(SortField[] sorts)
{
if (sorts == null)
{
_req.ClearSort();
}
else
{
_req.Sort = sorts;
}
}
开发者ID:modulexcite,项目名称:BoboBrowse.Net,代码行数:11,代码来源:BrowseRequestBuilder.cs
示例6: FieldValueHitQueue
// prevent instantiation and extension.
private FieldValueHitQueue(SortField[] fields)
{
// When we get here, fields.length is guaranteed to be > 0, therefore no
// need to check it again.
// All these are required by this class's API - need to return arrays.
// Therefore even in the case of a single comparator, create an array
// anyway.
this.fields = fields;
int numComparators = fields.Length;
comparators = new FieldComparator[numComparators];
reverseMul = new int[numComparators];
}
开发者ID:BackupTheBerlios,项目名称:lyra2-svn,代码行数:14,代码来源:FieldValueHitQueue.cs
示例7: InternalBrowseHitCollector
public InternalBrowseHitCollector(BoboBrowser boboBrowser, SortField[] sort, int offset, int count, bool fetchStoredFields)
{
this.boboBrowser = boboBrowser;
reader = boboBrowser.GetIndexReader();
sortFields = QueryUtils.convertSort(sort, reader);
this.offset = offset;
this.count = count;
this.numHits = offset + count;
hitQueue = new SortedHitQueue(this.boboBrowser, sortFields, offset + count);
totalHits = 0;
this.fetchStoredFields = fetchStoredFields;
this.reverseMul = (from s in sortFields select s.Reverse ? -1 : 1).ToArray();
}
开发者ID:NightOwl888,项目名称:Bobo-Browse.Net,代码行数:14,代码来源:InternalBrowseHitCollector.cs
示例8: MultiTopDocsSortedHitCollector
public MultiTopDocsSortedHitCollector(MultiBoboBrowser multiBrowser, SortField[] sort, int offset, int count,
bool fetchStoredFields)
{
this.sort = sort;
this.offset = offset;
this.count = count;
this.multiBrowser = multiBrowser;
IBrowsable[] subBrowsers = this.multiBrowser.getSubBrowsers();
subCollectors = new TopDocsSortedHitCollector[subBrowsers.Length];
for (int i = 0; i < subBrowsers.Length; ++i)
{
subCollectors[i] = subBrowsers[i].GetSortedHitCollector(sort, 0, this.offset + this.count, fetchStoredFields);
}
starts = this.multiBrowser.getStarts();
totalCount = 0;
}
开发者ID:NightOwl888,项目名称:Bobo-Browse.Net,代码行数:16,代码来源:MultiTopDocsSortedHitCollector.cs
示例9: OneComparatorFieldValueHitQueue
public OneComparatorFieldValueHitQueue(SortField[] fields, int size):base(fields)
{
if (fields.Length == 0)
{
throw new System.ArgumentException("Sort must contain at least one field");
}
SortField field = fields[0];
// AUTO is resolved before we are called
System.Diagnostics.Debug.Assert(field.GetType() != SortField.AUTO);
comparator = field.GetComparator(size, 0);
oneReverseMul = field.reverse?- 1:1;
comparators[0] = comparator;
reverseMul[0] = oneReverseMul;
Initialize(size);
}
开发者ID:VirtueMe,项目名称:ravendb,代码行数:18,代码来源:FieldValueHitQueue.cs
示例10: GetNonFacetComparatorSource
private static DocComparatorSource GetNonFacetComparatorSource(SortField sf)
{
string fieldname = sf.Field;
CultureInfo locale = sf.Locale;
if (locale != null)
{
return new DocComparatorSource.StringLocaleComparatorSource(fieldname, locale);
}
int type = sf.Type;
switch (type)
{
case SortField.INT:
return new DocComparatorSource.IntDocComparatorSource(fieldname);
case SortField.FLOAT:
return new DocComparatorSource.FloatDocComparatorSource(fieldname);
case SortField.LONG:
return new DocComparatorSource.LongDocComparatorSource(fieldname);
case SortField.DOUBLE:
return new DocComparatorSource.LongDocComparatorSource(fieldname);
case SortField.BYTE:
return new DocComparatorSource.ByteDocComparatorSource(fieldname);
case SortField.SHORT:
return new DocComparatorSource.ShortDocComparatorSource(fieldname);
case SortField.CUSTOM:
throw new InvalidOperationException("lucene custom sort no longer supported: " + fieldname);
case SortField.STRING:
return new DocComparatorSource.StringOrdComparatorSource(fieldname);
case SortField.STRING_VAL:
return new DocComparatorSource.StringValComparatorSource(fieldname);
default:
throw new InvalidOperationException("Illegal sort type: " + type + ", for field: " + fieldname);
}
}
开发者ID:modulexcite,项目名称:BoboBrowse.Net,代码行数:44,代码来源:SortCollector.cs
示例11: NAppIndexReader
public NAppIndexReader(Configuration.ConfigManager config)
{
// TODO: Use Central place to retrieve default setting of Index Full Path
indexFullPath = config.GetSetting(SettingKeys.Index_Directory, System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Index"));
indexFullPath = System.IO.Path.GetFullPath(indexFullPath);
directory = FSDirectory.Open(new System.IO.DirectoryInfo(indexFullPath));
analyzer = new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_29);
var sortFields = new SortField[2];
sortFields[0] = new SortField(FieldKeys.LogName, SortField.STRING);
sortFields[1] = new SortField(FieldKeys.LogID, SortField.LONG);
logNameIDSort = new Sort(sortFields);
textQueryFields = new string[]{
FieldKeys.Service,
FieldKeys.Method,
FieldKeys.Detail_Desc,
FieldKeys.Detail_Parm,
};
}
开发者ID:simonkang,项目名称:NAppProfiler,代码行数:20,代码来源:NAppIndexReader.cs
示例12: FieldSortedHitQueue
/// <summary> Creates a hit queue sorted by the given list of fields.</summary>
/// <param name="reader"> Index to use.
/// </param>
/// <param name="fields">Field names, in priority order (highest priority first). Cannot be <code>null</code> or empty.
/// </param>
/// <param name="size"> The number of hits to retain. Must be greater than zero.
/// </param>
/// <throws> IOException </throws>
public FieldSortedHitQueue(IndexReader reader, SortField[] fields, int size)
{
int n = fields.Length;
comparators = new ScoreDocComparator[n];
this.fields = new SortField[n];
for (int i = 0; i < n; ++i)
{
System.String fieldname = fields[i].GetField();
comparators[i] = GetCachedComparator(reader, fieldname, fields[i].GetType(), fields[i].GetLocale(), fields[i].GetFactory());
if (comparators[i].SortType() == SortField.STRING)
{
this.fields[i] = new SortField(fieldname, fields[i].GetLocale(), fields[i].GetReverse());
}
else
{
this.fields[i] = new SortField(fieldname, comparators[i].SortType(), fields[i].GetReverse());
}
}
Initialize(size);
}
开发者ID:vineelkovvuri,项目名称:ExtendableDesktopSearch,代码行数:29,代码来源:FieldSortedHitQueue.cs
示例13: convertSort
public static SortField[] convertSort(SortField[] sortSpec, BoboIndexReader idxReader)
{
SortField[] retVal = DEFAULT_SORT;
if (sortSpec != null && sortSpec.Length > 0)
{
List<SortField> sortList = new List<SortField>(sortSpec.Length + 1);
bool relevanceSortAdded = false;
for (int i = 0; i < sortSpec.Length; ++i)
{
if (SortField.FIELD_DOC.Equals(sortSpec[i]))
{
sortList.Add(SortField.FIELD_DOC);
}
else if (SortField.FIELD_SCORE.Equals(sortSpec[i]))
{
sortList.Add(SortField.FIELD_SCORE);
relevanceSortAdded = true;
}
else
{
string fieldname = sortSpec[i].Field;
if (fieldname != null)
{
SortField sf = sortSpec[i];
sortList.Add(sf);
}
}
}
if (!relevanceSortAdded)
{
sortList.Add(SortField.FIELD_SCORE);
}
retVal = sortList.ToArray();
}
return retVal;
}
开发者ID:NightOwl888,项目名称:Bobo-Browse.Net,代码行数:36,代码来源:QueryUtils.cs
示例14: Create
/// <summary> Creates a hit queue sorted by the given list of fields.
///
/// <p/><b>NOTE</b>: The instances returned by this method
/// pre-allocate a full array of length <code>numHits</code>.
///
/// </summary>
/// <param name="fields">SortField array we are sorting by in priority order (highest
/// priority first); cannot be <code>null</code> or empty
/// </param>
/// <param name="size">The number of hits to retain. Must be greater than zero.
/// </param>
/// <throws> IOException </throws>
public static FieldValueHitQueue Create(SortField[] fields, int size)
{
if (fields.Length == 0)
{
throw new System.ArgumentException("Sort must contain at least one field");
}
if (fields.Length == 1)
{
return new OneComparatorFieldValueHitQueue(fields, size);
}
else
{
return new MultiComparatorsFieldValueHitQueue(fields, size);
}
}
开发者ID:VirtueMe,项目名称:ravendb,代码行数:29,代码来源:FieldValueHitQueue.cs
示例15: MultiComparatorsFieldValueHitQueue
public MultiComparatorsFieldValueHitQueue(SortField[] fields, int size):base(fields)
{
int numComparators = comparators.Length;
for (int i = 0; i < numComparators; ++i)
{
SortField field = fields[i];
// AUTO is resolved before we are called
System.Diagnostics.Debug.Assert(field.GetType() != SortField.AUTO);
reverseMul[i] = field.reverse?- 1:1;
comparators[i] = field.GetComparator(size, i);
}
Initialize(size);
}
开发者ID:VirtueMe,项目名称:ravendb,代码行数:17,代码来源:FieldValueHitQueue.cs
示例16: FieldDocSortedHitQueue
/// <summary> Creates a hit queue sorted by the given list of fields.</summary>
/// <param name="fields">Fieldable names, in priority order (highest priority first).
/// </param>
/// <param name="size"> The number of hits to retain. Must be greater than zero.
/// </param>
internal FieldDocSortedHitQueue(SortField[] fields, int size)
{
this.fields = fields;
this.collators = HasCollators(fields);
Initialize(size);
}
开发者ID:vikasraz,项目名称:indexsearchutils,代码行数:11,代码来源:FieldDocSortedHitQueue.cs
示例17: SortCollector
protected SortCollector(SortField[] sortFields, bool fetchStoredFields)
{
_sortFields = sortFields;
_fetchStoredFields = fetchStoredFields;
}
开发者ID:yao-yi,项目名称:BoboBrowse.Net,代码行数:5,代码来源:SortCollector.cs
示例18: GetLongFromField
private long GetLongFromField(Document doc, SortField sortField)
{
var field = doc.GetField(sortField.Field);
if (field == null) return 0;
long data;
if (long.TryParse(field.StringValue, out data) && data >= 0) return data;
return 0;
}
开发者ID:revellado,项目名称:privateSocialGroups,代码行数:10,代码来源:SearchSecurityTrimmer.cs
示例19: SetSort
public virtual void SetSort(System.String[] fieldnames)
{
int n = fieldnames.Length;
SortField[] nfields = new SortField[n];
for (int i = 0; i < n; ++i)
{
nfields[i] = new SortField(fieldnames[i], SortField.AUTO);
}
fields = nfields;
}
开发者ID:sinsay,项目名称:SSE,代码行数:10,代码来源:Sort.cs
示例20: Sort
/// <summary>Sorts in succession by the criteria in each SortField. </summary>
public Sort(SortField[] fields)
{
SetSort(fields);
}
开发者ID:sinsay,项目名称:SSE,代码行数:5,代码来源:Sort.cs
注:本文中的Lucene.Net.Search.SortField类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论