Index: oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexPlanner.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexPlanner.java (date 1413177507000) +++ oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexPlanner.java (revision ) @@ -105,7 +105,7 @@ .setSortOrder(createSortOrder()) .setDelayed(true) //Lucene is always async .setAttribute(LuceneIndex.ATTR_INDEX_PATH, indexPath) - .setEstimatedEntryCount(getReader().numDocs()); + .setEstimatedEntryCount(Math.min(100, getReader().numDocs())); } private IndexReader getReader() { Index: oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndex.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndex.java (date 1413177507000) +++ oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndex.java (revision ) @@ -487,7 +487,7 @@ private static void addNonFullTextConstraints(List qs, Filter filter, IndexReader reader, Analyzer analyzer, IndexDefinition indexDefinition) { if (!filter.matchesAllTypes()) { - addNodeTypeConstraints(qs, filter); + addNodeTypeConstraints(qs, filter, indexDefinition); } String path = filter.getPath(); @@ -809,16 +809,25 @@ qs.add(bq); } - private static void addNodeTypeConstraints(List qs, Filter filter) { + + private static void addNodeTypeConstraints(List qs, Filter filter, + IndexDefinition indexDefinition) { BooleanQuery bq = new BooleanQuery(); - //TODO These condition should only be added if those propertyTypes are indexed + for (String type : filter.getPrimaryTypes()) { + if (indexDefinition.includeProperty(type)) { - bq.add(new TermQuery(new Term(JCR_PRIMARYTYPE, type)), SHOULD); - } + bq.add(new TermQuery(new Term(JCR_PRIMARYTYPE, type)), SHOULD); + } + } for (String type : filter.getMixinTypes()) { + if (indexDefinition.includeProperty(type)) { - bq.add(new TermQuery(new Term(JCR_MIXINTYPES, type)), SHOULD); - } + bq.add(new TermQuery(new Term(JCR_MIXINTYPES, type)), SHOULD); + } + } + + if (!bq.clauses().isEmpty()) { - qs.add(bq); + qs.add(bq); + } } static Query getFullTextQuery(FullTextExpression ft, final Analyzer analyzer, final IndexReader reader) { Index: oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/FieldFactory.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/FieldFactory.java (date 1413177507000) +++ oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/FieldFactory.java (revision ) @@ -106,9 +106,9 @@ } /** - * Date values are saved with sec resolution + * Date values are saved with configured resolution * @param date jcr data string - * @return date value in seconds + * @return date value */ public static Long dateToLong(String date){ if( date == null){ @@ -117,7 +117,7 @@ //TODO Should we change the precision to 5 min resolution //TODO make if configurable as part of property definition long millis = ISO8601.parse(date).getTimeInMillis(); - return TimeUnit.MILLISECONDS.toSeconds(millis); + return millis; } }