Repository: maven-indexer
Updated Branches:
  refs/heads/master fc801678e -> eff47eecf


MINDEXER-108: lift the prefix restriction

Historically Lucene needed this, but latest versions
can cope with it. This is still OOM prone, so use with care,
but the possibility is here.


Project: http://git-wip-us.apache.org/repos/asf/maven-indexer/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-indexer/commit/0d8b480a
Tree: http://git-wip-us.apache.org/repos/asf/maven-indexer/tree/0d8b480a
Diff: http://git-wip-us.apache.org/repos/asf/maven-indexer/diff/0d8b480a

Branch: refs/heads/master
Commit: 0d8b480a9a0434b386a0c494d44fb59e0c23618f
Parents: fc80167
Author: Tamas Cservenak <[email protected]>
Authored: Fri Nov 24 10:30:20 2017 +0100
Committer: Tamas Cservenak <[email protected]>
Committed: Fri Nov 24 10:30:20 2017 +0100

----------------------------------------------------------------------
 .../apache/maven/index/DefaultQueryCreator.java |  5 ---
 .../index/AbstractRepoNexusIndexerTest.java     | 43 ++++++++++++++------
 pom.xml                                         |  2 +-
 3 files changed, 32 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-indexer/blob/0d8b480a/indexer-core/src/main/java/org/apache/maven/index/DefaultQueryCreator.java
----------------------------------------------------------------------
diff --git 
a/indexer-core/src/main/java/org/apache/maven/index/DefaultQueryCreator.java 
b/indexer-core/src/main/java/org/apache/maven/index/DefaultQueryCreator.java
index f47bead..4900bac 100644
--- a/indexer-core/src/main/java/org/apache/maven/index/DefaultQueryCreator.java
+++ b/indexer-core/src/main/java/org/apache/maven/index/DefaultQueryCreator.java
@@ -200,11 +200,6 @@ public class DefaultQueryCreator
             return null;
         }
 
-        if ( query.startsWith( "*" ) || query.startsWith( "?" ) )
-        {
-            throw new ParseException( "Query cannot start with '*' or '?'!" );
-        }
-
         if ( Field.NOT_PRESENT.equals( query ) )
         {
             return new WildcardQuery( new Term( indexerField.getKey(), "*" ) );

http://git-wip-us.apache.org/repos/asf/maven-indexer/blob/0d8b480a/indexer-core/src/test/java/org/apache/maven/index/AbstractRepoNexusIndexerTest.java
----------------------------------------------------------------------
diff --git 
a/indexer-core/src/test/java/org/apache/maven/index/AbstractRepoNexusIndexerTest.java
 
b/indexer-core/src/test/java/org/apache/maven/index/AbstractRepoNexusIndexerTest.java
index 1af94e4..5b34d49 100644
--- 
a/indexer-core/src/test/java/org/apache/maven/index/AbstractRepoNexusIndexerTest.java
+++ 
b/indexer-core/src/test/java/org/apache/maven/index/AbstractRepoNexusIndexerTest.java
@@ -213,19 +213,10 @@ public abstract class AbstractRepoNexusIndexerTest
             // "-" in the name
             // New in 4.0! constructquery do throw error on wrong input! I 
left in old call and checking it fails,
             // and then added "new" call with proper query syntax!
-            Query q;
-            try
-            {
-                q = nexusIndexer.constructQuery( MAVEN.ARTIFACT_ID, 
"*-logging", SearchType.SCORED );
 
-                fail( "Input is invalid, query cannot start with *!" );
-            }
-            catch ( IllegalArgumentException e )
-            {
-                // good, now let's do it again with good input:
-                // Note: since queries are really parsed now, the leading "-" 
is wrong too
-                q = nexusIndexer.constructQuery( MAVEN.ARTIFACT_ID, "logging", 
SearchType.SCORED );
-            }
+            // Since Lucene 5.x can cope with wildcard prefixes, this case is 
not valid anymore
+            // see https://issues.apache.org/jira/browse/MINDEXER-108
+            Query q = nexusIndexer.constructQuery( MAVEN.ARTIFACT_ID, 
"*-logging", SearchType.SCORED );
 
             GroupedSearchRequest request = new GroupedSearchRequest( q, new 
GAGrouping() );
 
@@ -565,4 +556,32 @@ public abstract class AbstractRepoNexusIndexerTest
         }
     }
 
+    public void testPrefixWildcard()
+        throws Exception
+    {
+        // see https://issues.apache.org/jira/browse/MINDEXER-108
+        IteratorSearchRequest request =
+            new IteratorSearchRequest( nexusIndexer.constructQuery( 
MAVEN.GROUP_ID, "*.forge", SearchType.EXACT ) );
+
+        // two candidates (see src/test/repo):
+        // org.terracotta.forge:forge-parent:1.0.5
+        // org.terracotta.forge:archetype-parent:1.0.1
+
+        IteratorSearchResponse response = nexusIndexer.searchIterator( request 
);
+
+        try
+        {
+            assertEquals( response.getResults().toString(), 2, 
response.getTotalHitsCount() );
+
+            for ( ArtifactInfo ai : response )
+            {
+                assertEquals( ai.getGroupId(), "org.terracotta.forge" );
+            }
+        }
+        finally
+        {
+            response.close();
+        }
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/maven-indexer/blob/0d8b480a/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 1ee9394..e2eff45 100644
--- a/pom.xml
+++ b/pom.xml
@@ -88,7 +88,7 @@ under the License.
     <failsafe.redirectTestOutputToFile>true</failsafe.redirectTestOutputToFile>
 
     <eclipse-sisu.version>0.3.3</eclipse-sisu.version>
-    <lucene.version>5.5.4</lucene.version>
+    <lucene.version>5.5.5</lucene.version>
     <maven.version>3.5.2</maven.version>
     <resolver.version>1.1.0</resolver.version>
     <truezip.version>7.7.10</truezip.version>

Reply via email to