Package org.apache.lucene.document

Examples of org.apache.lucene.document.StringField


  public void addDocument(final String id, final String json)
  throws IOException {
    final Document doc = new Document();

    doc.add(new StringField(DEFAULT_ID_FIELD, id, Store.YES));

    final FieldType sirenFieldType = new FieldType();
    sirenFieldType.setIndexed(true);
    sirenFieldType.setTokenized(true);
    sirenFieldType.setOmitNorms(true);
View Full Code Here


        _localTmpWriter = new IndexWriter(_localTmpDir, _overFlowConf.clone());
        // The local tmp writer has merging disabled so the first document in is
        // going to be doc 0.
        // Therefore the first document added is the prime doc
        List<List<Field>> docs = new ArrayList<List<Field>>(_documents.values());
        docs.get(0).add(new StringField(BlurConstants.PRIME_DOC, BlurConstants.PRIME_DOC_VALUE, Store.NO));
        _localTmpWriter.addDocuments(docs);
      } else {
        _localTmpWriter.addDocuments(_documents.values());
      }
      _documents.clear();
View Full Code Here

            _writer.addDocument(getDeleteDoc());
            _rowDeleteCount.increment(1);
          }
        } else {
          List<List<Field>> docs = new ArrayList<List<Field>>(_documents.values());
          docs.get(0).add(new StringField(BlurConstants.PRIME_DOC, BlurConstants.PRIME_DOC_VALUE, Store.NO));
          _writer.addDocuments(docs);
          _recordRateCounter.mark(_documents.size());
          _documents.clear();
        }
      }
View Full Code Here

      _rowCount.increment(1);
    }

    private Document getDeleteDoc() {
      Document document = new Document();
      document.add(new StringField(BlurConstants.ROW_ID, _deletedRowId, Store.NO));
      document.add(new StringField(BlurConstants.DELETE_MARKER, BlurConstants.DELETE_MARKER_VALUE, Store.NO));
      return document;
    }
View Full Code Here

      }

      if (numericValue != null) {
        if (shouldNumberBeHighlighted(name, numericValue, fieldFixedQuery)) {
          String numberHighlight = preTag + text + postTag;
          result.add(new StringField(name, numberHighlight, Store.YES));
        }
      } else {
        Highlighter highlighter = new Highlighter(htmlFormatter, new QueryScorer(fieldFixedQuery, name));
        TokenStream tokenStream = TokenSources.getAnyTokenStream(reader, docId, name, analyzer);
        TextFragment[] frag = highlighter.getBestTextFragments(tokenStream, text, false, 10);
        for (int j = 0; j < frag.length; j++) {
          if ((frag[j] != null) && (frag[j].getScore() > 0)) {
            result.add(new StringField(name, frag[j].toString(), Store.YES));
          }
        }
      }
    }
    return result;
View Full Code Here

     */
    private FieldFactory() {
    }

    public static Field newPathField(String path) {
        return new StringField(PATH, path, YES);
    }
View Full Code Here

    }

    public static Field newPropertyField(String name, String value) {
        // TODO do we need norms info on the indexed fields ? TextField:StringField
        // return new TextField(name, value, NO);
        return new StringField(name, value, NO);
    }
View Full Code Here

    Directory dir = newDirectory();
    IndexWriterConfig iwc = new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
    iwc.setMergePolicy(newLogMergePolicy());
    IndexWriter iw = new IndexWriter(dir, iwc);
    Document doc = new Document();
    doc.add(new StringField("field1", "sometext", Field.Store.YES));
    doc.add(new TextField("field2", "sometext", Field.Store.NO));
    doc.add(new StringField("foo", "bar", Field.Store.NO));
    iw.addDocument(doc); // add an 'ok' document
    try {
      doc = new Document();
      // try to boost with norms omitted
      List<IndexableField> list = new ArrayList<IndexableField>();
View Full Code Here

    // Create an index with one document
    IndexWriterConfig iwc = new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
    IndexWriter iw = new IndexWriter(dir, iwc);
    Document doc = new Document();
    doc.add(new StringField("foo", "bar", Field.Store.NO));
    iw.addDocument(doc); // add a document
    iw.commit();
    DirectoryReader ir = DirectoryReader.open(dir);
    assertEquals(1, ir.numDocs());
    ir.close();
View Full Code Here

        // too many segments in the index:
        w.setDoRandomForceMergeAssert(false);
      }
      for(int i=0;i<numDocs;i++) {
        Document doc = new Document();
        doc.add(new StringField("id", ""+(docBase+i), Field.Store.NO));
        if (defaultCodecSupportsDocValues()) {
          doc.add(new NumericDocValuesField("f", 1L));
          doc.add(new NumericDocValuesField("cf", 2L));
        }
        w.addDocument(doc);
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.