jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexparvule...@apache.org
Subject svn commit: r1575221 - in /jackrabbit/oak/trunk/oak-lucene/src: main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndex.java test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexQueryTest.java
Date Fri, 07 Mar 2014 10:19:28 GMT
Author: alexparvulescu
Date: Fri Mar  7 10:19:28 2014
New Revision: 1575221

URL: http://svn.apache.org/r1575221
Log:
OAK-1516 PhraseQuery fails due to missing posiion info in indexed fields


Modified:
    jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndex.java
    jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexQueryTest.java

Modified: jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndex.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndex.java?rev=1575221&r1=1575220&r2=1575221&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndex.java
(original)
+++ jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndex.java
Fri Mar  7 10:19:28 2014
@@ -707,7 +707,7 @@ public class LuceneIndex implements Full
                 MultiPhraseQuery mpq = new MultiPhraseQuery();
                 for(String token: tokens){
                     if (hasFulltextToken(token)) {
-                        Term[] terms = extractMatchingTokens(reader, token);
+                        Term[] terms = extractMatchingTokens(reader, fieldName, token);
                         if (terms != null && terms.length > 0) {
                             mpq.add(terms);
                         }
@@ -726,7 +726,7 @@ public class LuceneIndex implements Full
         }
     }
 
-    private static Term[] extractMatchingTokens(IndexReader reader, String token) {
+    private static Term[] extractMatchingTokens(IndexReader reader, String fieldName, String
token) {
         if (reader == null) {
             // getPlan call
             return null;
@@ -734,13 +734,14 @@ public class LuceneIndex implements Full
 
         try {
             List<Term> terms = new ArrayList<Term>();
-            Terms t = MultiFields.getTerms(reader, FieldNames.FULLTEXT);
-            Automaton a = WildcardQuery.toAutomaton(newFulltextTerm(token));
+            Term onTerm = newFulltextTerm(token, fieldName);
+            Terms t = MultiFields.getTerms(reader, onTerm.field());
+            Automaton a = WildcardQuery.toAutomaton(onTerm);
             CompiledAutomaton ca = new CompiledAutomaton(a);
             TermsEnum te = ca.getTermsEnum(t);
             BytesRef text;
             while ((text = te.next()) != null) {
-                terms.add(newFulltextTerm(text.utf8ToString()));
+                terms.add(newFulltextTerm(text.utf8ToString(), fieldName));
             }
             return terms.toArray(new Term[terms.size()]);
         } catch (IOException e) {

Modified: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexQueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexQueryTest.java?rev=1575221&r1=1575220&r2=1575221&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexQueryTest.java
(original)
+++ jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexQueryTest.java
Fri Mar  7 10:19:28 2014
@@ -161,6 +161,18 @@ public class LuceneIndexQueryTest extend
     }
 
     @Test
+    public void multiPhraseQuery() throws Exception {
+        Tree test = root.getTree("/").addChild("test");
+        test.addChild("a").setProperty("dc:format", "type:application/pdf");
+        root.commit();
+
+        assertQuery(
+                "/jcr:root//*[jcr:contains(@dc:format, 'type:appli*')]",
+                "xpath", ImmutableList.of("/test/a"));
+
+    }
+
+    @Test
     public void containsPath() throws Exception {
 
         Tree test = root.getTree("/").addChild("test");



Mime
View raw message