private static FieldType LoadType() // LUCENENET: Avoid static constructors (see https://github.com/apache/lucenenet/pull/224#issuecomment-469284006) { var type = new FieldType { IsIndexed = true }; type.Freeze(); return(type); }
private void AddDoc(IndexWriter writer, int id) { Document doc = new Document(); doc.Add(new TextField("content", "aaa", Field.Store.NO)); doc.Add(new StringField("id", Convert.ToString(id), Field.Store.YES)); FieldType customType2 = new FieldType(TextField.TYPE_STORED); customType2.StoreTermVectors = true; customType2.StoreTermVectorPositions = true; customType2.StoreTermVectorOffsets = true; doc.Add(new Field("autf8", "Lu\uD834\uDD1Ece\uD834\uDD60ne \u0000 \u2620 ab\ud917\udc17cd", customType2)); doc.Add(new Field("utf8", "Lu\uD834\uDD1Ece\uD834\uDD60ne \u0000 \u2620 ab\ud917\udc17cd", customType2)); doc.Add(new Field("content2", "here is more content with aaa aaa aaa", customType2)); doc.Add(new Field("fie\u2C77ld", "field with non-ascii name", customType2)); // add numeric fields, to test if flex preserves encoding doc.Add(new IntField("trieInt", id, Field.Store.NO)); doc.Add(new LongField("trieLong", (long)id, Field.Store.NO)); // add docvalues fields doc.Add(new NumericDocValuesField("dvByte", (sbyte)id)); sbyte[] bytes = new sbyte[] { (sbyte)((int)((uint)id >> 24)), (sbyte)((int)((uint)id >> 16)), (sbyte)((int)((uint)id >> 8)), (sbyte)id }; BytesRef @ref = new BytesRef((byte[])(Array)bytes); doc.Add(new BinaryDocValuesField("dvBytesDerefFixed", @ref)); doc.Add(new BinaryDocValuesField("dvBytesDerefVar", @ref)); doc.Add(new SortedDocValuesField("dvBytesSortedFixed", @ref)); doc.Add(new SortedDocValuesField("dvBytesSortedVar", @ref)); doc.Add(new BinaryDocValuesField("dvBytesStraightFixed", @ref)); doc.Add(new BinaryDocValuesField("dvBytesStraightVar", @ref)); doc.Add(new DoubleDocValuesField("dvDouble", (double)id)); doc.Add(new FloatDocValuesField("dvFloat", (float)id)); doc.Add(new NumericDocValuesField("dvInt", id)); doc.Add(new NumericDocValuesField("dvLong", id)); doc.Add(new NumericDocValuesField("dvPacked", id)); doc.Add(new NumericDocValuesField("dvShort", (short)id)); // a field with both offsets and term vectors for a cross-check FieldType customType3 = new FieldType(TextField.TYPE_STORED); customType3.StoreTermVectors = true; customType3.StoreTermVectorPositions = true; customType3.StoreTermVectorOffsets = true; customType3.IndexOptions = IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS; doc.Add(new Field("content5", "here is more content with aaa aaa aaa", customType3)); // a field that omits only positions FieldType customType4 = new FieldType(TextField.TYPE_STORED); customType4.StoreTermVectors = true; customType4.StoreTermVectorPositions = false; customType4.StoreTermVectorOffsets = true; customType4.IndexOptions = IndexOptions.DOCS_AND_FREQS; doc.Add(new Field("content6", "here is more content with aaa aaa aaa", customType4)); // TODO: // index different norms types via similarity (we use a random one currently?!) // remove any analyzer randomness, explicitly add payloads for certain fields. writer.AddDocument(doc); }
private void AddNoProxDoc(IndexWriter writer) { Document doc = new Document(); FieldType customType = new FieldType(TextField.TYPE_STORED); customType.IndexOptions = IndexOptions.DOCS_ONLY; Field f = new Field("content3", "aaa", customType); doc.Add(f); FieldType customType2 = new FieldType(); customType2.Stored = true; customType2.IndexOptions = IndexOptions.DOCS_ONLY; f = new Field("content4", "aaa", customType2); doc.Add(f); writer.AddDocument(doc); }