/// <summary>Creates a sort, possibly in reverse, by terms in the given field, parsed /// to numeric values using a custom <see cref="Search.Parser" />. /// </summary> /// <param name="field"> Name of field to sort by. Must not be null. /// </param> /// <param name="parser">Instance of a <see cref="Search.Parser" />, /// which must subclass one of the existing numeric /// parsers from <see cref="FieldCache" />. Sort type is inferred /// by testing which numeric parser the parser subclasses. /// </param> /// <param name="reverse">True if natural order should be reversed. /// </param> /// <throws> IllegalArgumentException if the parser fails to </throws> /// <summary> subclass an existing numeric parser, or field is null /// </summary> public SortField(System.String field, Lucene.Net.Search.Parser parser, bool reverse) { if (parser is Lucene.Net.Search.IntParser) { InitFieldType(field, INT); } else if (parser is Lucene.Net.Search.FloatParser) { InitFieldType(field, FLOAT); } else if (parser is Lucene.Net.Search.ShortParser) { InitFieldType(field, SHORT); } else if (parser is Lucene.Net.Search.ByteParser) { InitFieldType(field, BYTE); } else if (parser is Lucene.Net.Search.LongParser) { InitFieldType(field, LONG); } else if (parser is Lucene.Net.Search.DoubleParser) { InitFieldType(field, DOUBLE); } else { throw new System.ArgumentException("Parser instance does not subclass existing numeric parser from FieldCache (got " + parser + ")"); } this.reverse = reverse; this.parser = parser; }
private FieldCacheRangeFilter(System.String field, Lucene.Net.Search.Parser parser, System.Object lowerVal, System.Object upperVal, bool includeLower, bool includeUpper) { this.field = field; this.parser = parser; this.lowerVal = lowerVal; this.upperVal = upperVal; this.includeLower = includeLower; this.includeUpper = includeUpper; }
private FieldCacheRangeFilter(System.String field, Lucene.Net.Search.Parser parser, System.Object lowerVal, System.Object upperVal, bool includeLower, bool includeUpper) { this.field = field; this.parser = parser; this.lowerVal = lowerVal; this.upperVal = upperVal; this.includeLower = includeLower; this.includeUpper = includeUpper; }
/// <summary> /// Lucene.Net specific. Needed for deserialization /// </summary> /// <param name="info"></param> /// <param name="context"></param> protected SortField(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { //Should we add other fields as in NumericRangeQuery? {{DIGY}} type = (int)info.GetValue("type", typeof(int)); useLegacy = (bool)info.GetValue("useLegacy", typeof(bool)); reverse = (bool)info.GetValue("reverse", typeof(bool)); locale = (System.Globalization.CultureInfo)info.GetValue("locale", typeof(System.Globalization.CultureInfo)); comparatorSource = (FieldComparatorSource)info.GetValue("comparatorSource", typeof(FieldComparatorSource)); factory = (SortComparatorSource)info.GetValue("factory", typeof(FieldComparatorSource)); parser = (Parser)info.GetValue("parser", typeof(Parser)); field = StringHelper.Intern((string)info.GetValue("field", typeof(string))); }
internal AnonymousClassFieldCacheRangeFilter(System.String Param1, Lucene.Net.Search.Parser Param2, System.Object Param3, System.Object Param4, bool Param5, bool Param6) : base(Param1, Param2, Param3, Param4, Param5, Param6) { }
internal static ScoreDocComparator GetCachedComparator(IndexReader reader, System.String field, int type, Lucene.Net.Search.Parser parser, System.Globalization.CultureInfo locale, SortComparatorSource factory) { if (type == SortField.DOC) { return(Lucene.Net.Search.ScoreDocComparator_Fields.INDEXORDER); } if (type == SortField.SCORE) { return(Lucene.Net.Search.ScoreDocComparator_Fields.RELEVANCE); } FieldCacheImpl.Entry entry = (factory != null)?new FieldCacheImpl.Entry(field, factory):((parser != null)?new FieldCacheImpl.Entry(field, type, parser):new FieldCacheImpl.Entry(field, type, locale)); return((ScoreDocComparator)Comparators.Get(reader, entry)); }
protected internal override System.Object CreateValue(IndexReader reader, FieldCacheImpl.Entry entryKey) { FieldCacheImpl.Entry entry = (FieldCacheImpl.Entry)entryKey; System.String fieldname = entry.field; int type = entry.type; System.Globalization.CultureInfo locale = entry.locale; Lucene.Net.Search.Parser parser = null; SortComparatorSource factory = null; if (entry.custom is SortComparatorSource) { factory = (SortComparatorSource)entry.custom; } else { parser = (Lucene.Net.Search.Parser)entry.custom; } ScoreDocComparator comparator; switch (type) { case SortField.AUTO: comparator = Lucene.Net.Search.FieldSortedHitQueue.ComparatorAuto(reader, fieldname); break; case SortField.INT: comparator = Lucene.Net.Search.FieldSortedHitQueue.comparatorInt(reader, fieldname, (Lucene.Net.Search.IntParser)parser); break; case SortField.FLOAT: comparator = Lucene.Net.Search.FieldSortedHitQueue.comparatorFloat(reader, fieldname, (Lucene.Net.Search.FloatParser)parser); break; case SortField.LONG: comparator = Lucene.Net.Search.FieldSortedHitQueue.comparatorLong(reader, fieldname, (Lucene.Net.Search.LongParser)parser); break; case SortField.DOUBLE: comparator = Lucene.Net.Search.FieldSortedHitQueue.comparatorDouble(reader, fieldname, (Lucene.Net.Search.DoubleParser)parser); break; case SortField.SHORT: comparator = Lucene.Net.Search.FieldSortedHitQueue.comparatorShort(reader, fieldname, (Lucene.Net.Search.ShortParser)parser); break; case SortField.BYTE: comparator = Lucene.Net.Search.FieldSortedHitQueue.comparatorByte(reader, fieldname, (Lucene.Net.Search.ByteParser)parser); break; case SortField.STRING: if (locale != null) { comparator = Lucene.Net.Search.FieldSortedHitQueue.comparatorStringLocale(reader, fieldname, locale); } else { comparator = Lucene.Net.Search.FieldSortedHitQueue.comparatorString(reader, fieldname); } break; case SortField.CUSTOM: comparator = factory.NewComparator(reader, fieldname); break; default: throw new System.SystemException("unknown field type: " + type); } return(comparator); }
internal ShortComparator(int numHits, System.String field, Lucene.Net.Search.Parser parser) { values = new short[numHits]; this.field = field; this.parser = (ShortParser)parser; }
internal LongComparator(int numHits, System.String field, Lucene.Net.Search.Parser parser) { values = new long[numHits]; this.field = field; this.parser = (LongParser)parser; }
internal DoubleComparator(int numHits, System.String field, Lucene.Net.Search.Parser parser) { values = new double[numHits]; this.field = field; this.parser = (DoubleParser)parser; }
/// <summary> /// Lucene.Net specific. Needed for deserialization /// </summary> /// <param name="info"></param> /// <param name="context"></param> protected SortField(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { //Should we add other fields as in NumericRangeQuery? {{DIGY}} type = (int)info.GetValue("type", typeof(int)); useLegacy = (bool)info.GetValue("useLegacy", typeof(bool)); reverse = (bool)info.GetValue("reverse", typeof(bool)); locale = (System.Globalization.CultureInfo)info.GetValue("locale", typeof(System.Globalization.CultureInfo)); comparatorSource = (FieldComparatorSource)info.GetValue("comparatorSource", typeof(FieldComparatorSource)); factory = (SortComparatorSource)info.GetValue("factory", typeof(FieldComparatorSource)); parser = (Parser)info.GetValue("parser", typeof(Parser)); field = StringHelper.Intern((string)info.GetValue("field", typeof(string))); }
/// <summary>Creates a sort, possibly in reverse, by terms in the given field, parsed /// to numeric values using a custom {@link FieldCache.Parser}. /// </summary> /// <param name="field"> Name of field to sort by. Must not be null. /// </param> /// <param name="parser">Instance of a {@link FieldCache.Parser}, /// which must subclass one of the existing numeric /// parsers from {@link FieldCache}. Sort type is inferred /// by testing which numeric parser the parser subclasses. /// </param> /// <param name="reverse">True if natural order should be reversed. /// </param> /// <throws> IllegalArgumentException if the parser fails to </throws> /// <summary> subclass an existing numeric parser, or field is null /// </summary> public SortField(System.String field, Lucene.Net.Search.Parser parser, bool reverse) { if (parser is Lucene.Net.Search.IntParser) InitFieldType(field, INT); else if (parser is Lucene.Net.Search.FloatParser) InitFieldType(field, FLOAT); else if (parser is Lucene.Net.Search.ShortParser) InitFieldType(field, SHORT); else if (parser is Lucene.Net.Search.ByteParser) InitFieldType(field, BYTE); else if (parser is Lucene.Net.Search.LongParser) InitFieldType(field, LONG); else if (parser is Lucene.Net.Search.DoubleParser) InitFieldType(field, DOUBLE); else { throw new System.ArgumentException("Parser instance does not subclass existing numeric parser from FieldCache (got " + parser + ")"); } this.reverse = reverse; this.parser = parser; }
internal AnonymousClassFieldCacheRangeFilter(string field, Lucene.Net.Search.Parser parser, string lowerVal, string upperVal, bool includeLower, bool includeUpper) : base(field, parser, lowerVal, upperVal, includeLower, includeUpper) { }
/// <summary>Creates a sort by terms in the given field, parsed /// to numeric values using a custom <see cref="Search.Parser" />. /// </summary> /// <param name="field"> Name of field to sort by. Must not be null. /// </param> /// <param name="parser">Instance of a <see cref="Search.Parser" />, /// which must subclass one of the existing numeric /// parsers from <see cref="FieldCache" />. Sort type is inferred /// by testing which numeric parser the parser subclasses. /// </param> /// <throws> IllegalArgumentException if the parser fails to </throws> /// <summary> subclass an existing numeric parser, or field is null /// </summary> public SortField(System.String field, Lucene.Net.Search.Parser parser) : this(field, parser, false) { }
private int bottom; // Value of bottom of queue internal IntComparator(int numHits, string field, Lucene.Net.Search.Parser parser) { values = new int[numHits]; this.field = field; this.parser = (IntParser)parser; }
internal ByteComparator(int numHits, string field, Lucene.Net.Search.Parser parser) { values = new sbyte[numHits]; this.field = field; this.parser = (ByteParser)parser; }