Java 类org.apache.lucene.document.DateTools.Resolution 实例源码

项目:lams    文件:StandardQueryConfigHandler.java   
public StandardQueryConfigHandler() {
  // Add listener that will build the FieldConfig.
  addFieldConfigListener(new FieldBoostMapFCListener(this));
  addFieldConfigListener(new FieldDateResolutionFCListener(this));
  addFieldConfigListener(new NumericFieldConfigListener(this));

  // Default Values
  set(ConfigurationKeys.ALLOW_LEADING_WILDCARD, false); // default in 2.9
  set(ConfigurationKeys.ANALYZER, null); //default value 2.4
  set(ConfigurationKeys.DEFAULT_OPERATOR, Operator.OR);
  set(ConfigurationKeys.PHRASE_SLOP, 0); //default value 2.4
  set(ConfigurationKeys.LOWERCASE_EXPANDED_TERMS, true); //default value 2.4
  set(ConfigurationKeys.ENABLE_POSITION_INCREMENTS, false); //default value 2.4
  set(ConfigurationKeys.FIELD_BOOST_MAP, new LinkedHashMap<String, Float>());
  set(ConfigurationKeys.FUZZY_CONFIG, new FuzzyConfig());
  set(ConfigurationKeys.LOCALE, Locale.getDefault());
  set(ConfigurationKeys.MULTI_TERM_REWRITE_METHOD, MultiTermQuery.CONSTANT_SCORE_AUTO_REWRITE_DEFAULT);
  set(ConfigurationKeys.FIELD_DATE_RESOLUTION_MAP, new HashMap<CharSequence, DateTools.Resolution>());

}
项目:lams    文件:FieldDateResolutionFCListener.java   
@Override
public void buildFieldConfig(FieldConfig fieldConfig) {
  DateTools.Resolution dateRes = null;
  Map<CharSequence, DateTools.Resolution> dateResMap = this.config.get(ConfigurationKeys.FIELD_DATE_RESOLUTION_MAP);

  if (dateResMap != null) {
    dateRes = dateResMap.get(
        fieldConfig.getField());
  }

  if (dateRes == null) {
    dateRes = this.config.get(ConfigurationKeys.DATE_RESOLUTION);
  }

  if (dateRes != null) {
    fieldConfig.set(ConfigurationKeys.DATE_RESOLUTION, dateRes);
  }

}
项目:cassandra-fhir-index    文件:FhirIndexService.java   
/**
 * Returns the Lucene {@link Query} represented by the specified
 * {@link Search} and key filter.
 *
 * @param expression
 *            the expression
 * @param command
 *            the command
 * @return a Lucene {@link Query}
 */
private Query query(String expression, ReadCommand command) {
    try {
        QueryParser queryParser = new QueryParser("query", this.indexOptions.search.defaultAnalyzer);
        queryParser.setDateResolution(Resolution.SECOND);
        Query searchQuery = queryParser.parse(expression);

        return searchQuery;
    } catch (ParseException e) {
        // TODO Auto-generated catch block
        throw new FhirIndexException(e);
    }

    // TODO: mejorar las busquedas por tipo
    // Optional<Query> maybeKeyRangeQuery = query(command);
    // if (maybeKeyRangeQuery.isPresent()) {
    // BooleanQuery.Builder builder = new BooleanQuery.Builder();
    // builder.add(maybeKeyRangeQuery.get(), FILTER);
    // builder.add(searchQuery, MUST);
    // return builder.build();
    // } else {
    // }
}
项目:search    文件:StandardQueryConfigHandler.java   
public StandardQueryConfigHandler() {
  // Add listener that will build the FieldConfig.
  addFieldConfigListener(new FieldBoostMapFCListener(this));
  addFieldConfigListener(new FieldDateResolutionFCListener(this));
  addFieldConfigListener(new NumericFieldConfigListener(this));

  // Default Values
  set(ConfigurationKeys.ALLOW_LEADING_WILDCARD, false); // default in 2.9
  set(ConfigurationKeys.ANALYZER, null); //default value 2.4
  set(ConfigurationKeys.DEFAULT_OPERATOR, Operator.OR);
  set(ConfigurationKeys.PHRASE_SLOP, 0); //default value 2.4
  set(ConfigurationKeys.LOWERCASE_EXPANDED_TERMS, true); //default value 2.4
  set(ConfigurationKeys.ENABLE_POSITION_INCREMENTS, false); //default value 2.4
  set(ConfigurationKeys.FIELD_BOOST_MAP, new LinkedHashMap<String, Float>());
  set(ConfigurationKeys.FUZZY_CONFIG, new FuzzyConfig());
  set(ConfigurationKeys.LOCALE, Locale.getDefault());
  set(ConfigurationKeys.MULTI_TERM_REWRITE_METHOD, MultiTermQuery.CONSTANT_SCORE_AUTO_REWRITE_DEFAULT);
  set(ConfigurationKeys.FIELD_DATE_RESOLUTION_MAP, new HashMap<CharSequence, DateTools.Resolution>());

}
项目:search    文件:FieldDateResolutionFCListener.java   
@Override
public void buildFieldConfig(FieldConfig fieldConfig) {
  DateTools.Resolution dateRes = null;
  Map<CharSequence, DateTools.Resolution> dateResMap = this.config.get(ConfigurationKeys.FIELD_DATE_RESOLUTION_MAP);

  if (dateResMap != null) {
    dateRes = dateResMap.get(
        fieldConfig.getField());
  }

  if (dateRes == null) {
    dateRes = this.config.get(ConfigurationKeys.DATE_RESOLUTION);
  }

  if (dateRes != null) {
    fieldConfig.set(ConfigurationKeys.DATE_RESOLUTION, dateRes);
  }

}
项目:Genji    文件:LuceneSearcher.java   
/**
 * Transforms the user entered date string to lucene date string format
 * by trying to reconstruct the Date object either by local or by ISO (yyy-MM-dd)
 * DateTools calculates in GMT (comparing to the server TimeZone), so it should be adjusted  
 * @param originalFieldValue
 * @param locale
 * @return
 */
private static String transformDateFields(String originalFieldValue, Locale locale) {
    String dateString = originalFieldValue;
    Date date;
    //DateTimeUtils dtu = new DateTimeUtils(locale);
    date = DateTimeUtils.getInstance().parseGUIDate(originalFieldValue, locale);
    if (date==null) {
        date = DateTimeUtils.getInstance().parseShortDate(originalFieldValue, locale);
    }
    //set the date according to offset from the GMT
    //see http://www.gossamer-threads.com/lists/lucene/java-user/39303?search_string=DateTools;#39303
    Calendar cal = new GregorianCalendar();
    int minutesOffset = (cal.get(Calendar.ZONE_OFFSET) + cal.get(Calendar.DST_OFFSET)) / (60 * 1000);
    if (date!=null) {
        cal.setTime(date);
        cal.add(Calendar.MINUTE, minutesOffset); 
        return DateTools.dateToString(cal.getTime(), Resolution.DAY);
    }
    date = DateTimeUtils.getInstance().parseISODate(originalFieldValue);
    if (date!=null) {
        cal.setTime(date);
        cal.add(Calendar.MINUTE, minutesOffset);
        return DateTools.dateToString(cal.getTime(), Resolution.DAY);
    }
    return dateString;
}
项目:NYBC    文件:StandardQueryConfigHandler.java   
public StandardQueryConfigHandler() {
  // Add listener that will build the FieldConfig.
  addFieldConfigListener(new FieldBoostMapFCListener(this));
  addFieldConfigListener(new FieldDateResolutionFCListener(this));
  addFieldConfigListener(new NumericFieldConfigListener(this));

  // Default Values
  set(ConfigurationKeys.ALLOW_LEADING_WILDCARD, false); // default in 2.9
  set(ConfigurationKeys.ANALYZER, null); //default value 2.4
  set(ConfigurationKeys.DEFAULT_OPERATOR, Operator.OR);
  set(ConfigurationKeys.PHRASE_SLOP, 0); //default value 2.4
  set(ConfigurationKeys.LOWERCASE_EXPANDED_TERMS, true); //default value 2.4
  set(ConfigurationKeys.ENABLE_POSITION_INCREMENTS, false); //default value 2.4
  set(ConfigurationKeys.FIELD_BOOST_MAP, new LinkedHashMap<String, Float>());
  set(ConfigurationKeys.FUZZY_CONFIG, new FuzzyConfig());
  set(ConfigurationKeys.LOCALE, Locale.getDefault());
  set(ConfigurationKeys.MULTI_TERM_REWRITE_METHOD, MultiTermQuery.CONSTANT_SCORE_AUTO_REWRITE_DEFAULT);
  set(ConfigurationKeys.FIELD_DATE_RESOLUTION_MAP, new HashMap<CharSequence, DateTools.Resolution>());

}
项目:NYBC    文件:FieldDateResolutionFCListener.java   
@Override
public void buildFieldConfig(FieldConfig fieldConfig) {
  DateTools.Resolution dateRes = null;
  Map<CharSequence, DateTools.Resolution> dateResMap = this.config.get(ConfigurationKeys.FIELD_DATE_RESOLUTION_MAP);

  if (dateResMap != null) {
    dateRes = dateResMap.get(
        fieldConfig.getField());
  }

  if (dateRes == null) {
    dateRes = this.config.get(ConfigurationKeys.DATE_RESOLUTION);
  }

  if (dateRes != null) {
    fieldConfig.set(ConfigurationKeys.DATE_RESOLUTION, dateRes);
  }

}
项目:read-open-source-code    文件:StandardQueryConfigHandler.java   
public StandardQueryConfigHandler() {
  // Add listener that will build the FieldConfig.
  addFieldConfigListener(new FieldBoostMapFCListener(this));
  addFieldConfigListener(new FieldDateResolutionFCListener(this));
  addFieldConfigListener(new NumericFieldConfigListener(this));

  // Default Values
  set(ConfigurationKeys.ALLOW_LEADING_WILDCARD, false); // default in 2.9
  set(ConfigurationKeys.ANALYZER, null); //default value 2.4
  set(ConfigurationKeys.DEFAULT_OPERATOR, Operator.OR);
  set(ConfigurationKeys.PHRASE_SLOP, 0); //default value 2.4
  set(ConfigurationKeys.LOWERCASE_EXPANDED_TERMS, true); //default value 2.4
  set(ConfigurationKeys.ENABLE_POSITION_INCREMENTS, false); //default value 2.4
  set(ConfigurationKeys.FIELD_BOOST_MAP, new LinkedHashMap<String, Float>());
  set(ConfigurationKeys.FUZZY_CONFIG, new FuzzyConfig());
  set(ConfigurationKeys.LOCALE, Locale.getDefault());
  set(ConfigurationKeys.MULTI_TERM_REWRITE_METHOD, MultiTermQuery.CONSTANT_SCORE_AUTO_REWRITE_DEFAULT);
  set(ConfigurationKeys.FIELD_DATE_RESOLUTION_MAP, new HashMap<CharSequence, DateTools.Resolution>());

}
项目:read-open-source-code    文件:FieldDateResolutionFCListener.java   
@Override
public void buildFieldConfig(FieldConfig fieldConfig) {
  DateTools.Resolution dateRes = null;
  Map<CharSequence, DateTools.Resolution> dateResMap = this.config.get(ConfigurationKeys.FIELD_DATE_RESOLUTION_MAP);

  if (dateResMap != null) {
    dateRes = dateResMap.get(
        fieldConfig.getField());
  }

  if (dateRes == null) {
    dateRes = this.config.get(ConfigurationKeys.DATE_RESOLUTION);
  }

  if (dateRes != null) {
    fieldConfig.set(ConfigurationKeys.DATE_RESOLUTION, dateRes);
  }

}
项目:read-open-source-code    文件:StandardQueryConfigHandler.java   
public StandardQueryConfigHandler() {
  // Add listener that will build the FieldConfig.
  addFieldConfigListener(new FieldBoostMapFCListener(this));
  addFieldConfigListener(new FieldDateResolutionFCListener(this));
  addFieldConfigListener(new NumericFieldConfigListener(this));

  // Default Values
  set(ConfigurationKeys.ALLOW_LEADING_WILDCARD, false); // default in 2.9
  set(ConfigurationKeys.ANALYZER, null); //default value 2.4
  set(ConfigurationKeys.DEFAULT_OPERATOR, Operator.OR);
  set(ConfigurationKeys.PHRASE_SLOP, 0); //default value 2.4
  set(ConfigurationKeys.LOWERCASE_EXPANDED_TERMS, true); //default value 2.4
  set(ConfigurationKeys.ENABLE_POSITION_INCREMENTS, false); //default value 2.4
  set(ConfigurationKeys.FIELD_BOOST_MAP, new LinkedHashMap<String, Float>());
  set(ConfigurationKeys.FUZZY_CONFIG, new FuzzyConfig());
  set(ConfigurationKeys.LOCALE, Locale.getDefault());
  set(ConfigurationKeys.MULTI_TERM_REWRITE_METHOD, MultiTermQuery.CONSTANT_SCORE_AUTO_REWRITE_DEFAULT);
  set(ConfigurationKeys.FIELD_DATE_RESOLUTION_MAP, new HashMap<CharSequence, DateTools.Resolution>());

}
项目:read-open-source-code    文件:FieldDateResolutionFCListener.java   
@Override
public void buildFieldConfig(FieldConfig fieldConfig) {
  DateTools.Resolution dateRes = null;
  Map<CharSequence, DateTools.Resolution> dateResMap = this.config.get(ConfigurationKeys.FIELD_DATE_RESOLUTION_MAP);

  if (dateResMap != null) {
    dateRes = dateResMap.get(
        fieldConfig.getField());
  }

  if (dateRes == null) {
    dateRes = this.config.get(ConfigurationKeys.DATE_RESOLUTION);
  }

  if (dateRes != null) {
    fieldConfig.set(ConfigurationKeys.DATE_RESOLUTION, dateRes);
  }

}
项目:read-open-source-code    文件:StandardQueryConfigHandler.java   
public StandardQueryConfigHandler() {
  // Add listener that will build the FieldConfig.
  addFieldConfigListener(new FieldBoostMapFCListener(this));
  addFieldConfigListener(new FieldDateResolutionFCListener(this));
  addFieldConfigListener(new NumericFieldConfigListener(this));

  // Default Values
  set(ConfigurationKeys.ALLOW_LEADING_WILDCARD, false); // default in 2.9
  set(ConfigurationKeys.ANALYZER, null); //default value 2.4
  set(ConfigurationKeys.DEFAULT_OPERATOR, Operator.OR);
  set(ConfigurationKeys.PHRASE_SLOP, 0); //default value 2.4
  set(ConfigurationKeys.LOWERCASE_EXPANDED_TERMS, true); //default value 2.4
  set(ConfigurationKeys.ENABLE_POSITION_INCREMENTS, false); //default value 2.4
  set(ConfigurationKeys.FIELD_BOOST_MAP, new LinkedHashMap<String, Float>());
  set(ConfigurationKeys.FUZZY_CONFIG, new FuzzyConfig());
  set(ConfigurationKeys.LOCALE, Locale.getDefault());
  set(ConfigurationKeys.MULTI_TERM_REWRITE_METHOD, MultiTermQuery.CONSTANT_SCORE_AUTO_REWRITE_DEFAULT);
  set(ConfigurationKeys.FIELD_DATE_RESOLUTION_MAP, new HashMap<CharSequence, DateTools.Resolution>());

}
项目:read-open-source-code    文件:FieldDateResolutionFCListener.java   
@Override
public void buildFieldConfig(FieldConfig fieldConfig) {
  DateTools.Resolution dateRes = null;
  Map<CharSequence, DateTools.Resolution> dateResMap = this.config.get(ConfigurationKeys.FIELD_DATE_RESOLUTION_MAP);

  if (dateResMap != null) {
    dateRes = dateResMap.get(
        fieldConfig.getField());
  }

  if (dateRes == null) {
    dateRes = this.config.get(ConfigurationKeys.DATE_RESOLUTION);
  }

  if (dateRes != null) {
    fieldConfig.set(ConfigurationKeys.DATE_RESOLUTION, dateRes);
  }

}
项目:cananolab    文件:IndexBuilder.java   
public void indexProtocolSearchableFieldsBean(ProtocolSearchableFieldsBean protocolFieldsBean) throws IOException {

        IndexWriter writer = getIndexWriter(false);
        Document doc = new Document();
        doc.add(new StringField("protocolId", protocolFieldsBean.getProtocolId(), Field.Store.YES));
        if(protocolFieldsBean.getProtocolFileDesc()!=null)
            doc.add(new StringField("protocolFileDesc", protocolFieldsBean.getProtocolFileDesc(), Field.Store.YES));
        if(protocolFieldsBean.getProtocolFileId()!=null)
            doc.add(new StringField("protocolFileId", protocolFieldsBean.getProtocolFileId(), Field.Store.YES));
        doc.add(new StringField("protocolName", protocolFieldsBean.getProtocolName(), Field.Store.YES));
        if(protocolFieldsBean.getProtocolFileName()!=null)
            doc.add(new StringField("protocolFileName", protocolFieldsBean.getProtocolFileName(), Field.Store.YES));
        if(protocolFieldsBean.getCreatedDate()!=null){
            try{
                doc.add(new Field("createdDate", DateTools.stringToDate(DateTools.dateToString(protocolFieldsBean.getCreatedDate(),Resolution.SECOND)).toString(), Field.Store.YES, Field.Index.NOT_ANALYZED));
            }catch(ParseException e){
                e.printStackTrace();
            }
        }
        String fullSearchableText = protocolFieldsBean.getProtocolName() + " " + protocolFieldsBean.getProtocolFileName();

        doc.add(new TextField("content", fullSearchableText, Field.Store.NO));
        writer.addDocument(doc);

    }
项目:gitblit    文件:LuceneExecutor.java   
/**
 * Creates a Lucene document from an issue.
 * 
 * @param issue
 * @return a Lucene document
 */
private Document createDocument(IssueModel issue) {
    Document doc = new Document();
    doc.add(new Field(FIELD_OBJECT_TYPE, SearchObjectType.issue.name(), Store.YES,
            Field.Index.NOT_ANALYZED));
    doc.add(new Field(FIELD_ISSUE, issue.id, Store.YES, Index.ANALYZED));
    doc.add(new Field(FIELD_BRANCH, IssueUtils.GB_ISSUES, Store.YES, Index.ANALYZED));
    doc.add(new Field(FIELD_DATE, DateTools.dateToString(issue.created, Resolution.MINUTE),
            Store.YES, Field.Index.NO));
    doc.add(new Field(FIELD_AUTHOR, issue.reporter, Store.YES, Index.ANALYZED));
    List<String> attachments = new ArrayList<String>();
    for (Attachment attachment : issue.getAttachments()) {
        attachments.add(attachment.name.toLowerCase());
    }
    doc.add(new Field(FIELD_ATTACHMENT, StringUtils.flattenStrings(attachments), Store.YES,
            Index.ANALYZED));
    doc.add(new Field(FIELD_SUMMARY, issue.summary, Store.YES, Index.ANALYZED));
    doc.add(new Field(FIELD_CONTENT, issue.toString(), Store.YES, Index.ANALYZED));
    doc.add(new Field(FIELD_LABEL, StringUtils.flattenStrings(issue.getLabels()), Store.YES,
            Index.ANALYZED));
    return doc;
}
项目:gitblit    文件:LuceneExecutor.java   
/**
 * Creates a Lucene document for a commit
 * 
 * @param commit
 * @param tags
 * @return a Lucene document
 */
private Document createDocument(RevCommit commit, List<String> tags) {
    Document doc = new Document();
    doc.add(new Field(FIELD_OBJECT_TYPE, SearchObjectType.commit.name(), Store.YES,
            Index.NOT_ANALYZED));
    doc.add(new Field(FIELD_COMMIT, commit.getName(), Store.YES, Index.ANALYZED));
    doc.add(new Field(FIELD_DATE, DateTools.timeToString(commit.getCommitTime() * 1000L,
            Resolution.MINUTE), Store.YES, Index.NO));
    doc.add(new Field(FIELD_AUTHOR, getAuthor(commit), Store.YES, Index.ANALYZED));
    doc.add(new Field(FIELD_COMMITTER, getCommitter(commit), Store.YES, Index.ANALYZED));
    doc.add(new Field(FIELD_SUMMARY, commit.getShortMessage(), Store.YES, Index.ANALYZED));
    doc.add(new Field(FIELD_CONTENT, commit.getFullMessage(), Store.YES, Index.ANALYZED));
    if (!ArrayUtils.isEmpty(tags)) {
        doc.add(new Field(FIELD_TAG, StringUtils.flattenStrings(tags), Store.YES, Index.ANALYZED));
    }
    return doc;
}
项目:Maskana-Gestor-de-Conocimiento    文件:StandardQueryConfigHandler.java   
public StandardQueryConfigHandler() {
  // Add listener that will build the FieldConfig.
  addFieldConfigListener(new FieldBoostMapFCListener(this));
  addFieldConfigListener(new FieldDateResolutionFCListener(this));
  addFieldConfigListener(new NumericFieldConfigListener(this));

  // Default Values
  set(ConfigurationKeys.ALLOW_LEADING_WILDCARD, false); // default in 2.9
  set(ConfigurationKeys.ANALYZER, null); //default value 2.4
  set(ConfigurationKeys.DEFAULT_OPERATOR, Operator.OR);
  set(ConfigurationKeys.PHRASE_SLOP, 0); //default value 2.4
  set(ConfigurationKeys.LOWERCASE_EXPANDED_TERMS, true); //default value 2.4
  set(ConfigurationKeys.ENABLE_POSITION_INCREMENTS, false); //default value 2.4
  set(ConfigurationKeys.FIELD_BOOST_MAP, new LinkedHashMap<String, Float>());
  set(ConfigurationKeys.FUZZY_CONFIG, new FuzzyConfig());
  set(ConfigurationKeys.LOCALE, Locale.getDefault());
  set(ConfigurationKeys.MULTI_TERM_REWRITE_METHOD, MultiTermQuery.CONSTANT_SCORE_AUTO_REWRITE_DEFAULT);
  set(ConfigurationKeys.FIELD_DATE_RESOLUTION_MAP, new HashMap<CharSequence, DateTools.Resolution>());

}
项目:Maskana-Gestor-de-Conocimiento    文件:FieldDateResolutionFCListener.java   
@Override
public void buildFieldConfig(FieldConfig fieldConfig) {
  DateTools.Resolution dateRes = null;
  Map<CharSequence, DateTools.Resolution> dateResMap = this.config.get(ConfigurationKeys.FIELD_DATE_RESOLUTION_MAP);

  if (dateResMap != null) {
    dateRes = dateResMap.get(
        fieldConfig.getField());
  }

  if (dateRes == null) {
    dateRes = this.config.get(ConfigurationKeys.DATE_RESOLUTION);
  }

  if (dateRes != null) {
    fieldConfig.set(ConfigurationKeys.DATE_RESOLUTION, dateRes);
  }

}
项目:IRCBlit    文件:LuceneExecutor.java   
/**
 * Creates a Lucene document from an issue.
 * 
 * @param issue
 * @return a Lucene document
 */
private Document createDocument(IssueModel issue) {
    Document doc = new Document();
    doc.add(new Field(FIELD_OBJECT_TYPE, SearchObjectType.issue.name(), Store.YES,
            Field.Index.NOT_ANALYZED));
    doc.add(new Field(FIELD_ISSUE, issue.id, Store.YES, Index.ANALYZED));
    doc.add(new Field(FIELD_BRANCH, IssueUtils.GB_ISSUES, Store.YES, Index.ANALYZED));
    doc.add(new Field(FIELD_DATE, DateTools.dateToString(issue.created, Resolution.MINUTE),
            Store.YES, Field.Index.NO));
    doc.add(new Field(FIELD_AUTHOR, issue.reporter, Store.YES, Index.ANALYZED));
    List<String> attachments = new ArrayList<String>();
    for (Attachment attachment : issue.getAttachments()) {
        attachments.add(attachment.name.toLowerCase());
    }
    doc.add(new Field(FIELD_ATTACHMENT, StringUtils.flattenStrings(attachments), Store.YES,
            Index.ANALYZED));
    doc.add(new Field(FIELD_SUMMARY, issue.summary, Store.YES, Index.ANALYZED));
    doc.add(new Field(FIELD_CONTENT, issue.toString(), Store.YES, Index.ANALYZED));
    doc.add(new Field(FIELD_LABEL, StringUtils.flattenStrings(issue.getLabels()), Store.YES,
            Index.ANALYZED));
    return doc;
}
项目:IRCBlit    文件:LuceneExecutor.java   
/**
 * Creates a Lucene document for a commit
 * 
 * @param commit
 * @param tags
 * @return a Lucene document
 */
private Document createDocument(RevCommit commit, List<String> tags) {
    Document doc = new Document();
    doc.add(new Field(FIELD_OBJECT_TYPE, SearchObjectType.commit.name(), Store.YES,
            Index.NOT_ANALYZED));
    doc.add(new Field(FIELD_COMMIT, commit.getName(), Store.YES, Index.ANALYZED));
    doc.add(new Field(FIELD_DATE, DateTools.timeToString(commit.getCommitTime() * 1000L,
            Resolution.MINUTE), Store.YES, Index.NO));
    doc.add(new Field(FIELD_AUTHOR, getAuthor(commit), Store.YES, Index.ANALYZED));
    doc.add(new Field(FIELD_COMMITTER, getCommitter(commit), Store.YES, Index.ANALYZED));
    doc.add(new Field(FIELD_SUMMARY, commit.getShortMessage(), Store.YES, Index.ANALYZED));
    doc.add(new Field(FIELD_CONTENT, commit.getFullMessage(), Store.YES, Index.ANALYZED));
    if (!ArrayUtils.isEmpty(tags)) {
        doc.add(new Field(FIELD_TAG, StringUtils.flattenStrings(tags), Store.YES, Index.ANALYZED));
    }
    return doc;
}
项目:jeecms6    文件:LuceneContent.java   
/**
 * 获得Lucene格式的Document
 * 
 * @param c
 *            文章对象
 * @return
 */
public static Document createDocument(Content c) {
    Document doc = new Document();
    doc.add(new Field(ID, c.getId().toString(), Field.Store.YES,
            Field.Index.NOT_ANALYZED));
    doc.add(new Field(SITE_ID, c.getSite().getId().toString(),
            Field.Store.NO, Field.Index.NOT_ANALYZED));
    doc.add(new Field(RELEASE_DATE, DateTools.dateToString(c
            .getReleaseDate(), Resolution.DAY), Field.Store.NO,
            Field.Index.NOT_ANALYZED));
    Channel channel = c.getChannel();
    while (channel != null) {
        doc.add(new Field(CHANNEL_ID_ARRAY, channel.getId().toString(),
                Field.Store.NO, Field.Index.NOT_ANALYZED));
        channel = channel.getParent();
    }
    doc.add(new Field(TITLE, c.getTitle(), Field.Store.NO,
            Field.Index.ANALYZED));
    if (!StringUtils.isBlank(c.getTxt())) {
        doc.add(new Field(CONTENT, c.getTxt(), Field.Store.NO,
                Field.Index.ANALYZED));
    }
    if(c.getAttr()!=null&&StringUtils.isNotBlank(c.getAttr().get("workplace"))){
        doc.add(new Field(WORKPLACE, c.getAttr().get("workplace"), Field.Store.NO,
                Field.Index.ANALYZED));
    }
    if(c.getAttr()!=null&&StringUtils.isNotBlank(c.getAttr().get("category"))){
        doc.add(new Field(CATEGORY, c.getAttr().get("category"), Field.Store.NO,
                Field.Index.ANALYZED));
    }
    return doc;
}
项目:search    文件:TestStandardQP.java   
@Override
public void setDateResolution(CommonQueryParserConfiguration cqpC,
    CharSequence field, Resolution value) {
  assert (cqpC instanceof StandardQueryParser);
  StandardQueryParser qp = (StandardQueryParser) cqpC;
  qp.getDateResolutionMap().put(field, value);
}
项目:search    文件:TestQueryParser.java   
@Override
public void setDateResolution(CommonQueryParserConfiguration cqpC,
    CharSequence field, Resolution value) {
  assert (cqpC instanceof QueryParser);
  QueryParser qp = (QueryParser) cqpC;
  qp.setDateResolution(field.toString(), value);
}
项目:NYBC    文件:TestStandardQP.java   
@Override
public void setDateResolution(CommonQueryParserConfiguration cqpC,
    CharSequence field, Resolution value) {
  assert (cqpC instanceof StandardQueryParser);
  StandardQueryParser qp = (StandardQueryParser) cqpC;
  qp.getDateResolutionMap().put(field, value);
}
项目:NYBC    文件:TestQueryParser.java   
@Override
public void setDateResolution(CommonQueryParserConfiguration cqpC,
    CharSequence field, Resolution value) {
  assert (cqpC instanceof QueryParser);
  QueryParser qp = (QueryParser) cqpC;
  qp.setDateResolution(field.toString(), value);
}
项目:gerrit-gitblit-plugin    文件:LuceneService.java   
/**
 * Creates a Lucene document for a commit
 * 
 * @param commit
 * @param tags
 * @return a Lucene document
 */
private Document createDocument(RevCommit commit, List<String> tags) {
    Document doc = new Document();
    doc.add(new Field(FIELD_OBJECT_TYPE, SearchObjectType.commit.name(), StringField.TYPE_STORED));
    doc.add(new Field(FIELD_COMMIT, commit.getName(), TextField.TYPE_STORED));
    doc.add(new Field(FIELD_DATE, DateTools.timeToString(commit.getCommitTime() * 1000L, Resolution.MINUTE), StringField.TYPE_STORED));
    doc.add(new Field(FIELD_AUTHOR, getAuthor(commit), TextField.TYPE_STORED));
    doc.add(new Field(FIELD_COMMITTER, getCommitter(commit), TextField.TYPE_STORED));
    doc.add(new Field(FIELD_SUMMARY, commit.getShortMessage(), TextField.TYPE_STORED));
    doc.add(new Field(FIELD_CONTENT, commit.getFullMessage(), TextField.TYPE_STORED));
    if (!ArrayUtils.isEmpty(tags)) {
        doc.add(new Field(FIELD_TAG, StringUtils.flattenStrings(tags), TextField.TYPE_STORED));
    }
    return doc;
}
项目:lucene-addons    文件:TestQueryParser.java   
@Override
public void setDateResolution(CommonQueryParserConfiguration cqpC,
                              CharSequence field, Resolution value) {
  assert (cqpC instanceof QueryParser);
  QueryParser qp = (QueryParser) cqpC;
  qp.setDateResolution(field.toString(), value);
}
项目:cananolab    文件:IndexBuilder.java   
public void indexSampleSearchableFieldsBean(SampleSearchableFieldsBean sampleFieldsBean) throws IOException {

        IndexWriter writer = getIndexWriter(false);
        Document doc = new Document();
        doc.add(new StringField("sampleId", sampleFieldsBean.getSampleId(), Field.Store.YES));
        doc.add(new StringField("sampleName", sampleFieldsBean.getSampleName(), Field.Store.YES));
        if(sampleFieldsBean.getSamplePocName()!=null)
            doc.add(new StringField("samplePocName", sampleFieldsBean.getSamplePocName(), Field.Store.YES));
        if(sampleFieldsBean.getNanoEntityName()!=null)
            doc.add(new StringField("nanoEntityName", sampleFieldsBean.getNanoEntityName(), Field.Store.YES));
        if(sampleFieldsBean.getNanoEntityDesc()!=null)
            doc.add(new StringField("nanoEntityDesc", sampleFieldsBean.getNanoEntityDesc(), Field.Store.YES));
        if(sampleFieldsBean.getFuncEntityName()!=null)
            doc.add(new StringField("funcEntityName", sampleFieldsBean.getFuncEntityName(), Field.Store.YES));
        if(sampleFieldsBean.getFunction()!=null)
            doc.add(new StringField("function", sampleFieldsBean.getFunction(), Field.Store.YES));
        if(sampleFieldsBean.getCharacterization()!=null)
            doc.add(new StringField("characterization", sampleFieldsBean.getCharacterization(), Field.Store.YES));
        if(sampleFieldsBean.getCreatedDate()!=null)
            try{
                doc.add(new Field("createdDate", DateTools.stringToDate(DateTools.dateToString(sampleFieldsBean.getCreatedDate(),Resolution.SECOND)).toString(), Field.Store.YES, Field.Index.NOT_ANALYZED));
            }catch(ParseException e){
                e.printStackTrace();
            }
        if(sampleFieldsBean.getSampleKeywords().size()>0)
            for(int i = 0; i < sampleFieldsBean.getSampleKeywords().size();i++){
                doc.add(new StringField("sampleKeywords", sampleFieldsBean.getSampleKeywords().get(i), Field.Store.YES));
            }
        String fullSearchableText = sampleFieldsBean.getSampleName() + " " + sampleFieldsBean.getSamplePocName() + " " + sampleFieldsBean.getNanoEntityName() + " " + sampleFieldsBean.getNanoEntityDesc() + " " + sampleFieldsBean.getFuncEntityName() + " " + sampleFieldsBean.getFunction() + " " + sampleFieldsBean.getCharacterization();
        String keywords = "";
        for( int i = 0; i < sampleFieldsBean.getSampleKeywords().size(); i++){
            String keyword = sampleFieldsBean.getSampleKeywords().get(i);
            keywords = keywords + " " + keyword;
        }
        fullSearchableText = fullSearchableText + " " + keywords;
        doc.add(new TextField("content", fullSearchableText, Field.Store.NO));
        writer.addDocument(doc);

    }
项目:Lottery    文件:LuceneContent.java   
/**
 * 获得Lucene格式的Document
 * 
 * @param c
 *            文章对象
 * @return
 */
public static Document createDocument(Content c) {
    Document doc = new Document();
    doc.add(new Field(ID, c.getId().toString(), Field.Store.YES,
            Field.Index.NOT_ANALYZED));
    doc.add(new Field(SITE_ID, c.getSite().getId().toString(),
            Field.Store.NO, Field.Index.NOT_ANALYZED));
    doc.add(new Field(RELEASE_DATE, DateTools.dateToString(c
            .getReleaseDate(), Resolution.DAY), Field.Store.NO,
            Field.Index.NOT_ANALYZED));
    Channel channel = c.getChannel();
    while (channel != null) {
        doc.add(new Field(CHANNEL_ID_ARRAY, channel.getId().toString(),
                Field.Store.NO, Field.Index.NOT_ANALYZED));
        channel = channel.getParent();
    }
    doc.add(new Field(TITLE, c.getTitle(), Field.Store.NO,
            Field.Index.ANALYZED));
    if (!StringUtils.isBlank(c.getTxt())) {
        doc.add(new Field(CONTENT, c.getTxt(), Field.Store.NO,
                Field.Index.ANALYZED));
    }
    if(c.getAttr()!=null&&StringUtils.isNotBlank(c.getAttr().get("workplace"))){
        doc.add(new Field(WORKPLACE, c.getAttr().get("workplace"), Field.Store.NO,
                Field.Index.ANALYZED));
    }
    if(c.getAttr()!=null&&StringUtils.isNotBlank(c.getAttr().get("category"))){
        doc.add(new Field(CATEGORY, c.getAttr().get("category"), Field.Store.NO,
                Field.Index.ANALYZED));
    }
    return doc;
}
项目:VillageElder    文件:Search.java   
/**
 * Initializes a new instance of Search with a query,
 * a set of facets (in {@link String} form with integer counts), an
 * analyzer and a custom sort.
 * @param qquery The query to be executed during the search.
 * @param ffacets The facets for which to search.
 * @param aanalyzer The analyzer with which to parse the
 * query.
 * @param ssort The custom sort order.
 * @throws ParseException A fatal exception occurred while
 * parsing the String query.
 */
public Search(
      final String qquery,
      final Map<String, Integer> ffacets,
      final Analyzer aanalyzer,
      final Sort ssort)
            throws ParseException {
   QueryParser parser =
         new SearchQueryParser(
               Lucene.LUCENE_VERSION,
               Lucene.DEFAULT_QUERY_FIELD,
               aanalyzer
          );
   parser.setDateResolution(Resolution.HOUR);
   query = parser.parse(qquery);

   if (ffacets == null) {
      facets = null;
   } else {
      facets = new ArrayList<FacetRequest>(ffacets.size());

      for (Entry<String, Integer> facet : ffacets.entrySet()) {
         final CategoryPath facetPath =
               new CategoryPath(facet.getKey(), '/');
         final CountFacetRequest facetRequest =
               new CountFacetRequest(facetPath, facet.getValue());
         facets.add(facetRequest);
      }
   }

   sort = ssort;
}
项目:Maskana-Gestor-de-Conocimiento    文件:TestStandardQP.java   
@Override
public void setDateResolution(CommonQueryParserConfiguration cqpC,
    CharSequence field, Resolution value) {
  assert (cqpC instanceof StandardQueryParser);
  StandardQueryParser qp = (StandardQueryParser) cqpC;
  qp.getDateResolutionMap().put(field, value);
}
项目:Maskana-Gestor-de-Conocimiento    文件:TestQueryParser.java   
@Override
public void setDateResolution(CommonQueryParserConfiguration cqpC,
    CharSequence field, Resolution value) {
  assert (cqpC instanceof QueryParser);
  QueryParser qp = (QueryParser) cqpC;
  qp.setDateResolution(field.toString(), value);
}
项目:Jouve-Project    文件:BaseLuceneIndexHelper.java   
public static String adjustIfDate(String texteLibre) {
    String result;
    try {
        Date date = new SimpleDateFormat("yyyy-MM-dd").parse(texteLibre.trim());
        result = DateTools.dateToString(date, Resolution.DAY);
    } catch (Exception e) {
        result = texteLibre;
    }
    return result;
}
项目:anycook-api    文件:FulltextIndex.java   
public void addRecipe(String recipeName)
        throws SQLException, DBRecipe.RecipeNotFoundException, IOException {
    recipeName = recipeName.toLowerCase(Locale.GERMAN);
    if (checkIfRecipeExists(recipeName)) {
        removeRecipe(recipeName);
    }

    try (DBGetRecipe dbGetRecipe = new DBGetRecipe()) {
        Recipe recipe = dbGetRecipe.get(recipeName);

        int id = dbGetRecipe.getActiveIdfromRecipe(recipeName);

        String date = DateTools.dateToString(new Date(), Resolution.DAY);

        List<Step> steps = Steps.loadRecipeSteps(recipeName);
        StringBuilder stepText = new StringBuilder();
        for (Step step : steps) {
            stepText.append(" ").append(step.getText());
        }

        try (IndexWriter writer = new IndexWriter(index, createIndexWriterConfig())) {
            Document doc = new Document();
            doc.add(new TextField("title", recipe.getName(), Field.Store.YES));
            doc.add(new TextField("description", recipe.getDescription() == null ? "" : recipe
                    .getDescription(),
                                  Field.Store.YES));
            doc.add(new TextField("steps", stepText.toString(), Field.Store.YES));
            doc.add(new IntField("version_id", id, Field.Store.YES));
            doc.add(new TextField("date", date, Field.Store.YES));

            writer.addDocument(doc);
            writer.commit();

            logger.info("added " + recipeName + " to index");

        } catch (CorruptIndexException | LockObtainFailedException e) {
            throw new IOException(e);
        }
    }
}
项目:anycook-api    文件:FulltextIndex.java   
public Document generateRecipeDoc(String recipeName)
        throws SQLException, DBRecipe.RecipeNotFoundException {
    try (DBGetRecipe dbGetRecipe = new DBGetRecipe()) {
        Recipe recipe = dbGetRecipe.get(recipeName);

        List<Step> steps = Steps.loadRecipeSteps(recipeName);
        StringBuilder stepText = new StringBuilder();
        for (Step step : steps) {
            stepText.append(" ").append(step.getText());
        }

        int id = dbGetRecipe.getActiveIdfromRecipe(recipeName);
        String date = DateTools.dateToString(new Date(), Resolution.DAY);

        Document doc = new Document();
        doc.add(new TextField("title", recipe.getName(), Field.Store.YES));
        doc.add(new TextField("description",
                              recipe.getDescription() == null ? "" : recipe.getDescription(),
                              Field.Store.YES));
        doc.add(new TextField("steps", stepText.toString(), Field.Store.YES));
        doc.add(new IntField("version_id", id, Field.Store.YES));
        doc.add(new TextField("date", date, Field.Store.YES));

        return doc;
    }

}
项目:resource-query-parser    文件:TestQueryParser.java   
@Override
public void setDateResolution(QueryParser cqpC, CharSequence field, Resolution value) {
    assert (cqpC instanceof QueryParser);
    QueryParser qp = (QueryParser) cqpC;
    qp.setDateResolution(field.toString(), value);
}
项目:lucene-addons    文件:TestQPTestBaseSpanQuery.java   
@Override
public void setDateResolution(CommonQueryParserConfiguration cqpC,
    CharSequence field, Resolution value) {
  //no-op
}
项目:cananolab    文件:IndexBuilder.java   
public void indexPublicationSearchableFieldsBean(PublicationSearchableFieldsBean pubFieldsBean) throws IOException {

        IndexWriter writer = getIndexWriter(false);
        Document doc = new Document();
        doc.add(new StringField("publicationId", pubFieldsBean.getPublicationId(), Field.Store.YES));
        if(pubFieldsBean.getPubTitle()!=null)
            doc.add(new StringField("pubTitle", pubFieldsBean.getPubTitle(), Field.Store.YES));
        if(pubFieldsBean.getPubmedId()!=null)
            doc.add(new StringField("pubmedId", pubFieldsBean.getPubmedId(), Field.Store.YES));
        if(pubFieldsBean.getDoiId()!=null)
            doc.add(new StringField("doiId", pubFieldsBean.getDoiId(), Field.Store.YES));
        if(pubFieldsBean.getPubDesc()!=null)
            doc.add(new StringField("pubDesc", pubFieldsBean.getPubDesc(), Field.Store.YES));
        if(pubFieldsBean.getCreatedDate()!=null)
            try{
                doc.add(new Field("createdDate", DateTools.stringToDate(DateTools.dateToString(pubFieldsBean.getCreatedDate(),Resolution.SECOND)).toString(), Field.Store.YES, Field.Index.NOT_ANALYZED));
            }catch(ParseException e){
                e.printStackTrace();
            }
        String keywords = "";
        String fullSearchableText = pubFieldsBean.getSampleName() + " " + pubFieldsBean.getPubDesc() + " " + pubFieldsBean.getPubTitle() + " " + pubFieldsBean.getPubmedId() + " " + pubFieldsBean.getDoiId();
        if(pubFieldsBean.getPubKeywords()!=null){
            for(int i = 0; i < pubFieldsBean.getPubKeywords().size(); i++){
                String keyword = pubFieldsBean.getPubKeywords().get(i);
                keywords = keywords + " " + keyword;
            }
        }
        fullSearchableText = fullSearchableText + " " + keywords;
        String authors = "";
        if(pubFieldsBean.getAuthors()!=null){
            for ( int j = 0; j < pubFieldsBean.getAuthors().size(); j++){
                String author = pubFieldsBean.getAuthors().get(j);
                authors = authors + " " + author;
            }
        }
        fullSearchableText = fullSearchableText + " " + authors;
        String sampleNames = "";
        if(pubFieldsBean.getSampleName()!=null){
            for(int k = 0; k < pubFieldsBean.getSampleName().size(); k++){
                String sampleName = pubFieldsBean.getSampleName().get(k);
                sampleNames = sampleNames + " " + sampleName;
            }
        }
        fullSearchableText = fullSearchableText + " " + sampleNames;

        doc.add(new TextField("content", fullSearchableText, Field.Store.NO));
        writer.addDocument(doc);

    }
项目:lams    文件:CommonQueryParserConfiguration.java   
/**
 * Sets the default {@link Resolution} used for certain field when
 * no {@link Resolution} is defined for this field.
 * 
 * @param dateResolution the default {@link Resolution}
 */
public void setDateResolution(DateTools.Resolution dateResolution);