Search in sources :

Example 6 with IntField

use of org.apache.lucene.document.IntField in project entando-core by entando.

the class IndexerDAO method indexAttribute.

private void indexAttribute(Document document, AttributeInterface attribute, Lang lang) throws ApsSystemException {
    attribute.setRenderingLang(lang.getCode());
    if (attribute instanceof IndexableAttributeInterface) {
        String valueToIndex = ((IndexableAttributeInterface) attribute).getIndexeableFieldValue();
        String indexingType = attribute.getIndexingType();
        String fieldName = lang.getCode();
        if (attribute instanceof ResourceAttributeInterface) {
            fieldName += IIndexerDAO.ATTACHMENT_FIELD_SUFFIX;
        }
        if (null != indexingType && IndexableAttributeInterface.INDEXING_TYPE_UNSTORED.equalsIgnoreCase(indexingType)) {
            document.add(new TextField(fieldName, valueToIndex, Field.Store.NO));
        }
        if (null != indexingType && IndexableAttributeInterface.INDEXING_TYPE_TEXT.equalsIgnoreCase(indexingType)) {
            document.add(new TextField(fieldName, valueToIndex, Field.Store.YES));
        }
    }
    if (attribute.isSearchable()) {
        List<Lang> langs = new ArrayList<Lang>();
        langs.add(lang);
        AttributeTracer tracer = new AttributeTracer();
        tracer.setLang(lang);
        String name = tracer.getFormFieldName(attribute);
        List<AttributeSearchInfo> searchInfos = attribute.getSearchInfos(langs);
        if (null != searchInfos) {
            for (int i = 0; i < searchInfos.size(); i++) {
                AttributeSearchInfo info = searchInfos.get(i);
                Field field = null;
                if (null != info.getDate()) {
                    field = new TextField(name, DateTools.timeToString(info.getDate().getTime(), DateTools.Resolution.MINUTE), Field.Store.YES);
                } else if (null != info.getBigDecimal()) {
                    field = new IntField(name, info.getBigDecimal().intValue(), Field.Store.YES);
                } else {
                    field = new TextField(name, info.getString(), Field.Store.YES);
                }
                document.add(field);
            }
        }
    }
}
Also used : AttributeTracer(com.agiletec.aps.system.common.entity.model.AttributeTracer) ResourceAttributeInterface(com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.ResourceAttributeInterface) ArrayList(java.util.ArrayList) Lang(com.agiletec.aps.system.services.lang.Lang) IntField(org.apache.lucene.document.IntField) AttributeSearchInfo(com.agiletec.aps.system.common.entity.model.AttributeSearchInfo) StringField(org.apache.lucene.document.StringField) Field(org.apache.lucene.document.Field) TextField(org.apache.lucene.document.TextField) IntField(org.apache.lucene.document.IntField) TextField(org.apache.lucene.document.TextField) IndexableAttributeInterface(com.agiletec.aps.system.common.searchengine.IndexableAttributeInterface)

Example 7 with IntField

use of org.apache.lucene.document.IntField in project gitblit by gitblit.

the class TicketIndexer method toDocField.

private void toDocField(Document doc, Lucene lucene, int value) {
    doc.add(new IntField(lucene.name(), value, Store.YES));
    doc.add(new NumericDocValuesField(lucene.name(), value));
}
Also used : NumericDocValuesField(org.apache.lucene.document.NumericDocValuesField) IntField(org.apache.lucene.document.IntField)

Aggregations

IntField (org.apache.lucene.document.IntField)7 Document (org.apache.lucene.document.Document)4 Field (org.apache.lucene.document.Field)4 StringField (org.apache.lucene.document.StringField)4 TextField (org.apache.lucene.document.TextField)4 DoubleField (org.apache.lucene.document.DoubleField)3 LongField (org.apache.lucene.document.LongField)3 FloatField (org.apache.lucene.document.FloatField)2 NumericDocValuesField (org.apache.lucene.document.NumericDocValuesField)2 AttributeSearchInfo (com.agiletec.aps.system.common.entity.model.AttributeSearchInfo)1 AttributeTracer (com.agiletec.aps.system.common.entity.model.AttributeTracer)1 IndexableAttributeInterface (com.agiletec.aps.system.common.searchengine.IndexableAttributeInterface)1 Lang (com.agiletec.aps.system.services.lang.Lang)1 ResourceAttributeInterface (com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.ResourceAttributeInterface)1 MultiTermTokenStream (de.ids_mannheim.korap.index.MultiTermTokenStream)1 StringReader (java.io.StringReader)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 ParamConverterProvider (javax.ws.rs.ext.ParamConverterProvider)1 DoubleDocValuesField (org.apache.lucene.document.DoubleDocValuesField)1