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

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

Introduction

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

Prototype

String name

To view the source code for org.apache.lucene.document Field name.

Click Source Link

Document

Field's name

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;
        }//  www  .  j  a va  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;
        }//  w w  w  .ja  va  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();
        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;
        }//ww w  . ja  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;
        }//from ww  w .  ja  va  2s. 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();
        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));
    }//from   w  w  w. ja  v a  2 s  . 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;
        }// www.j a v  a2s.  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.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  .j a  v 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();
        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 v a 2s. 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.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;
    }/*  w  w w.j  ava2s .  c  om*/

    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  w ww.  java 2 s  .  c  o m
            map.put(fieldname, f.stringValue());
        }
    }

    return map;
}