Package org.apache.lucene.document

Examples of org.apache.lucene.document.IntField


    for (int l = 0; l < num; l++) {
      Document doc = new Document();
      for (int m=0, c=random().nextInt(10); m<=c; m++) {
        int value = random().nextInt(Integer.MAX_VALUE);
        doc.add(newStringField("asc", format.format(value), Field.Store.NO));
        doc.add(new IntField("trie", value, Field.Store.NO));
      }
      writer.addDocument(doc);
    }
    IndexReader reader = writer.getReader();
    writer.close();
View Full Code Here


    final Set<Integer> ordsForDocSet = new HashSet<Integer>();

    for(int id=0;id<NUM_DOCS;id++) {
      Document doc = new Document();

      doc.add(new IntField("id", id, Field.Store.NO));
     
      final int termCount = _TestUtil.nextInt(random(), 0, 20*RANDOM_MULTIPLIER);
      while(ordsForDocSet.size() < termCount) {
        ordsForDocSet.add(random().nextInt(termsArray.length));
      }
View Full Code Here

    final Set<Integer> ordsForDocSet = new HashSet<Integer>();

    for(int id=0;id<NUM_DOCS;id++) {
      Document doc = new Document();

      doc.add(new IntField("id", id, Field.Store.NO));
     
      final int termCount = _TestUtil.nextInt(random(), 0, 20*RANDOM_MULTIPLIER);
      while(ordsForDocSet.size() < termCount) {
        ordsForDocSet.add(random().nextInt(termsArray.length));
      }
View Full Code Here

      ft.freeze();
      final Field field;

      switch(type) {
      case INT:
        field = new IntField(type.name(), 0, ft);
        break;
      case FLOAT:
        field = new FloatField(type.name(), 0.0f, ft);
        break;
      case LONG:
View Full Code Here

      String date = line.substring(0, endOfDate).trim();
      String content = line.substring(endOfDate).trim();
      Document doc = new Document();
      doc.add(newTextField("date", date, Field.Store.YES));
      doc.add(newTextField("contents", content, Field.Store.YES));
      doc.add(new IntField("date2", Integer.valueOf(date), Field.Store.NO));
      writer.addDocument(doc);
      line = d.readLine();
    }
    d.close();
    writer.close();
View Full Code Here

        TEST_VERSION_CURRENT, new MockAnalyzer(random(), MockTokenizer.SIMPLE, true, MockTokenFilter.ENGLISH_STOPSET)));
    for (String text : texts) {
      addDoc(writer, text);
    }
    Document doc = new Document();
    doc.add(new IntField(NUMERIC_FIELD_NAME, 1, Field.Store.NO));
    doc.add(new StoredField(NUMERIC_FIELD_NAME, 1));
    writer.addDocument(doc, analyzer);

    doc = new Document();
    doc.add(new IntField(NUMERIC_FIELD_NAME, 3, Field.Store.NO));
    doc.add(new StoredField(NUMERIC_FIELD_NAME, 3));
    writer.addDocument(doc, analyzer);

    doc = new Document();
    doc.add(new IntField(NUMERIC_FIELD_NAME, 5, Field.Store.NO));
    doc.add(new StoredField(NUMERIC_FIELD_NAME, 5));
    writer.addDocument(doc, analyzer);

    doc = new Document();
    doc.add(new IntField(NUMERIC_FIELD_NAME, 7, Field.Store.NO));
    doc.add(new StoredField(NUMERIC_FIELD_NAME, 7));
    writer.addDocument(doc, analyzer);

    writer.forceMerge(1);
    writer.close();
View Full Code Here

    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", (byte) id));
    byte bytes[] = new byte[] {
      (byte)(id >>> 24), (byte)(id >>> 16),(byte)(id >>> 8),(byte)id
View Full Code Here

    docs.close();
  }

  private void addDoc(RandomIndexWriter w, Collection<String> terms, Map<BytesRef,Integer> termToID, int id) throws IOException {
    Document doc = new Document();
    doc.add(new IntField("id", id, Field.Store.NO));
    if (VERBOSE) {
      System.out.println("TEST: addDoc id:" + id + " terms=" + terms);
    }
    for (String s2 : terms) {
      doc.add(newStringField("f", s2, Field.Store.NO));
View Full Code Here

      ft.setStoreTermVectorPositions(random().nextBoolean());
    }

    for(int docCount=0;docCount<numDocs;docCount++) {
      Document doc = new Document();
      doc.add(new IntField("id", docCount, Field.Store.NO));
      List<Token> tokens = new ArrayList<Token>();
      final int numTokens = atLeast(100);
      //final int numTokens = atLeast(20);
      int pos = -1;
      int offset = 0;
View Full Code Here

    FacetsConfig config = new FacetsConfig();

    // Reused across documents, to add the necessary facet
    // fields:
    Document doc = new Document();
    doc.add(new IntField("num", 10, Field.Store.NO));
    doc.add(new FacetField("Author", "Bob"));
    writer.addDocument(config.build(taxoWriter, doc));

    doc = new Document();
    doc.add(new IntField("num", 20, Field.Store.NO));
    doc.add(new FacetField("Author", "Lisa"));
    writer.addDocument(config.build(taxoWriter, doc));

    doc = new Document();
    doc.add(new IntField("num", 30, Field.Store.NO));
    doc.add(new FacetField("Author", "Lisa"));
    writer.addDocument(config.build(taxoWriter, doc));

    doc = new Document();
    doc.add(new IntField("num", 40, Field.Store.NO));
    doc.add(new FacetField("Author", "Susan"));
    writer.addDocument(config.build(taxoWriter, doc));

    doc = new Document();
    doc.add(new IntField("num", 45, Field.Store.NO));
    doc.add(new FacetField("Author", "Frank"));
    writer.addDocument(config.build(taxoWriter, doc));

    // NRT open
    IndexSearcher searcher = newSearcher(writer.getReader());
View Full Code Here

TOP

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

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.