Package org.apache.lucene.document

Examples of org.apache.lucene.document.StringField


    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


      else if (i % 2 == 0) make = "rav4";
      else make = "prius";

      String ID = Integer.toString(i);
      Document d = new Document();
      d.add(new StringField("id", ID, Field.Store.YES));
      d.add(new StringField("color", color, Field.Store.YES));
      d.add(new StringField("make", make, Field.Store.YES));
      dataList.add(d);
    }
    return dataList.toArray(new Document[dataList.size()]);
  }
View Full Code Here

  public Document[] createDataTwo() {
    ArrayList<Document> dataList = new ArrayList<Document>();
    String color = "red";
    String ID = Integer.toString(10);
    Document d = new Document();
    d.add(new StringField("id", ID, Field.Store.YES));
    d.add(new StringField("color", color, Field.Store.YES));
    d.add(new IntField("NUM", 10, Field.Store.YES));
    dataList.add(d);

    color = "green";
    ID = Integer.toString(11);
    d = new Document();
    d.add(new StringField("id", ID, Field.Store.YES));
    d.add(new StringField("color", color, Field.Store.YES));
    d.add(new IntField("NUM", 11, Field.Store.YES));
    dataList.add(d);

    return dataList.toArray(new Document[dataList.size()]);
  }
View Full Code Here

    ArrayList<Document> dataList = new ArrayList<Document>();
    for (int i = 0; i < _documentSize; i++) {
      String color = (i % 2 == 0) ? "red" : "green";
      String ID = Integer.toString(i);
      Document d = new Document();
      d.add(new StringField("id", ID, Field.Store.YES));
      d.add(new StringField("color", color, Field.Store.YES));
      dataList.add(d);
    }

    return dataList.toArray(new Document[dataList.size()]);
  }
View Full Code Here

  private BoboBrowser newBrowser() throws IOException {
    return new BoboBrowser(newIndexReader());
  }

  public static Field buildMetaField(String name, String val) {
    Field f = new StringField(name, val, Field.Store.NO);
    return f;
  }
View Full Code Here

    d1.add(buildMetaField("custom", "000003"));
    d1.add(buildMetaField("latitude", "60"));
    d1.add(buildMetaField("longitude", "120"));
    d1.add(buildMetaField("salary", "04500"));

    Field sf = new StringField("testStored", "stored", Store.YES);
    d1.add(sf);

    FieldType ft = new FieldType();
    ft.setStored(false);
    ft.setIndexed(true);
View Full Code Here

    }
   
    FieldType ft = new FieldType(TextField.TYPE_NOT_STORED);
    ft.setOmitNorms(true);
    parentStreamField = new Field(Consts.FIELD_PAYLOADS, parentStream, ft);
    fullPathField = new StringField(Consts.FULL, "", Field.Store.YES);

    nextID = indexWriter.maxDoc();

    if (cache == null) {
      cache = defaultTaxonomyWriterCache();
View Full Code Here

        TEST_VERSION_CURRENT, new MockAnalyzer(random)));
    // we don't need many documents to assert this, but don't use one document either
    int numDocs = atLeast(random, 50);
    for (int i = 0; i < numDocs; i++) {
      Document doc = new Document();
      doc.add(new StringField("f", "doc", Store.NO));
      writer.addDocument(doc);
    }
    writer.close();
   
    Term term = new Term("f", new BytesRef("doc"));
View Full Code Here

    IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
    conf.setCodec(oldCodecs[random().nextInt(oldCodecs.length)]);
    IndexWriter writer = new IndexWriter(dir, conf);
   
    Document doc = new Document();
    doc.add(new StringField("f", "bar", Store.YES));
    doc.add(new NumericDocValuesField("n", 18L));
    writer.addDocument(doc);
   
    OLD_FORMAT_IMPERSONATION_IS_ACTIVE = false;
    try {
View Full Code Here

            // (e.g., Washington State's population is more than 10x that of Washington, DC
            // but Washington, DC is mentioned far more frequently than Washington State)
            doc.add(new LongField(SORT_POP.key(), geoName.getPopulation(), Field.Store.YES));
        }
        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) {
View Full Code Here

TOP

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

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.