Package org.apache.lucene.document

Examples of org.apache.lucene.document.TextField


  @Test
  public void testWithInterleavedCommitsUsingLuceneQuery() throws Exception {
    String text = "text";

    Document doc1 = new Document();
    doc1.add(new TextField(text, "Foo1", Store.YES));
    m_indexWriter.addDocument(doc1);
    m_indexWriter.commit();

    Document doc2 = new Document();
    doc2.add(new TextField(text, "Foo2", Store.YES));
    m_indexWriter.addDocument(doc2);
    m_indexWriter.commit();

    Document doc3 = new Document();
    doc3.add(new TextField(text, "Foo3", Store.YES));
    m_indexWriter.addDocument(doc3);
    m_indexWriter.commit();

    DirectoryReader reader = DirectoryReader.open(m_indexWriter, true);
    IndexSearcher searcher = new IndexSearcher(reader);
View Full Code Here


  public void testWithInterleavedCommitsUsingBoboWithFacets() throws Exception {
    String text = "text";
    String color = "color";

    Document doc1 = new Document();
    doc1.add(new TextField(text, "Foo1", Store.YES));
    doc1.add(new StringField(color, RED, Store.YES));
    m_indexWriter.addDocument(doc1);
    m_indexWriter.commit();

    Document doc2 = new Document();
    doc2.add(new TextField(text, "Foo2", Store.YES));
    doc2.add(new StringField(color, RED, Store.YES));
    m_indexWriter.addDocument(doc2);
    m_indexWriter.commit();

    Document doc3 = new Document();
    doc3.add(new TextField(text, "Foo3", Store.YES));
    doc3.add(new StringField(color, BLUE, Store.YES));
    m_indexWriter.addDocument(doc3);
    m_indexWriter.commit();

    SimpleFacetHandler colorHandler = new SimpleFacetHandler(color);
View Full Code Here

      }
    }
  }

  public static Field buildMetaSizePayloadField(final Term term, final int size) {
    Field f = new TextField(term.field(), new MetaTokenStream(term, size));
    return f;
  }
View Full Code Here

   throws Exception
   {
      File file = new File(workDir, fileName);
      Document doc = new Document();
      InputStreamReader is = new InputStreamReader(new FileInputStream(file), "UTF-8");
      doc.add(new TextField("contents", is));
      writer.addDocument(doc);
      writer.commit();
      is.close();
      return writer.newestSegment();
   }
View Full Code Here

    final LineFileDocs docs = new LineFileDocs(random());
    int num = atLeast(100);
    for (int i = 0; i < num; i++) {
      Document doc = docs.nextDoc();
      float nextFloat = random().nextFloat();
      Field f = new TextField(floatTestField, "" + nextFloat, Field.Store.YES);
      f.setBoost(nextFloat);

      doc.add(f);
      writer.addDocument(doc);
      doc.removeField(floatTestField);
      if (rarely()) {
View Full Code Here

        }
        doc.add(new IntField(HISTORICAL.key(), IndexField.getBooleanIndexValue(geoName.getFeatureCode().isHistorical()), Field.Store.NO));
        doc.add(new StringField(FEATURE_CODE.key(), geoName.getFeatureCode().name(), Field.Store.NO));

        // create a unique Document for each name of this GeoName
        TextField nameField = new TextField(INDEX_NAME.key(), "", Field.Store.YES);
        doc.add(nameField);
        for (String name : names) {
            nameField.setStringValue(name);
            indexWriter.addDocument(doc);
        }
    }
View Full Code Here

        // return new TextField(name, value, NO);
        return new StringField(name, value, NO);
    }

    public static Field newFulltextField(String value) {
        return new TextField(FULLTEXT, value, NO);
    }
View Full Code Here

    final LineFileDocs docs = new LineFileDocs(random, defaultCodecSupportsDocValues());
    int num = atLeast(100);
    for (int i = 0; i < num; i++) {
      Document doc = docs.nextDoc();
      int boost = random().nextInt(255);
      Field f = new TextField(byteTestField, "" + boost, Field.Store.YES);
      f.setBoost(boost);
      doc.add(f);
      writer.addDocument(doc);
      doc.removeField(byteTestField);
      if (rarely()) {
        writer.commit();
View Full Code Here

            _TestUtil.checkIndex(dir);
          }
           
        }
        Document document = new Document();
        document.add(new TextField("field", "a field", Field.Store.YES));
        w.addDocument(document);

        for (int i = 0; i < numDocs; i++) {
          Document doc = new Document();
          Field field = newTextField(random(), "field", "a field", Field.Store.YES);
          doc.add(field);
          // random TV
          try {
            w.addDocument(doc);
            assertFalse(field.fieldType().storeTermVectors());
          } catch (RuntimeException e) {
            assertTrue(e.getMessage().startsWith(FailOnTermVectors.EXC_MSG));
          }
          if (random().nextInt(20) == 0) {
            w.commit();
            _TestUtil.checkIndex(dir);
          }
        }
        document = new Document();
        document.add(new TextField("field", "a field", Field.Store.YES));
        w.addDocument(document);
        w.close();
        IndexReader reader = DirectoryReader.open(dir);
        assertTrue(reader.numDocs() > 0);
        SegmentInfos sis = new SegmentInfos();
View Full Code Here

    Token t2 = new Token("bar", 4, 7);
    t2.setPositionIncrement(200);
    TokenStream overflowingTokenStream = new CannedTokenStream(
        new Token[] { t1, t2 }
    );
    Field field = new TextField("foo", overflowingTokenStream);
    doc.add(field);
    try {
      iw.addDocument(doc);
      fail();
    } catch (IllegalArgumentException expected) {
View Full Code Here

TOP

Related Classes of org.apache.lucene.document.TextField

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.