Java Code Examples for org.apache.lucene.document.Field#Store

The following examples show how to use org.apache.lucene.document.Field#Store . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HardwareDeviceDocumentBuilder.java    From uyuni with GNU General Public License v2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
public Document buildDocument(Long objId, Map<String, String> metadata) {
    Document doc = new Document();
    doc.add(new Field("id", objId.toString(), Field.Store.YES,
            Field.Index.UN_TOKENIZED));

    for (Iterator<String> iter = metadata.keySet().iterator(); iter.hasNext();) {
        Field.Store store = Field.Store.YES;
        Field.Index tokenize = Field.Index.TOKENIZED;

        String name = iter.next();
        String value = metadata.get(name);

        if (name.equals("name") || (name.equals("description"))) {
            store = Field.Store.YES;
        }
        else if (name.equals("serverId")) {
            store = Field.Store.YES;
            tokenize = Field.Index.UN_TOKENIZED;
        }

        doc.add(new Field(name, String.valueOf(value), store,
                tokenize));
    }
    return doc;
}
 
Example 2
Source File: XccdfIdentDocumentBuilder.java    From uyuni with GNU General Public License v2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
public Document buildDocument(Long objId, Map<String, String> metadata) {
    Document doc = new Document();
    doc.add(new Field("id", objId.toString(), Field.Store.YES,
            Field.Index.UN_TOKENIZED));

    for (Iterator<String> iter = metadata.keySet().iterator(); iter.hasNext();) {
        Field.Store store = Field.Store.YES;
        Field.Index tokenize = Field.Index.TOKENIZED;

        String name = iter.next();
        String value = metadata.get(name);

        doc.add(new Field(name, String.valueOf(value), store,
                tokenize));
    }
    return doc;
}
 
Example 3
Source File: HardwareDeviceDocumentBuilder.java    From spacewalk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
public Document buildDocument(Long objId, Map<String, String> metadata) {
    Document doc = new Document();
    doc.add(new Field("id", objId.toString(), Field.Store.YES,
            Field.Index.UN_TOKENIZED));

    for (Iterator<String> iter = metadata.keySet().iterator(); iter.hasNext();) {
        Field.Store store = Field.Store.YES;
        Field.Index tokenize = Field.Index.TOKENIZED;

        String name = iter.next();
        String value = metadata.get(name);

        if (name.equals("name") || (name.equals("description"))) {
            store = Field.Store.YES;
        }
        else if (name.equals("serverId")) {
            store = Field.Store.YES;
            tokenize = Field.Index.UN_TOKENIZED;
        }

        doc.add(new Field(name, String.valueOf(value), store,
                tokenize));
    }
    return doc;
}
 
Example 4
Source File: XccdfIdentDocumentBuilder.java    From spacewalk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
public Document buildDocument(Long objId, Map<String, String> metadata) {
    Document doc = new Document();
    doc.add(new Field("id", objId.toString(), Field.Store.YES,
            Field.Index.UN_TOKENIZED));

    for (Iterator<String> iter = metadata.keySet().iterator(); iter.hasNext();) {
        Field.Store store = Field.Store.YES;
        Field.Index tokenize = Field.Index.TOKENIZED;

        String name = iter.next();
        String value = metadata.get(name);

        doc.add(new Field(name, String.valueOf(value), store,
                tokenize));
    }
    return doc;
}
 
Example 5
Source File: ErrataDocumentBuilder.java    From uyuni with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public Document buildDocument(Long objId, Map<String, String> metadata) {
    Document doc = new Document();
    doc.add(new Field("id", objId.toString(), Field.Store.YES,
            Field.Index.UN_TOKENIZED));

    for (Iterator<String> iter = metadata.keySet().iterator(); iter.hasNext();) {
        Field.Store store = Field.Store.NO;
        Field.Index tokenize = Field.Index.TOKENIZED;

        String name = iter.next();
        String value = metadata.get(name);

        if (name.equals("name") || name.equals("advisoryName")) {
            store = Field.Store.YES;
        }
        else if (name.equals("synopsis") || name.equals("description") ||
                name.equals("topic") || name.equals("solution")) {
            // index, but do not store
        }
        else {
            // skip - do not store or index
            continue;
        }

        doc.add(new Field(name, String.valueOf(value), store,
                tokenize));
    }
    return doc;
}
 
Example 6
Source File: ServerDocumentBuilder.java    From uyuni with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public Document buildDocument(Long objId, Map<String, String> metadata) {
    Document doc = new Document();
    // Keep 'id' UN_TOKENIZED, this is needed to determine 'uniqueness'
    // if you tokenize this it will break deleting documents, we'll
    // no longer have unique documents per id.

    doc.add(new Field("id", objId.toString(), Field.Store.YES,
            Field.Index.UN_TOKENIZED));
    // This is the tokenized form of 'id' so we can do searches on it and
    // use ngram flexibility
    doc.add(new Field("system_id", objId.toString(), Field.Store.YES,
            Field.Index.TOKENIZED));

    for (Iterator<String> iter = metadata.keySet().iterator(); iter.hasNext();) {
        Field.Store store = Field.Store.YES;
        Field.Index tokenize = Field.Index.TOKENIZED;

        String name = iter.next();
        String value = metadata.get(name);

        if (name.equals("name") || name.equals("cpuModel") ||
                name.equals("hostname") || name.equals("ipaddr") ||
                name.equals("ip6addr") ||
                (name.equals("runningKernel"))) {
            store = Field.Store.YES;
        }
        else if (name.equals("checkin") || name.equals("registered") ||
                name.equals("ram") || name.equals("swap") ||
                name.equals("cpuMHz") | name.equals("cpuNumberOfCpus")) {
            store = Field.Store.YES;
            tokenize = Field.Index.UN_TOKENIZED;
        }

        doc.add(new Field(name, String.valueOf(value), store,
                tokenize));
    }
    return doc;
}
 
Example 7
Source File: ServerCustomInfoDocumentBuilder.java    From uyuni with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public Document buildDocument(Long objId, Map<String, String> metadata) {
    Document doc = new Document();
    doc.add(new Field("id", objId.toString(), Field.Store.YES,
            Field.Index.UN_TOKENIZED));

    for (Iterator<String> iter = metadata.keySet().iterator(); iter.hasNext();) {
        Field.Store store = Field.Store.YES;
        Field.Index tokenize = Field.Index.TOKENIZED;

        String name = iter.next();
        String value = metadata.get(name);

        if (name.equals("value")) {
            store = Field.Store.YES;
        }
        else if (name.equals("created") || (name.equals("modified"))) {
            store = Field.Store.YES;
            tokenize = Field.Index.UN_TOKENIZED;
        }
        else if (name.equals("serverId") || name.equals("createdBy") ||
                name.equals("lastModifiedBy")) {
            store = Field.Store.YES;
            tokenize = Field.Index.UN_TOKENIZED;
        }

        doc.add(new Field(name, String.valueOf(value), store,
                tokenize));
    }
    return doc;
}
 
Example 8
Source File: PackageDocumentBuilder.java    From uyuni with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public Document buildDocument(Long objId, Map<String, String> metadata) {
    Document doc = new Document();
    doc.add(new Field("id", objId.toString(), Field.Store.YES,
            Field.Index.UN_TOKENIZED));

    for (Iterator<String> iter = metadata.keySet().iterator(); iter
            .hasNext();) {
        Field.Store store = Field.Store.YES;
        Field.Index tokenize = Field.Index.TOKENIZED;

        String name = iter.next();
        String value = metadata.get(name);
        if (name.equals("name")) {
            store = Field.Store.YES;
        }
        else if (name.equals("arch") || name.equals("filename") ||
                name.equals("version") || name.equals("release") ||
                name.equals("epoch")) {
            tokenize = Field.Index.UN_TOKENIZED;
        }

        doc.add(new Field(name, String.valueOf(value), store,
                tokenize));
    }
    return doc;
}
 
Example 9
Source File: SnapshotTagDocumentBuilder.java    From uyuni with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public Document buildDocument(Long objId, Map<String, String> metadata) {
    Document doc = new Document();
    doc.add(new Field("id", objId.toString(), Field.Store.YES,
            Field.Index.UN_TOKENIZED));

    for (Iterator<String> iter = metadata.keySet().iterator(); iter.hasNext();) {
        Field.Store store = Field.Store.YES;
        Field.Index tokenize = Field.Index.TOKENIZED;

        String name = iter.next();
        String value = metadata.get(name);

        if (name.equals("name")) {
            store = Field.Store.YES;
        }
        else if (name.equals("created") || (name.equals("modified"))) {
            store = Field.Store.YES;
            tokenize = Field.Index.UN_TOKENIZED;
        }
        else if (name.equals("snapshotId") || name.equals("tagNameId") ||
                name.equals("serverId") || name.equals("orgId")) {
            store = Field.Store.YES;
            tokenize = Field.Index.UN_TOKENIZED;
        }

        doc.add(new Field(name, String.valueOf(value), store,
                tokenize));
    }
    return doc;
}
 
Example 10
Source File: IndexedField.java    From sql-layer with GNU Affero General Public License v3.0 5 votes vote down vote up
public Field getField(ValueSource value) {
    if (value.isNull()) 
        return null;
    Field.Store store = Field.Store.NO; // Only store hkey.
    switch (fieldType) {
    case INT:
        switch (TInstance.underlyingType(value.getType())) {
        case INT_8:
            return new IntField(name, value.getInt8(), store);
        case INT_16:
            return new IntField(name, value.getInt16(), store);
        case UINT_16:
            return new IntField(name, value.getUInt16(), store);
        case INT_32:
        default:
            return new IntField(name, value.getInt32(), store);
        }
    case LONG:
        return new LongField(name, value.getInt64(), store);
    case FLOAT:
        return new FloatField(name, value.getFloat(), store);
    case DOUBLE:
        return new DoubleField(name, value.getDouble(), store);
    case STRING:
        switch (TInstance.underlyingType(value.getType())) {
        case STRING:
            return new StringField(name, value.getString(), store);
        default:
            {
                StringBuilder str = new StringBuilder();
                value.getType().format(value, AkibanAppender.of(str));
                return new StringField(name, str.toString(), store);
            }
        }
    case TEXT:
        return new TextField(name, value.getString(), store);
    default:
        return null;
    }
}
 
Example 11
Source File: ErrataDocumentBuilder.java    From spacewalk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public Document buildDocument(Long objId, Map<String, String> metadata) {
    Document doc = new Document();
    doc.add(new Field("id", objId.toString(), Field.Store.YES,
            Field.Index.UN_TOKENIZED));

    for (Iterator<String> iter = metadata.keySet().iterator(); iter.hasNext();) {
        Field.Store store = Field.Store.NO;
        Field.Index tokenize = Field.Index.TOKENIZED;

        String name = iter.next();
        String value = metadata.get(name);

        if (name.equals("name") || name.equals("advisoryName")) {
            store = Field.Store.YES;
        }
        else if (name.equals("synopsis") || name.equals("description") ||
                name.equals("topic") || name.equals("solution")) {
            // index, but do not store
        }
        else {
            // skip - do not store or index
            continue;
        }

        doc.add(new Field(name, String.valueOf(value), store,
                tokenize));
    }
    return doc;
}
 
Example 12
Source File: ServerDocumentBuilder.java    From spacewalk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public Document buildDocument(Long objId, Map<String, String> metadata) {
    Document doc = new Document();
    // Keep 'id' UN_TOKENIZED, this is needed to determine 'uniqueness'
    // if you tokenize this it will break deleting documents, we'll
    // no longer have unique documents per id.

    doc.add(new Field("id", objId.toString(), Field.Store.YES,
            Field.Index.UN_TOKENIZED));
    // This is the tokenized form of 'id' so we can do searches on it and
    // use ngram flexibility
    doc.add(new Field("system_id", objId.toString(), Field.Store.YES,
            Field.Index.TOKENIZED));

    for (Iterator<String> iter = metadata.keySet().iterator(); iter.hasNext();) {
        Field.Store store = Field.Store.YES;
        Field.Index tokenize = Field.Index.TOKENIZED;

        String name = iter.next();
        String value = metadata.get(name);

        if (name.equals("name") || name.equals("cpuModel") ||
                name.equals("hostname") || name.equals("ipaddr") ||
                name.equals("ip6addr") ||
                (name.equals("runningKernel"))) {
            store = Field.Store.YES;
        }
        else if (name.equals("checkin") || name.equals("registered") ||
                name.equals("ram") || name.equals("swap") ||
                name.equals("cpuMHz") | name.equals("cpuNumberOfCpus")) {
            store = Field.Store.YES;
            tokenize = Field.Index.UN_TOKENIZED;
        }

        doc.add(new Field(name, String.valueOf(value), store,
                tokenize));
    }
    return doc;
}
 
Example 13
Source File: ServerCustomInfoDocumentBuilder.java    From spacewalk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public Document buildDocument(Long objId, Map<String, String> metadata) {
    Document doc = new Document();
    doc.add(new Field("id", objId.toString(), Field.Store.YES,
            Field.Index.UN_TOKENIZED));

    for (Iterator<String> iter = metadata.keySet().iterator(); iter.hasNext();) {
        Field.Store store = Field.Store.YES;
        Field.Index tokenize = Field.Index.TOKENIZED;

        String name = iter.next();
        String value = metadata.get(name);

        if (name.equals("value")) {
            store = Field.Store.YES;
        }
        else if (name.equals("created") || (name.equals("modified"))) {
            store = Field.Store.YES;
            tokenize = Field.Index.UN_TOKENIZED;
        }
        else if (name.equals("serverId") || name.equals("createdBy") ||
                name.equals("lastModifiedBy")) {
            store = Field.Store.YES;
            tokenize = Field.Index.UN_TOKENIZED;
        }

        doc.add(new Field(name, String.valueOf(value), store,
                tokenize));
    }
    return doc;
}
 
Example 14
Source File: PackageDocumentBuilder.java    From spacewalk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public Document buildDocument(Long objId, Map<String, String> metadata) {
    Document doc = new Document();
    doc.add(new Field("id", objId.toString(), Field.Store.YES,
            Field.Index.UN_TOKENIZED));

    for (Iterator<String> iter = metadata.keySet().iterator(); iter
            .hasNext();) {
        Field.Store store = Field.Store.YES;
        Field.Index tokenize = Field.Index.TOKENIZED;

        String name = iter.next();
        String value = metadata.get(name);
        if (name.equals("name")) {
            store = Field.Store.YES;
        }
        else if (name.equals("arch") || name.equals("filename") ||
                name.equals("version") || name.equals("release") ||
                name.equals("epoch")) {
            tokenize = Field.Index.UN_TOKENIZED;
        }

        doc.add(new Field(name, String.valueOf(value), store,
                tokenize));
    }
    return doc;
}
 
Example 15
Source File: SnapshotTagDocumentBuilder.java    From spacewalk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public Document buildDocument(Long objId, Map<String, String> metadata) {
    Document doc = new Document();
    doc.add(new Field("id", objId.toString(), Field.Store.YES,
            Field.Index.UN_TOKENIZED));

    for (Iterator<String> iter = metadata.keySet().iterator(); iter.hasNext();) {
        Field.Store store = Field.Store.YES;
        Field.Index tokenize = Field.Index.TOKENIZED;

        String name = iter.next();
        String value = metadata.get(name);

        if (name.equals("name")) {
            store = Field.Store.YES;
        }
        else if (name.equals("created") || (name.equals("modified"))) {
            store = Field.Store.YES;
            tokenize = Field.Index.UN_TOKENIZED;
        }
        else if (name.equals("snapshotId") || name.equals("tagNameId") ||
                name.equals("serverId") || name.equals("orgId")) {
            store = Field.Store.YES;
            tokenize = Field.Index.UN_TOKENIZED;
        }

        doc.add(new Field(name, String.valueOf(value), store,
                tokenize));
    }
    return doc;
}
 
Example 16
Source File: OLuceneIndexManagerAbstract.java    From orientdb-lucene with Apache License 2.0 4 votes vote down vote up
protected Field.Store isToStore(String f) {
  return collectionFields.get(f) ? Field.Store.YES : Field.Store.NO;
}