Example usage for org.apache.lucene.document Document fields

List of usage examples for org.apache.lucene.document Document fields

Introduction

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

Prototype

List fields

To view the source code for org.apache.lucene.document Document fields.

Click Source Link

Usage

From source file:axiom.db.utils.LuceneManipulator.java

License:Open Source License

protected Document convertDocument(Document doc) {
    Document ndoc = new Document();
    Enumeration e = doc.fields();

    while (e.hasMoreElements()) {
        Field f = (Field) e.nextElement();
        Field.Store currstore = Field.Store.YES;
        if (!f.isStored()) {
            currstore = Field.Store.NO;
        } else if (f.isCompressed()) {
            currstore = Field.Store.COMPRESS;
        }//from   w  w w . j  av  a 2 s  .c  o m
        Field.Index curridx = Field.Index.UN_TOKENIZED;
        if (!f.isIndexed()) {
            curridx = Field.Index.NO;
        } else if (f.isTokenized()) {
            curridx = Field.Index.TOKENIZED;
        }

        String name = f.name();
        String value = f.stringValue();

        ndoc.add(new Field(name, value, currstore, curridx));
    }

    return ndoc;
}

From source file:axiom.objectmodel.dom.convert.LuceneVersion2Convertor.java

License:Open Source License

public Document convertDocument(Document doc) {
    Document ndoc = new Document();
    Enumeration e = doc.fields();

    while (e.hasMoreElements()) {
        Field f = (Field) e.nextElement();
        Field.Store currstore = Field.Store.YES;
        if (!f.isStored()) {
            currstore = Field.Store.NO;
        } else if (f.isCompressed()) {
            currstore = Field.Store.COMPRESS;
        }/*from  w w w  . j a v  a  2s  . co m*/
        Field.Index curridx = Field.Index.UN_TOKENIZED;
        if (!f.isIndexed()) {
            curridx = Field.Index.NO;
        } else if (f.isTokenized()) {
            curridx = Field.Index.TOKENIZED;
        }

        String name = f.name();
        String value = f.stringValue();
        if (name.startsWith("__")) {
            name = name.substring(1);
            if ("_state".equals(name)) {
                name = "_status";
            } else if ("_prototype".equals(name) || "_parentproto".equals(name)) {
                if ("HopObject".equalsIgnoreCase(value)) {
                    value = "AxiomObject";
                }
            }
        }
        ndoc.add(new Field(name, value, currstore, curridx));
    }

    return ndoc;
}

From source file:axiom.objectmodel.dom.convert.LuceneVersion3Convertor.java

License:Open Source License

public Document convertDocument(Document doc) {

    Document ndoc = new Document();
    Enumeration e = doc.fields();

    while (e.hasMoreElements()) {
        Field f = (Field) e.nextElement();
        Field.Store currstore = Field.Store.YES;
        if (!f.isStored()) {
            currstore = Field.Store.NO;
        } else if (f.isCompressed()) {
            currstore = Field.Store.COMPRESS;
        }/*from   w ww  . j  a  v  a2 s.  c  o m*/
        Field.Index curridx = Field.Index.UN_TOKENIZED;
        if (!f.isIndexed()) {
            curridx = Field.Index.NO;
        } else if (f.isTokenized()) {
            curridx = Field.Index.TOKENIZED;
        }

        String name = f.name();
        String value = f.stringValue();
        if (name.startsWith("__")) {
            name = name.substring(1);
            if ("_state".equals(name)) {
                name = "_status";
            } else if ("_prototype".equals(name) || "_parentproto".equals(name)) {
                if ("HopObject".equalsIgnoreCase(value)) {
                    value = "AxiomObject";
                }
            }
        }
        ndoc.add(new Field(name, value, currstore, curridx));
    }

    return ndoc;
}

From source file:axiom.objectmodel.dom.convert.LuceneVersion4Convertor.java

License:Open Source License

public Document convertDocument(Document doc) {

    Document ndoc = new Document();
    Enumeration e = doc.fields();

    final String prototype = doc.get("_prototype");
    final Prototype proto = app.getPrototypeByName(prototype);

    while (e.hasMoreElements()) {
        Field f = (Field) e.nextElement();
        Field.Store currstore = Field.Store.YES;
        if (!f.isStored()) {
            currstore = Field.Store.NO;
        } else if (f.isCompressed()) {
            currstore = Field.Store.COMPRESS;
        }/* www  .ja v a2 s  .co m*/
        Field.Index curridx = Field.Index.UN_TOKENIZED;
        if (!f.isIndexed()) {
            curridx = Field.Index.NO;
        } else if (f.isTokenized()) {
            curridx = Field.Index.TOKENIZED;
        }

        String name = f.name();
        String value = f.stringValue();
        final int type = this.getTypeForProperty(proto, name);
        if (type == IProperty.DATE) {
            value = formatDate(value);
        } else if (type == IProperty.TIME) {
            value = formatTime(value);
        }
        ndoc.add(new Field(name, value, currstore, curridx));
    }

    return ndoc;
}

From source file:axiom.objectmodel.dom.convert.LuceneVersion5Convertor.java

License:Open Source License

protected Document convertDocument(Document doc) {
    Document ndoc = new Document();
    Enumeration e = doc.fields();
    if (doc.get("cms_sortable_prototype") == null) {
        ndoc.add(new Field("cms_sortable_prototype", getDisplayPrototype(cms_props, doc.get("_prototype")),
                Field.Store.YES, Field.Index.UN_TOKENIZED));
    }/*w w w.  ja  v  a2s  .c om*/
    if (doc.get("cms_sortabletitle") == null && doc.get("title") != null) {
        ndoc.add(new Field("cms_sortabletitle", doc.get("title").toLowerCase(), Field.Store.YES,
                Field.Index.UN_TOKENIZED));
    }

    while (e.hasMoreElements()) {
        Field f = (Field) e.nextElement();
        Field.Store currstore = Field.Store.YES;
        if (!f.isStored()) {
            currstore = Field.Store.NO;
        } else if (f.isCompressed()) {
            currstore = Field.Store.COMPRESS;
        }
        Field.Index curridx = Field.Index.UN_TOKENIZED;
        if (!f.isIndexed()) {
            curridx = Field.Index.NO;
        } else if (f.isTokenized()) {
            curridx = Field.Index.TOKENIZED;
        }

        String name = f.name();
        String value = f.stringValue();

        ndoc.add(new Field(name, value, currstore, curridx));
    }

    return ndoc;
}

From source file:axiom.objectmodel.dom.convert.LuceneVersion6Convertor.java

License:Open Source License

protected Document convertDocument(Document doc) {

    Document ndoc = new Document();
    Enumeration e = doc.fields();

    while (e.hasMoreElements()) {
        Field f = (Field) e.nextElement();
        Field.Store currstore = Field.Store.YES;
        if (!f.isStored()) {
            currstore = Field.Store.NO;
        } else if (f.isCompressed()) {
            currstore = Field.Store.COMPRESS;
        }//  w  w  w . j av a  2 s. c om
        Field.Index curridx = Field.Index.UN_TOKENIZED;
        if (!f.isIndexed()) {
            curridx = Field.Index.NO;
        } else if (f.isTokenized()) {
            curridx = Field.Index.TOKENIZED;
        }

        String name = f.name();
        String value = f.stringValue();
        if (name.equals("cms_lasteditedby")) {
            Date last = new Date(Long.parseLong(doc.get("_lastmodified")));
            String user = doc.get("lastmodifiedby");
            if (user == null) {
                user = "";
            }
            value = last.getDate() + " " + months[last.getMonth()] + " " + (last.getYear() + "").substring(1)
                    + ", " + last.getHours() + ':'
                    + (last.getMinutes() < 10 ? '0' + last.getMinutes() : last.getMinutes()) + " by " + user;
        }
        ndoc.add(new Field(name, value, currstore, curridx));
    }

    return ndoc;
}

From source file:axiom.objectmodel.dom.convert.LuceneVersion7Convertor.java

License:Open Source License

protected Document convertDocument(Document doc) throws Exception {
    Document ndoc = new Document();
    Enumeration e = doc.fields();

    final String prototype = doc.get("_prototype");
    final Prototype proto = app.getPrototypeByName(prototype);

    while (e.hasMoreElements()) {
        Field f = (Field) e.nextElement();
        Field.Store currstore = Field.Store.YES;
        if (!f.isStored()) {
            currstore = Field.Store.NO;
        } else if (f.isCompressed()) {
            currstore = Field.Store.COMPRESS;
        }/*from   w w w  .  ja va 2 s  .  co  m*/
        Field.Index curridx = Field.Index.UN_TOKENIZED;
        if (!f.isIndexed()) {
            curridx = Field.Index.NO;
        } else if (f.isTokenized()) {
            curridx = Field.Index.TOKENIZED;
        }

        String name = f.name();
        String value = f.stringValue();
        final int type = this.getTypeForProperty(proto, name);
        if (type == IProperty.DATE) {
            value = formatDate(value);
        } else if (type == IProperty.TIME) {
            value = formatTime(value);
        } else if (type == IProperty.TIMESTAMP) {
            value = formatTimestamp(value);
        } else if (type == IProperty.INTEGER) {
            value = formatInt(value);
        } else if (type == IProperty.FLOAT) {
            value = formatFloat(value);
        } else if (type == IProperty.SMALLFLOAT) {
            value = formatSmallFloat(value);
        } else if (type == IProperty.SMALLINT) {
            value = formatSmallInt(value);
        }
        ndoc.add(new Field(name, value, currstore, curridx));
    }

    return ndoc;
}

From source file:axiom.objectmodel.dom.convert.LuceneVersion8Convertor.java

License:Open Source License

public Document convertDocument(Document doc) {
    Document ndoc = new Document();
    Enumeration e = doc.fields();

    while (e.hasMoreElements()) {
        Field f = (Field) e.nextElement();
        Field.Store currstore = Field.Store.YES;
        if (!f.isStored()) {
            currstore = Field.Store.NO;
        } else if (f.isCompressed()) {
            currstore = Field.Store.COMPRESS;
        }/*from  w w  w .  ja  va2s .c om*/
        Field.Index curridx = Field.Index.UN_TOKENIZED;
        if (!f.isIndexed()) {
            curridx = Field.Index.NO;
        } else if (f.isTokenized()) {
            curridx = Field.Index.TOKENIZED;
        }

        String name = f.name();
        String value = f.stringValue();

        ndoc.add(new Field(name, value, currstore, curridx));
    }

    return ndoc;
}

From source file:axiom.objectmodel.dom.convert.LuceneVersion9Convertor.java

License:Open Source License

public Document convertDocument(Document doc) {
    Field protoField = doc.getField(LuceneManager.PROTOTYPE);
    if (protoField != null && ("CMSTask".equalsIgnoreCase(protoField.stringValue())
            || "CMSTaskContainer".equalsIgnoreCase(protoField.stringValue()))) {
        return null;
    }/*from   ww  w  . jav  a2  s. c  o  m*/

    Document ndoc = new Document();
    Enumeration e = doc.fields();

    String id = null, layer = null;
    Field idField = doc.getField(LuceneManager.ID);
    Field layerField = doc.getField(LuceneManager.LAYER_OF_SAVE);
    if (idField != null && layerField != null) {
        id = idField.stringValue();
        layer = layerField.stringValue();
    }

    while (e.hasMoreElements()) {
        Field f = (Field) e.nextElement();
        Field.Store currstore = Field.Store.YES;
        if (!f.isStored()) {
            currstore = Field.Store.NO;
        } else if (f.isCompressed()) {
            currstore = Field.Store.COMPRESS;
        }
        Field.Index curridx = Field.Index.UN_TOKENIZED;
        if (!f.isIndexed()) {
            curridx = Field.Index.NO;
        } else if (f.isTokenized()) {
            curridx = Field.Index.TOKENIZED;
        }

        String name = f.name();
        String value = f.stringValue();

        if (!("84".equals(id) && "1".equals(layer) && "_task".equals(name))
                && !("71".equals(id) && "1".equals(layer) && "_task".equals(name))) {

            ndoc.add(new Field(name, value, currstore, curridx));
        }
    }

    return ndoc;
}

From source file:axiom.objectmodel.dom.LuceneManager.java

License:Open Source License

public static HashMap luceneDocumentToMap(Document doc) {
    HashMap map = new HashMap();

    Enumeration e = doc.fields();
    while (e.hasMoreElements()) {
        Field f = (Field) e.nextElement();
        String fieldname = f.name();
        if (LuceneManager.isSearchOnlyField(fieldname)) {
            map.put(fieldname, undoFields(doc.getFields(fieldname)));
        } else {/*from   www  . j  a  v  a  2s.c om*/
            map.put(fieldname, f.stringValue());
        }
    }

    return map;
}