Beispiel #1
0
            public virtual void  IndexDoc()
            {
                Document d = new Document();

                System.Collections.ArrayList fields = new System.Collections.ArrayList();
                System.String idString = GetIdString();
                Field         idField  = new Field(Lucene.Net.Index.TestStressIndexing2.idTerm.Field, idString, Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS);

                fields.Add(idField);

                int nFields = NextInt(Lucene.Net.Index.TestStressIndexing2.maxFields);

                for (int i = 0; i < nFields; i++)
                {
                    Field.TermVector tvVal = Field.TermVector.NO;
                    switch (NextInt(4))
                    {
                    case 0:
                        tvVal = Field.TermVector.NO;
                        break;

                    case 1:
                        tvVal = Field.TermVector.YES;
                        break;

                    case 2:
                        tvVal = Field.TermVector.WITH_POSITIONS;
                        break;

                    case 3:
                        tvVal = Field.TermVector.WITH_POSITIONS_OFFSETS;
                        break;
                    }

                    switch (NextInt(4))
                    {
                    case 0:
                        fields.Add(new Field("f" + NextInt(100), GetString(1), Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS, tvVal));
                        break;

                    case 1:
                        fields.Add(new Field("f" + NextInt(100), GetString(0), Field.Store.NO, Field.Index.ANALYZED, tvVal));
                        break;

                    case 2:
                        fields.Add(new Field("f" + NextInt(100), GetString(0), Field.Store.YES, Field.Index.NO, Field.TermVector.NO));
                        break;

                    case 3:
                        fields.Add(new Field("f" + NextInt(100), GetString(Lucene.Net.Index.TestStressIndexing2.bigFieldSize), Field.Store.YES, Field.Index.ANALYZED, tvVal));
                        break;
                    }
                }

                if (Lucene.Net.Index.TestStressIndexing2.sameFieldOrder)
                {
                    CollectionsHelper.Sort(fields, Lucene.Net.Index.TestStressIndexing2.fieldNameComparator);
                }
                else
                {
                    // random placement of id field also
                    int index = NextInt(fields.Count);
                    fields[0]     = fields[index];
                    fields[index] = idField;
                }

                for (int i = 0; i < fields.Count; i++)
                {
                    d.Add((IFieldable)fields[i]);
                }
                w.UpdateDocument(Lucene.Net.Index.TestStressIndexing2.idTerm.CreateTerm(idString), d);
                // System.out.println("indexing "+d);
                docs[idString] = d;
            }