Author: chetanm
Date: Tue May 19 05:41:22 2015
New Revision: 1680176
URL: http://svn.apache.org/r1680176
Log:
OAK-2863 - No matching result found with use of relative property names in
fulltext search in some cases
Merging 1678954
Modified:
jackrabbit/oak/branches/1.2/ (props changed)
jackrabbit/oak/branches/1.2/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndex.java
jackrabbit/oak/branches/1.2/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndex.java
jackrabbit/oak/branches/1.2/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndexTest.java
Propchange: jackrabbit/oak/branches/1.2/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue May 19 05:41:22 2015
@@ -1,3 +1,3 @@
/jackrabbit/oak/branches/1.0:1665962
-/jackrabbit/oak/trunk:1672350,1672468,1672537,1672603,1672642,1672644,1672834-1672835,1673351,1673410,1673414,1673436,1673644,1673662-1673664,1673669,1673695,1674046,1674065,1674075,1674107,1674228,1674880,1675055,1675332,1675354,1675357,1675593,1676198,1676237,1676407,1676458,1676539,1676670,1676725,1677579,1677581,1677609,1677611,1677939,1677991,1678173,1678323,1678758,1678938,1679165,1679191,1679235
+/jackrabbit/oak/trunk:1672350,1672468,1672537,1672603,1672642,1672644,1672834-1672835,1673351,1673410,1673414,1673436,1673644,1673662-1673664,1673669,1673695,1674046,1674065,1674075,1674107,1674228,1674880,1675055,1675332,1675354,1675357,1675593,1676198,1676237,1676407,1676458,1676539,1676670,1676725,1677579,1677581,1677609,1677611,1677939,1677991,1678173,1678323,1678758,1678938,1678954,1679165,1679191,1679235
/jackrabbit/trunk:1345480
Modified:
jackrabbit/oak/branches/1.2/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndex.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.2/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndex.java?rev=1680176&r1=1680175&r2=1680176&view=diff
==============================================================================
---
jackrabbit/oak/branches/1.2/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndex.java
(original)
+++
jackrabbit/oak/branches/1.2/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndex.java
Tue May 19 05:41:22 2015
@@ -349,23 +349,31 @@ public class LuceneIndex implements Adva
TopDocs docs;
long time = System.currentTimeMillis();
checkForIndexVersionChange(searcher);
- if (lastDoc != null) {
- LOG.debug("loading the next {} entries for query
{}", nextBatchSize, query);
- docs = searcher.searchAfter(lastDoc, query,
nextBatchSize);
- } else {
- LOG.debug("loading the first {} entries for query
{}", nextBatchSize, query);
- docs = searcher.search(query, nextBatchSize);
- }
- time = System.currentTimeMillis() - time;
- LOG.debug("... took {} ms", time);
- nextBatchSize = (int) Math.min(nextBatchSize * 2L,
100000);
+ while (true) {
+ if (lastDoc != null) {
+ LOG.debug("loading the next {} entries for
query {}", nextBatchSize, query);
+ docs = searcher.searchAfter(lastDoc, query,
nextBatchSize);
+ } else {
+ LOG.debug("loading the first {} entries for
query {}", nextBatchSize, query);
+ docs = searcher.search(query, nextBatchSize);
+ }
+ time = System.currentTimeMillis() - time;
+ LOG.debug("... took {} ms", time);
+ nextBatchSize = (int) Math.min(nextBatchSize * 2L,
100000);
+
+ for (ScoreDoc doc : docs.scoreDocs) {
+ LuceneResultRow row = convertToRow(doc,
searcher);
+ if (row != null) {
+ queue.add(row);
+ }
+ lastDocToRecord = doc;
+ }
- for (ScoreDoc doc : docs.scoreDocs) {
- LuceneResultRow row = convertToRow(doc, searcher);
- if (row != null) {
- queue.add(row);
+ if (queue.isEmpty() && docs.scoreDocs.length > 0) {
+ lastDoc = lastDocToRecord;
+ } else {
+ break;
}
- lastDocToRecord = doc;
}
} else if (luceneRequestFacade.getLuceneRequest()
instanceof SpellcheckHelper.SpellcheckQuery) {
SpellcheckHelper.SpellcheckQuery spellcheckQuery =
(SpellcheckHelper.SpellcheckQuery) luceneRequestFacade.getLuceneRequest();
Modified:
jackrabbit/oak/branches/1.2/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndex.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.2/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndex.java?rev=1680176&r1=1680175&r2=1680176&view=diff
==============================================================================
---
jackrabbit/oak/branches/1.2/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndex.java
(original)
+++
jackrabbit/oak/branches/1.2/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndex.java
Tue May 19 05:41:22 2015
@@ -291,14 +291,23 @@ public class LucenePropertyIndex impleme
path = "/";
}
if (pr.isPathTransformed()) {
+ String originalPath = path;
path = pr.transformPath(path);
+
+ if (path == null){
+ LOG.trace("Ignoring path {} : Transformation
returned null", originalPath);
+ return null;
+ }
+
// avoid duplicate entries
- if (path == null || seenPaths.contains(path)) {
+ if (seenPaths.contains(path)){
+ LOG.trace("Ignoring path {} : Duplicate post
transformation", originalPath);
return null;
}
seenPaths.add(path);
}
+ LOG.trace("Matched path {}", path);
return new LuceneResultRow(path, doc.score);
}
return null;
@@ -334,30 +343,40 @@ public class LucenePropertyIndex impleme
TopDocs docs;
long start = PERF_LOGGER.start();
- if (lastDoc != null) {
- LOG.debug("loading the next {} entries for query
{}", nextBatchSize, query);
- if (sort == null) {
- docs = searcher.searchAfter(lastDoc, query,
nextBatchSize);
+ while (true) {
+ if (lastDoc != null) {
+ LOG.debug("loading the next {} entries for
query {}", nextBatchSize, query);
+ if (sort == null) {
+ docs = searcher.searchAfter(lastDoc,
query, nextBatchSize);
+ } else {
+ docs = searcher.searchAfter(lastDoc,
query, nextBatchSize, sort);
+ }
} else {
- docs = searcher.searchAfter(lastDoc, query,
nextBatchSize, sort);
+ LOG.debug("loading the first {} entries for
query {}", nextBatchSize, query);
+ if (sort == null) {
+ docs = searcher.search(query,
nextBatchSize);
+ } else {
+ docs = searcher.search(query,
nextBatchSize, sort);
+ }
}
- } else {
- LOG.debug("loading the first {} entries for query
{}", nextBatchSize, query);
- if (sort == null) {
- docs = searcher.search(query, nextBatchSize);
- } else {
- docs = searcher.search(query, nextBatchSize,
sort);
+ PERF_LOGGER.end(start, -1, "{} ...",
docs.scoreDocs.length);
+ nextBatchSize = (int) Math.min(nextBatchSize * 2L,
100000);
+
+ for (ScoreDoc doc : docs.scoreDocs) {
+ LuceneResultRow row = convertToRow(doc,
searcher);
+ if (row != null) {
+ queue.add(row);
+ }
+ lastDocToRecord = doc;
}
- }
- PERF_LOGGER.end(start, -1, "...");
- nextBatchSize = (int) Math.min(nextBatchSize * 2L,
100000);
- for (ScoreDoc doc : docs.scoreDocs) {
- LuceneResultRow row = convertToRow(doc, searcher);
- if (row != null) {
- queue.add(row);
+ if (queue.isEmpty() && docs.scoreDocs.length > 0) {
+ //queue is still empty but more results can be
fetched
+ //from Lucene so still continue
+ lastDoc = lastDocToRecord;
+ } else {
+ break;
}
- lastDocToRecord = doc;
}
} else if (luceneRequestFacade.getLuceneRequest()
instanceof SpellcheckHelper.SpellcheckQuery) {
SpellcheckHelper.SpellcheckQuery spellcheckQuery =
(SpellcheckHelper.SpellcheckQuery) luceneRequestFacade.getLuceneRequest();
Modified:
jackrabbit/oak/branches/1.2/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndexTest.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.2/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndexTest.java?rev=1680176&r1=1680175&r2=1680176&view=diff
==============================================================================
---
jackrabbit/oak/branches/1.2/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndexTest.java
(original)
+++
jackrabbit/oak/branches/1.2/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndexTest.java
Tue May 19 05:41:22 2015
@@ -1280,6 +1280,37 @@ public class LucenePropertyIndexTest ext
assertQuery("select * from [nt:base] where CONTAINS(*, 'jumping')",
Collections.<String>emptyList());
}
+ @Test
+ public void relativePropertyAndCursor() throws Exception{
+ // Index Definition
+ Tree idx = createIndex("test1", of("propa", "propb"));
+ TestUtil.useV2(idx);
+ idx.setProperty(LuceneIndexConstants.FULL_TEXT_ENABLED, true);
+
+ Tree propNode = idx.addChild(PROP_NODE);
+
+ // property definition for index test1
+ Tree propA = propNode.addChild("propa");
+ propA.setProperty(LuceneIndexConstants.PROP_TYPE,
PropertyType.TYPENAME_STRING);
+ propA.setProperty(LuceneIndexConstants.FIELD_BOOST, 2.0);
+
+ root.commit();
+
+ // create test data with 1 more than batch size
+ //with boost set we ensure that correct result comes *after* the batch
size of results
+ Tree test = root.getTree("/").addChild("test");
+ root.commit();
+ for (int i = 0; i < LucenePropertyIndex.LUCENE_QUERY_BATCH_SIZE; i++) {
+ test.addChild("a"+i).addChild("doNotInclude").setProperty("propa",
"foo");
+ }
+ test.addChild("b").addChild("jcr:content").setProperty("propb", "foo");
+ root.commit();
+
+ String queryString = "/jcr:root//element(*,
nt:base)[jcr:contains(jcr:content, 'foo' )]";
+
+ assertQuery(queryString, "xpath", asList("/test/b"));
+ }
+
private Tree createFileNode(Tree tree, String name, String content, String
mimeType){
Tree jcrContent = tree.addChild(name).addChild(JCR_CONTENT);
jcrContent.setProperty(JcrConstants.JCR_DATA, content.getBytes());