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

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

Introduction

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

Prototype

public StoredField(String name, double value) 

Source Link

Document

Create a stored-only field with the given double value.

Usage

From source file:com.bluedragon.search.DocumentWrap.java

License:Open Source License

public void setSummary(String summary) {
    if (summary == null || summary.length() > 0)
        return;//from  w w  w .  j a  v a  2s.c o m

    int summaryLen = (summary.length() >= 256 ? 256 : summary.length());
    doc.add(new StoredField(SUMMARY, summary.substring(0, summaryLen)));
}

From source file:com.difference.historybook.index.lucene.IndexDocumentAdapter.java

License:Apache License

/**
 * @param timestamp the timestamp for when the page was fetched from the source
 * @return this for method chaining//from   w ww  .  j  ava2 s  .c o m
 */
public IndexDocumentAdapter setTimestamp(Instant timestamp) {
    doc.add(new NumericDocValuesField(FIELD_TIMESTAMP, timestamp.getEpochSecond()));
    doc.add(new StoredField(FIELD_TIMESTAMP_TEXT, timestamp.toString()));
    return this;
}

From source file:com.epam.catgenome.dao.index.FeatureIndexDao.java

License:Open Source License

private void addCommonDocumentFields(Document document, FeatureIndexEntry entry, final Long featureFileId) {
    document.add(new SortedStringField(FeatureIndexFields.FEATURE_ID.getFieldName(), entry.getFeatureId()));

    FieldType fieldType = new FieldType();
    fieldType.setOmitNorms(true);//from  w  w  w. ja  v a 2 s .c  o m
    fieldType.setIndexOptions(IndexOptions.DOCS);
    fieldType.setStored(true);
    fieldType.setTokenized(false);
    fieldType.setDocValuesType(DocValuesType.SORTED);
    fieldType.freeze();
    Field field = new Field(FeatureIndexFields.CHROMOSOME_ID.getFieldName(),
            entry.getChromosome() != null ? new BytesRef(entry.getChromosome().getId().toString())
                    : new BytesRef(""),
            fieldType);
    document.add(field);
    document.add(new SortedStringField(FeatureIndexFields.CHROMOSOME_NAME.getFieldName(),
            entry.getChromosome().getName(), true));

    document.add(new SortedIntPoint(FeatureIndexFields.START_INDEX.getFieldName(), entry.getStartIndex()));
    document.add(new StoredField(FeatureIndexFields.START_INDEX.getFieldName(), entry.getStartIndex()));
    document.add(new SortedDocValuesField(FeatureIndexFields.START_INDEX.getGroupName(),
            new BytesRef(entry.getStartIndex().toString())));

    document.add(new SortedIntPoint(FeatureIndexFields.END_INDEX.getFieldName(), entry.getEndIndex()));
    document.add(new StoredField(FeatureIndexFields.END_INDEX.getFieldName(), entry.getEndIndex()));
    document.add(new SortedDocValuesField(FeatureIndexFields.END_INDEX.getGroupName(),
            new BytesRef(entry.getStartIndex().toString())));

    document.add(new StringField(FeatureIndexFields.FEATURE_TYPE.getFieldName(),
            entry.getFeatureType() != null ? entry.getFeatureType().getFileValue() : "", Field.Store.YES));
    document.add(new StringField(FeatureIndexFields.FILE_ID.getFieldName(), featureFileId.toString(),
            Field.Store.YES));

    document.add(new StringField(FeatureIndexFields.FEATURE_NAME.getFieldName(),
            entry.getFeatureName() != null ? entry.getFeatureName().toLowerCase() : "", Field.Store.YES));
    document.add(new SortedDocValuesField(FeatureIndexFields.FEATURE_NAME.getFieldName(),
            new BytesRef(entry.getFeatureName() != null ? entry.getFeatureName() : "")));

    document.add(new SortedSetDocValuesFacetField(FeatureIndexFields.CHR_ID.getFieldName(),
            entry.getChromosome().getId().toString()));

    document.add(new SortedStringField(FeatureIndexFields.UID.getFieldName(), entry.getUuid().toString()));
    document.add(new SortedSetDocValuesFacetField(FeatureIndexFields.F_UID.getFieldName(),
            entry.getUuid().toString()));
}

From source file:com.epam.catgenome.dao.index.FeatureIndexDao.java

License:Open Source License

private void addVcfDocumentFields(Document document, FeatureIndexEntry entry) {
    VcfIndexEntry vcfIndexEntry = (VcfIndexEntry) entry;
    document.add(new SortedStringField(FeatureIndexFields.VARIATION_TYPE.getFieldName(),
            vcfIndexEntry.getVariationType().name()));

    if (StringUtils.isNotBlank(vcfIndexEntry.getFailedFilter())) {
        document.add(new SortedStringField(FeatureIndexFields.FAILED_FILTER.getFieldName(),
                vcfIndexEntry.getFailedFilter()));
    }/* w  ww . j  ava2  s .c  om*/

    document.add(new SortedFloatPoint(FeatureIndexFields.QUALITY.getFieldName(),
            vcfIndexEntry.getQuality().floatValue()));
    document.add(new StoredField(FeatureIndexFields.QUALITY.getFieldName(),
            vcfIndexEntry.getQuality().floatValue()));
    document.add(new SortedDocValuesField(FeatureIndexFields.QUALITY.getGroupName(),
            new BytesRef(vcfIndexEntry.getQuality().toString())));

    if (StringUtils.isNotBlank(vcfIndexEntry.getGene())) {
        document.add(new StringField(FeatureIndexFields.GENE_ID.getFieldName(),
                vcfIndexEntry.getGene().toLowerCase(), Field.Store.YES));
        document.add(new SortedStringField(FeatureIndexFields.GENE_IDS.getFieldName(),
                vcfIndexEntry.getGeneIds(), true));
    }

    if (StringUtils.isNotBlank(vcfIndexEntry.getGeneName())) {
        document.add(new StringField(FeatureIndexFields.GENE_NAME.getFieldName(),
                vcfIndexEntry.getGeneName().toLowerCase(), Field.Store.YES));
        document.add(new SortedStringField(FeatureIndexFields.GENE_NAMES.getFieldName(),
                vcfIndexEntry.getGeneNames(), true));
    }

    document.add(new SortedStringField(FeatureIndexFields.IS_EXON.getFieldName(),
            vcfIndexEntry.getExon().toString()));

    if (vcfIndexEntry.getInfo() != null) {
        addVcfDocumentInfoFields(document, vcfIndexEntry);
    }
}

From source file:com.epam.catgenome.dao.index.FeatureIndexDao.java

License:Open Source License

private void addVcfDocumentInfoFields(Document document, VcfIndexEntry vcfIndexEntry) {
    for (Map.Entry<String, Object> info : vcfIndexEntry.getInfo().entrySet()) {
        if (viewFieldPattern.matcher(info.getKey()).matches()) { //view fields are for view purposes
            continue;
        }/*from  w w w . j av  a 2  s  .  co  m*/

        String viewKey = "_" + info.getKey() + "_v";
        if (info.getValue() instanceof Integer) {
            document.add(new SortedIntPoint(info.getKey().toLowerCase(), (Integer) info.getValue()));
            if (vcfIndexEntry.getInfo().containsKey(viewKey)) {
                document.add(new StoredField(info.getKey().toLowerCase(),
                        vcfIndexEntry.getInfo().get(viewKey).toString()));
                document.add(
                        new SortedDocValuesField(FeatureIndexFields.getGroupName(info.getKey().toLowerCase()),
                                new BytesRef(vcfIndexEntry.getInfo().get(viewKey).toString())));
            } else {
                document.add(new StoredField(info.getKey().toLowerCase(), (Integer) info.getValue()));
                document.add(
                        new SortedDocValuesField(FeatureIndexFields.getGroupName(info.getKey().toLowerCase()),
                                new BytesRef(info.getValue().toString())));
            }
        } else if (info.getValue() instanceof Float) {
            document.add(new SortedFloatPoint(info.getKey().toLowerCase(), (Float) info.getValue()));

            if (vcfIndexEntry.getInfo().containsKey(viewKey)) {
                document.add(new StoredField(info.getKey().toLowerCase(),
                        vcfIndexEntry.getInfo().get(viewKey).toString()));
                document.add(
                        new SortedDocValuesField(FeatureIndexFields.getGroupName(info.getKey().toLowerCase()),
                                new BytesRef(vcfIndexEntry.getInfo().get(viewKey).toString())));
            } else {
                document.add(new StoredField(info.getKey().toLowerCase(), (Float) info.getValue()));
                document.add(
                        new SortedDocValuesField(FeatureIndexFields.getGroupName(info.getKey().toLowerCase()),
                                new BytesRef(info.getValue().toString())));
            }
        } else {
            if (vcfIndexEntry.getInfo().containsKey(viewKey)) {
                document.add(new SortedStringField(info.getKey().toLowerCase(),
                        vcfIndexEntry.getInfo().get(viewKey).toString()));
            } else {
                document.add(
                        new SortedStringField(info.getKey().toLowerCase(), info.getValue().toString().trim()));
            }
        }
    }
}

From source file:com.flycode.CRIBSearch.SearchEngine.IndexDB.java

public static void addTenantDoc(Tenant data) {
    try {/*from  w w w  .j  a v a2s .  c  o m*/
        Document doc = new Document();
        doc.add(new StoredField("id", data.getId()));
        doc.add(new TextField("firstName", data.getFirst(), null));
        doc.add(new TextField("secondName", data.getSecond(), null));
        doc.add(new TextField("surname", data.getSurname(), null));
        doc.add(new IntPoint("tell", data.getTell()));
        doc.add(new IntPoint("nationalID", data.getNational_ID()));
        doc.add(new TextField("bio", data.getBio(), null));

        new Build().create().indexDoc(doc);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.flycode.CRIBSearch.SearchEngine.IndexDB.java

public static void updateTenantDoc(Tenant data) {
    try {/*from  www  .jav a2 s.  c om*/
        Document doc = new Document();
        doc.add(new StoredField("id", data.getId()));
        doc.add(new TextField("firstName", data.getFirst(), null));
        doc.add(new TextField("secondName", data.getSecond(), null));
        doc.add(new TextField("surname", data.getSurname(), null));
        doc.add(new IntPoint("tell", data.getTell()));
        doc.add(new IntPoint("nationalID", data.getNational_ID()));
        doc.add(new TextField("bio", data.getBio(), null));
        new Build().create().updateDoc(doc, "id", String.valueOf(data.getId()));
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.flycode.CRIBSearch.SearchEngine.IndexDB.java

public static void addBuildingDoc(Building data) {
    try {/*from   w w  w .  j a  v a2 s  .c  om*/
        Document doc = new Document();
        doc.add(new StoredField("id", data.getId()));
        doc.add(new IntPoint("Registration ID", data.getRegistration_id()));
        doc.add(new TextField("Name", data.getName(), null));
        doc.add(new TextField("OwnerName", data.getOwner_Name(), null));
        doc.add(new StringField("License", data.getLicense(), null));
        doc.add(new TextField("Location", data.getLocation(), null));
        doc.add(new IntPoint("No of rooms", data.getNo_of_rooms()));

        new Build().create().indexDoc(doc);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.flycode.CRIBSearch.SearchEngine.IndexDB.java

public static void updateBuildingDoc(Building data) {
    try {/*from  w ww . ja v a 2s. c o  m*/
        Document doc = new Document();
        doc.add(new StoredField("id", data.getId()));
        doc.add(new IntPoint("Registration ID", data.getRegistration_id()));
        doc.add(new TextField("Name", data.getName(), null));
        doc.add(new TextField("OwnerName", data.getOwner_Name(), null));
        doc.add(new StringField("License", data.getLicense(), null));
        doc.add(new TextField("Location", data.getLocation(), null));
        doc.add(new IntPoint("No of rooms", data.getNo_of_rooms()));

        new Build().create().updateDoc(doc, "id", String.valueOf(data.getId()));
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.flycode.CRIBSearch.SearchEngine.IndexDB.java

public static void addOwnerDoc(Owner data) {
    try {/*w  w  w.  j a va2s. co  m*/
        Document doc = new Document();
        doc.add(new StoredField("id", data.getId()));
        doc.add(new TextField("firstName", data.getFirst(), null));
        doc.add(new TextField("secondName", data.getSecond(), null));
        doc.add(new TextField("surname", data.getSurname(), null));
        doc.add(new IntPoint("tell", data.getTell()));
        doc.add(new IntPoint("nationalID", data.getNational_id()));
        doc.add(new TextField("bio", data.getBio(), null));
        doc.add(new IntPoint("Owner Id", data.getOwner_id()));

        new Build().create().indexDoc(doc);
    } catch (Exception e) {
        e.printStackTrace();
    }
}