Example usage for org.apache.lucene.document Field Field

List of usage examples for org.apache.lucene.document Field Field

Introduction

In this page you can find the example usage for org.apache.lucene.document Field Field.

Prototype

protected Field(String name, IndexableFieldType type) 

Source Link

Document

Expert: creates a field with no initial value.

Usage

From source file:action.meetlucene.Indexer.java

License:Apache License

protected Document getDocument(File f) throws Exception {
    Document doc = new Document();
    doc.add(new Field("contents", new FileReader(f))); //7
    doc.add(new Field("filename", f.getName(), Field.Store.YES, Field.Index.NOT_ANALYZED));//8
    doc.add(new Field("fullpath", f.getCanonicalPath(), Field.Store.YES, Field.Index.NOT_ANALYZED));//9
    return doc;/*from   www .j  av  a2s. c  o  m*/
}

From source file:br.usp.icmc.gazetteer.SemanticSearchTest.LuceneSearcher.java

License:Open Source License

public void addDocument(File f) throws FileNotFoundException, IOException {
    Document d = new Document();

    d.add(new Field("content", new FileReader(f)));
    d.add(new Field("filename", f.getName(), Field.Store.YES, Field.Index.ANALYZED));
    writer.addDocument(d);//from  ww w.  j  av a2s  .  c  om
}

From source file:com.browseengine.bobo.test.BoboTestCase.java

License:Open Source License

public static Field buildMetaSizePayloadField(final Term term, final int size) {
    Field f = new Field(term.field(), new MetaTokenStream(term, size));
    return f;/*from   w w  w .j  a  v  a2  s. co  m*/
}

From source file:com.browseengine.bobo.test.section.TestSectionSearch.java

License:Apache License

private void addTextField(Document doc, String fieldName, String[] sections) {
    for (int i = 0; i < sections.length; i++) {
        Field field = new Field(fieldName,
                new SectionTokenStream(analyzer.tokenStream(fieldName, new StringReader(sections[i])), i));
        doc.add(field);/*from w w  w . j  av a  2s . c  o m*/
    }
}

From source file:com.browseengine.bobo.test.section.TestSectionSearch.java

License:Apache License

private void addMetaDataField(Document doc, Term term, int[] meta) {
    IntMetaDataTokenStream tokenStream = new IntMetaDataTokenStream(term.text());
    tokenStream.setMetaData(meta);/*from  ww  w . ja  v a 2 s .c o m*/
    Field field = new Field(term.field(), tokenStream);
    doc.add(field);
}

From source file:com.gprasad.searchwithlucene.Indexer.java

private static void fileToIndexDoc(File file) throws IOException {
    System.out.println(">> EXT : " + getFileExtension(file));
    totalFile++;/*  w w  w. ja  v  a2  s . c  o m*/
    if (getFileExtension(file).equalsIgnoreCase("java")) {
        System.out.println(">> File Indexed : " + file.getCanonicalPath());
        Document doc = new Document();
        doc.add(new Field("contents", new FileReader(file)));
        doc.add(new Field("filename", file.getCanonicalPath(), Field.Store.YES, Field.Index.ANALYZED));
        writer.addDocument(doc);
        count++;
    }
}

From source file:com.isotrol.impe3.nr.core.DocumentBuilder.java

License:Open Source License

/**
 * Adds bytes to document with compress mode.
 * @param bytes the byte array/*from  ww w . ja va  2s .  c  om*/
 * @param compressed if true bytes goes compress
 * @return fluid builder
 */
public DocumentBuilder setBytes(byte[] bytes, boolean compressed) {
    document.add(new Field(Schema.CONTENT_STORE, compressed ? compress(bytes) : bytes));
    siu(Schema.COMPRESSED, compressed ? Schema.COMPRESSED_VALUE : O);
    return this;
}

From source file:com.isotrol.impe3.nr.core.DocumentBuilder.java

License:Open Source License

/**
 * Adds an user binary property field to the document.
 * @param name Field name (not null). Must start with {@code Schema.BLOB_PREFIX}.
 * @param value Field value (not null)//from w w  w  .  j  a  va 2 s .  c o m
 * @return fluid builder
 */
public DocumentBuilder setField(String name, byte[] value) {
    checkNotNull(name);
    checkNotNull(value);
    checkArgument(name.startsWith(Schema.BLOB_PREFIX) && name.length() > Schema.BLOB_PREFIX.length());
    document.add(new Field(name, value));
    return this;
}

From source file:com.leavesfly.lia.meetlucene.Indexer.java

License:Apache License

protected Document getDocument(File f) throws Exception {
    Document doc = new Document();
    doc.add(new Field("contents", new FileReader(f))); // 7
    doc.add(new Field("filename", f.getName(), // 8
            Field.Store.YES, Field.Index.NOT_ANALYZED));// 8
    doc.add(new Field("fullpath", f.getCanonicalPath(), // 9
            Field.Store.YES, Field.Index.NOT_ANALYZED));// 9
    return doc;//from  w ww  .  j ava 2 s. c  o  m
}

From source file:com.mathworks.xzheng.meetlucene.Indexer.java

License:Apache License

protected Document getDocument(File f) throws Exception {
    Document doc = new Document();
    doc.add(new Field("contents", new FileReader(f))); //7
    doc.add(new Field("filename", f.getName(), //8
            Field.Store.YES, Field.Index.NOT_ANALYZED));//8
    doc.add(new Field("fullpath", f.getCanonicalPath(), //9
            Field.Store.YES, Field.Index.NOT_ANALYZED));//9
    return doc;/*from   ww w  . ja  va 2  s. c  o m*/
}