You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ep...@apache.org on 2006/02/22 03:39:06 UTC

svn commit: r379654 [1/2] - in /maven/repository-manager/trunk/maven-repository-indexer/src: main/java/org/apache/maven/repository/indexing/ test/java/org/apache/maven/repository/indexing/

Author: epunzalan
Date: Tue Feb 21 18:39:04 2006
New Revision: 379654

URL: http://svn.apache.org/viewcvs?rev=379654&view=rev
Log:
PR: MRM-57, MRM-58
Submitted by: Maria Odea Ching

patch fix for general search

Added:
    maven/repository-manager/trunk/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/RepositoryIndexSearchHit.java
    maven/repository-manager/trunk/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/RepositoryIndexSearchLayer.java
    maven/repository-manager/trunk/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/SearchResult.java
    maven/repository-manager/trunk/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/RepositoryIndexSearchLayerTest.java
Removed:
    maven/repository-manager/trunk/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/GeneralRepositoryIndexSearcher.java
    maven/repository-manager/trunk/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/GeneralRepositoryIndexSearcherTest.java
Modified:
    maven/repository-manager/trunk/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/DefaultRepositoryIndexSearcher.java
    maven/repository-manager/trunk/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/DefaultRepositoryIndexingFactory.java
    maven/repository-manager/trunk/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/MetadataRepositoryIndex.java
    maven/repository-manager/trunk/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/RepositoryIndex.java
    maven/repository-manager/trunk/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/RepositoryIndexingFactory.java
    maven/repository-manager/trunk/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/ArtifactRepositoryIndexingTest.java
    maven/repository-manager/trunk/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/MetadataRepositoryIndexingTest.java
    maven/repository-manager/trunk/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/PomRepositoryIndexingTest.java

Modified: maven/repository-manager/trunk/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/DefaultRepositoryIndexSearcher.java
URL: http://svn.apache.org/viewcvs/maven/repository-manager/trunk/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/DefaultRepositoryIndexSearcher.java?rev=379654&r1=379653&r2=379654&view=diff
==============================================================================
--- maven/repository-manager/trunk/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/DefaultRepositoryIndexSearcher.java (original)
+++ maven/repository-manager/trunk/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/DefaultRepositoryIndexSearcher.java Tue Feb 21 18:39:04 2006
@@ -24,35 +24,38 @@
 import org.apache.lucene.search.Hits;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.TermQuery;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.factory.ArtifactFactory;
+import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata;
+import org.apache.maven.artifact.repository.metadata.GroupRepositoryMetadata;
+import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
+import org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata;
+import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader;
+import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
 import org.apache.maven.repository.indexing.query.CompoundQuery;
 import org.apache.maven.repository.indexing.query.CompoundQueryTerm;
 import org.apache.maven.repository.indexing.query.Query;
 import org.apache.maven.repository.indexing.query.RangeQuery;
 import org.apache.maven.repository.indexing.query.SinglePhraseQuery;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
-import org.apache.maven.artifact.repository.metadata.GroupRepositoryMetadata;
-import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata;
-import org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata;
-import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader;
-import org.apache.maven.artifact.factory.ArtifactFactory;
 import org.codehaus.plexus.logging.AbstractLogEnabled;
 import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
 
-import java.io.IOException;
 import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.net.MalformedURLException;
 import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 import java.util.StringTokenizer;
-import java.util.Collections;
-import java.net.MalformedURLException;
-import java.net.URL;
 
 /**
- * Abstract Class to hold common codes for the different RepositoryIndexSearcher
+ * Implementation Class for searching through the index
  */
 public class DefaultRepositoryIndexSearcher
     extends AbstractLogEnabled
@@ -62,6 +65,8 @@
 
     private ArtifactFactory factory;
 
+    private List artifactList;
+
     /**
      * Constructor
      *
@@ -79,7 +84,7 @@
     public List search( Query query )
         throws RepositoryIndexSearchException
     {
-
+        artifactList = new ArrayList();
         org.apache.lucene.search.Query luceneQuery;
         try
         {
@@ -215,12 +220,9 @@
     private List buildList( Hits hits )
         throws MalformedURLException, IOException, XmlPullParserException
     {
-        List artifactList = new ArrayList();
-
         for ( int i = 0; i < hits.length(); i++ )
         {
             Document doc = hits.doc( i );
-
             artifactList.add( createSearchedObjectFromIndexDocument( doc ) );
         }
 
@@ -233,38 +235,55 @@
      * @param doc the index document where the object field values will be retrieved from
      * @return Object
      */
-    protected Object createSearchedObjectFromIndexDocument( Document doc )
+    protected RepositoryIndexSearchHit createSearchedObjectFromIndexDocument( Document doc )
         throws MalformedURLException, IOException, XmlPullParserException
     {
         String groupId, artifactId, version, name, packaging;
+        RepositoryIndexSearchHit searchHit = null;
 
-        if ( doc.get( index.FLD_DOCTYPE ).equals( index.ARTIFACT ) )
+        // the document is of type artifact
+        if ( doc.get( RepositoryIndex.FLD_DOCTYPE ).equals( RepositoryIndex.ARTIFACT ) )
         {
-            groupId = doc.get( ArtifactRepositoryIndex.FLD_GROUPID );
-            artifactId = doc.get( ArtifactRepositoryIndex.FLD_ARTIFACTID );
-            version = doc.get( ArtifactRepositoryIndex.FLD_VERSION );
-            name = doc.get( ArtifactRepositoryIndex.FLD_NAME );
-            packaging = name.substring( name.lastIndexOf( '.' ) + 1 );
+            groupId = doc.get( RepositoryIndex.FLD_GROUPID );
+            artifactId = doc.get( RepositoryIndex.FLD_ARTIFACTID );
+            version = doc.get( RepositoryIndex.FLD_VERSION );
+            name = doc.get( RepositoryIndex.FLD_NAME );
+            packaging = doc.get( RepositoryIndex.FLD_PACKAGING );
             Artifact artifact = factory.createBuildArtifact( groupId, artifactId, version, packaging );
-            String groupIdTemp = groupId.replace( '.', '/' );
-            artifact.setFile( new File(
-                index.getRepository().getBasedir() + groupIdTemp + "/" + artifactId + "/" + version + "/" + name ) );
 
-            return artifact;
-        }
-        else if ( doc.get( index.FLD_DOCTYPE ).equals( index.POM ) )
-        {
-            groupId = doc.get( PomRepositoryIndex.FLD_GROUPID );
-            artifactId = doc.get( PomRepositoryIndex.FLD_ARTIFACTID );
-            version = doc.get( PomRepositoryIndex.FLD_VERSION );
-            packaging = doc.get( PomRepositoryIndex.FLD_PACKAGING );
+            artifact.setFile(
+                new File( index.getRepository().getBasedir(), index.getRepository().pathOf( artifact ) ) );
+
+            Map map = new HashMap();
+            map.put( RepositoryIndex.ARTIFACT, artifact );
+            map.put( RepositoryIndex.FLD_CLASSES, doc.get( RepositoryIndex.FLD_CLASSES ) );
+            map.put( RepositoryIndex.FLD_PACKAGES, doc.get( RepositoryIndex.FLD_PACKAGES ) );
+            map.put( RepositoryIndex.FLD_FILES, doc.get( RepositoryIndex.FLD_FILES ) );
+            map.put( RepositoryIndex.FLD_MD5, doc.get( RepositoryIndex.FLD_MD5 ) );
+            map.put( RepositoryIndex.FLD_SHA1, doc.get( RepositoryIndex.FLD_SHA1 ) );
+            map.put( RepositoryIndex.FLD_PACKAGING, doc.get( RepositoryIndex.FLD_PACKAGING ) );
+
+            searchHit = new RepositoryIndexSearchHit( true, false, false );
+            searchHit.setObject( map );
+        }
+        // the document is of type model
+        else if ( doc.get( RepositoryIndex.FLD_DOCTYPE ).equals( RepositoryIndex.POM ) )
+        {
+            InputStream is = new FileInputStream( new File( index.getRepository().getBasedir() +
+                doc.get( RepositoryIndex.FLD_GROUPID ).replace( '.', '/' ) + "/" +
+                doc.get( RepositoryIndex.FLD_ARTIFACTID ) + "/" + doc.get( RepositoryIndex.FLD_VERSION ) + "/" +
+                doc.get( RepositoryIndex.FLD_ARTIFACTID ) + "-" + doc.get( RepositoryIndex.FLD_VERSION ) + ".pom" ) );
+            MavenXpp3Reader reader = new MavenXpp3Reader();
+
+            searchHit = new RepositoryIndexSearchHit( false, false, true );
+            searchHit.setObject( reader.read( new InputStreamReader( is ) ) );
 
-            return factory.createBuildArtifact( groupId, artifactId, version, packaging );
         }
-        else if ( doc.get( index.FLD_DOCTYPE ).equals( index.METADATA ) )
+        // the document is of type metadata
+        else if ( doc.get( RepositoryIndex.FLD_DOCTYPE ).equals( RepositoryIndex.METADATA ) )
         {
             List pathParts = new ArrayList();
-            StringTokenizer st = new StringTokenizer( doc.get( MetadataRepositoryIndex.FLD_NAME ), "/\\" );
+            StringTokenizer st = new StringTokenizer( doc.get( RepositoryIndex.FLD_NAME ), "/\\" );
             while ( st.hasMoreTokens() )
             {
                 pathParts.add( st.nextToken() );
@@ -276,28 +295,28 @@
             String tmpDir = (String) it.next();
 
             String metadataType = "";
-            if ( tmpDir.equals( doc.get( MetadataRepositoryIndex.FLD_GROUPID ) ) )
+            if ( tmpDir.equals( doc.get( RepositoryIndex.FLD_VERSION ) ) )
             {
-                metadataType = MetadataRepositoryIndex.GROUP_METADATA;
+                metadataType = MetadataRepositoryIndex.SNAPSHOT_METADATA;
             }
-            else if ( tmpDir.equals( doc.get( MetadataRepositoryIndex.FLD_ARTIFACTID ) ) )
+            else if ( tmpDir.equals( doc.get( RepositoryIndex.FLD_ARTIFACTID ) ) )
             {
                 metadataType = MetadataRepositoryIndex.ARTIFACT_METADATA;
             }
             else
             {
-                metadataType = MetadataRepositoryIndex.SNAPSHOT_METADATA;
+                metadataType = MetadataRepositoryIndex.GROUP_METADATA;
             }
 
-            RepositoryMetadata repoMetadata = null;
-            repoMetadata = getMetadata( doc.get( MetadataRepositoryIndex.FLD_GROUPID ),
-                                        doc.get( MetadataRepositoryIndex.FLD_ARTIFACTID ),
-                                        doc.get( MetadataRepositoryIndex.FLD_VERSION ), metadataFile, metadataType );
-
-            return repoMetadata;
+            RepositoryMetadata repoMetadata = getMetadata( doc.get( RepositoryIndex.FLD_GROUPID ),
+                                                           doc.get( RepositoryIndex.FLD_ARTIFACTID ),
+                                                           doc.get( RepositoryIndex.FLD_VERSION ), metadataFile,
+                                                           metadataType );
+            searchHit = new RepositoryIndexSearchHit( false, true, false );
+            searchHit.setObject( repoMetadata );
         }
 
-        return null;
+        return searchHit;
     }
 
     /**
@@ -318,24 +337,22 @@
         throws MalformedURLException, IOException, XmlPullParserException
     {
         RepositoryMetadata repoMetadata = null;
-        URL url;
         InputStream is = null;
         MetadataXpp3Reader metadataReader = new MetadataXpp3Reader();
 
         //group metadata
         if ( metadataType.equals( MetadataRepositoryIndex.GROUP_METADATA ) )
         {
-            url = new File( index.getRepository().getBasedir() + groupId.replace( '.', '/' ) + "/" + filename ).toURL();
-            is = url.openStream();
+            is = new FileInputStream(
+                new File( index.getRepository().getBasedir() + groupId.replace( '.', '/' ) + "/" + filename ) );
             repoMetadata = new GroupRepositoryMetadata( groupId );
             repoMetadata.setMetadata( metadataReader.read( new InputStreamReader( is ) ) );
         }
         //artifact metadata
         else if ( metadataType.equals( MetadataRepositoryIndex.ARTIFACT_METADATA ) )
         {
-            url = new File( index.getRepository().getBasedir() + groupId.replace( '.', '/' ) + "/" + artifactId + "/" +
-                filename ).toURL();
-            is = url.openStream();
+            is = new FileInputStream( new File( index.getRepository().getBasedir() + groupId.replace( '.', '/' ) + "/" +
+                artifactId + "/" + filename ) );
             repoMetadata =
                 new ArtifactRepositoryMetadata( factory.createBuildArtifact( groupId, artifactId, version, "jar" ) );
             repoMetadata.setMetadata( metadataReader.read( new InputStreamReader( is ) ) );
@@ -343,9 +360,8 @@
         //snapshot/version metadata
         else if ( metadataType.equals( MetadataRepositoryIndex.SNAPSHOT_METADATA ) )
         {
-            url = new File( index.getRepository().getBasedir() + groupId.replace( '.', '/' ) + "/" + artifactId + "/" +
-                version + "/" + filename ).toURL();
-            is = url.openStream();
+            is = new FileInputStream( new File( index.getRepository().getBasedir() + groupId.replace( '.', '/' ) + "/" +
+                artifactId + "/" + version + "/" + filename ) );
             repoMetadata = new SnapshotArtifactRepositoryMetadata(
                 factory.createBuildArtifact( groupId, artifactId, version, "jar" ) );
             repoMetadata.setMetadata( metadataReader.read( new InputStreamReader( is ) ) );

Modified: maven/repository-manager/trunk/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/DefaultRepositoryIndexingFactory.java
URL: http://svn.apache.org/viewcvs/maven/repository-manager/trunk/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/DefaultRepositoryIndexingFactory.java?rev=379654&r1=379653&r2=379654&view=diff
==============================================================================
--- maven/repository-manager/trunk/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/DefaultRepositoryIndexingFactory.java (original)
+++ maven/repository-manager/trunk/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/DefaultRepositoryIndexingFactory.java Tue Feb 21 18:39:04 2006
@@ -66,11 +66,11 @@
     }
 
     /*
-     * @see RepositoryIndexingFactory#createGeneralRepositoryIndexSearcher(RepositoryIndex)
+     * @see RepositoryIndexingFactory#createRepositoryIndexSearchLayer(RepositoryIndex)
      */
-    public GeneralRepositoryIndexSearcher createGeneralRepositoryIndexSearcher( RepositoryIndex index )
+    public RepositoryIndexSearchLayer createRepositoryIndexSearchLayer( RepositoryIndex index )
     {
-        return new GeneralRepositoryIndexSearcher( index, artifactFactory );
+        return new RepositoryIndexSearchLayer( index, artifactFactory );
     }
 
     /**

Modified: maven/repository-manager/trunk/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/MetadataRepositoryIndex.java
URL: http://svn.apache.org/viewcvs/maven/repository-manager/trunk/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/MetadataRepositoryIndex.java?rev=379654&r1=379653&r2=379654&view=diff
==============================================================================
--- maven/repository-manager/trunk/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/MetadataRepositoryIndex.java (original)
+++ maven/repository-manager/trunk/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/MetadataRepositoryIndex.java Tue Feb 21 18:39:04 2006
@@ -132,7 +132,7 @@
             Plugin plugin = (Plugin) iter.next();
             if ( plugin.getPrefix() != null && !plugin.getPrefix().equals( "" ) )
             {
-                pluginAppended = plugin.getPrefix() + " ";
+                pluginAppended = plugin.getPrefix() + "\n";
             }
         }
         doc.add( Field.Text( FLD_PLUGINPREFIX, pluginAppended ) );

Modified: maven/repository-manager/trunk/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/RepositoryIndex.java
URL: http://svn.apache.org/viewcvs/maven/repository-manager/trunk/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/RepositoryIndex.java?rev=379654&r1=379653&r2=379654&view=diff
==============================================================================
--- maven/repository-manager/trunk/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/RepositoryIndex.java (original)
+++ maven/repository-manager/trunk/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/RepositoryIndex.java Tue Feb 21 18:39:04 2006
@@ -33,43 +33,43 @@
 
     static final String ARTIFACT = "ARTIFACT";
 
-    static final String FLD_ID = "ID";
+    static final String FLD_ID = "id";
 
-    static final String FLD_NAME = "NAME";
+    static final String FLD_NAME = "name";
 
-    static final String FLD_DOCTYPE = "DOCTYPE";
+    static final String FLD_DOCTYPE = "doctype";
 
-    static final String FLD_GROUPID = "GROUPID";
+    static final String FLD_GROUPID = "groupId";
 
-    static final String FLD_ARTIFACTID = "ARTIFACTID";
+    static final String FLD_ARTIFACTID = "artifactId";
 
-    static final String FLD_VERSION = "VERSION";
+    static final String FLD_VERSION = "version";
 
-    static final String FLD_PACKAGING = "PACKAGING";
+    static final String FLD_PACKAGING = "packaging";
 
-    static final String FLD_SHA1 = "SHA1";
+    static final String FLD_SHA1 = "sha1";
 
-    static final String FLD_MD5 = "MD5";
+    static final String FLD_MD5 = "md5";
 
-    static final String FLD_LASTUPDATE = "LASTUPDATE";
+    static final String FLD_LASTUPDATE = "last update";
 
-    static final String FLD_PLUGINPREFIX = "PLUGINPREFIX";
+    static final String FLD_PLUGINPREFIX = "plugin prefix";
 
-    static final String FLD_CLASSES = "CLASSES";
+    static final String FLD_CLASSES = "class";
 
-    static final String FLD_PACKAGES = "PACKAGES";
+    static final String FLD_PACKAGES = "package";
 
-    static final String FLD_FILES = "FILES";
+    static final String FLD_FILES = "file";
 
-    static final String FLD_LICENSE_URLS = "LICENSE_URLS";
+    static final String FLD_LICENSE_URLS = "license url";
 
-    static final String FLD_DEPENDENCIES = "DEPENDENCIES";
+    static final String FLD_DEPENDENCIES = "dependency";
 
-    static final String FLD_PLUGINS_BUILD = "PLUGINS_BUILD";
+    static final String FLD_PLUGINS_BUILD = "build plugin";
 
-    static final String FLD_PLUGINS_REPORT = "PLUGINS_REPORT";
+    static final String FLD_PLUGINS_REPORT = "report plugin";
 
-    static final String FLD_PLUGINS_ALL = "PLUGINS_ALL";
+    static final String FLD_PLUGINS_ALL = "plugins_all";
 
     static final String[] FIELDS = {FLD_ID, FLD_NAME, FLD_DOCTYPE, FLD_GROUPID, FLD_ARTIFACTID, FLD_VERSION,
         FLD_PACKAGING, FLD_SHA1, FLD_MD5, FLD_LASTUPDATE, FLD_PLUGINPREFIX, FLD_CLASSES, FLD_PACKAGES, FLD_FILES,
@@ -77,6 +77,9 @@
 
     static final List KEYWORD_FIELDS = Arrays.asList( new String[]{FLD_ID, FLD_PACKAGING, FLD_LICENSE_URLS,
         FLD_DEPENDENCIES, FLD_PLUGINS_BUILD, FLD_PLUGINS_REPORT, FLD_PLUGINS_ALL} );
+
+    static final String[] MODEL_FIELDS =
+        {FLD_PACKAGING, FLD_LICENSE_URLS, FLD_DEPENDENCIES, FLD_PLUGINS_BUILD, FLD_PLUGINS_REPORT};
 
     /**
      * Method used to query the index status

Added: maven/repository-manager/trunk/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/RepositoryIndexSearchHit.java
URL: http://svn.apache.org/viewcvs/maven/repository-manager/trunk/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/RepositoryIndexSearchHit.java?rev=379654&view=auto
==============================================================================
--- maven/repository-manager/trunk/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/RepositoryIndexSearchHit.java (added)
+++ maven/repository-manager/trunk/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/RepositoryIndexSearchHit.java Tue Feb 21 18:39:04 2006
@@ -0,0 +1,96 @@
+package org.apache.maven.repository.indexing;
+
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * This class is the object type contained in the list returned by the DefaultRepositoryIndexSearcher
+ */
+public class RepositoryIndexSearchHit
+{
+    private Object obj;
+
+    private boolean isHashMap = false;
+
+    private boolean isMetadata = false;
+
+    private boolean isModel = false;
+
+    /**
+     * Class constructor
+     *
+     * @param isHashMap  indicates whether the object is a HashMap object
+     * @param isMetadata indicates whether the object is a RepositoryMetadata object
+     * @param isModel    indicates whether the object is a Model object
+     */
+    public RepositoryIndexSearchHit( boolean isHashMap, boolean isMetadata, boolean isModel )
+    {
+        this.isHashMap = isHashMap;
+        this.isMetadata = isMetadata;
+        this.isModel = isModel;
+    }
+
+    /**
+     * Getter method for obj variable
+     *
+     * @return the Object
+     */
+    public Object getObject()
+    {
+        return obj;
+    }
+
+    /**
+     * Setter method for obj variable
+     *
+     * @param obj
+     */
+    public void setObject( Object obj )
+    {
+        this.obj = obj;
+    }
+
+    /**
+     * Method that indicates if the object is a HashMap
+     *
+     * @return boolean
+     */
+    public boolean isHashMap()
+    {
+        return isHashMap;
+    }
+
+    /**
+     * Method that indicates if the object is a RepositoryMetadata
+     *
+     * @return boolean
+     */
+    public boolean isMetadata()
+    {
+        return isMetadata;
+    }
+
+    /**
+     * Method that indicates if the object is a Model
+     *
+     * @return boolean
+     */
+    public boolean isModel()
+    {
+        return isModel;
+    }
+
+}

Added: maven/repository-manager/trunk/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/RepositoryIndexSearchLayer.java
URL: http://svn.apache.org/viewcvs/maven/repository-manager/trunk/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/RepositoryIndexSearchLayer.java?rev=379654&view=auto
==============================================================================
--- maven/repository-manager/trunk/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/RepositoryIndexSearchLayer.java (added)
+++ maven/repository-manager/trunk/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/RepositoryIndexSearchLayer.java Tue Feb 21 18:39:04 2006
@@ -0,0 +1,438 @@
+package org.apache.maven.repository.indexing;
+
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.factory.ArtifactFactory;
+import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
+import org.apache.maven.model.Dependency;
+import org.apache.maven.model.License;
+import org.apache.maven.model.Model;
+import org.apache.maven.model.Plugin;
+import org.apache.maven.model.ReportPlugin;
+import org.apache.maven.repository.indexing.query.Query;
+import org.apache.maven.repository.indexing.query.SinglePhraseQuery;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
+import java.util.Set;
+
+/**
+ * <p/>
+ * This class is to be invoked or called by the action class for
+ * general and advanced searching. It uses the DefaultRepositoryIndexSearcher
+ * to perform the search and constructs the search result objects to be
+ * returned to tha webapp action class.
+ */
+public class RepositoryIndexSearchLayer
+{
+    private RepositoryIndex index;
+
+    private ArtifactFactory factory;
+
+    private List searchResults;
+
+    private List generalSearchResults;
+
+    /**
+     * Class constructor
+     *
+     * @param index
+     */
+    public RepositoryIndexSearchLayer( RepositoryIndex index, ArtifactFactory factory )
+    {
+        this.index = index;
+        this.factory = factory;
+    }
+
+    /**
+     * Method for searching the keyword in all the fields in the index. "Query everything" search.
+     * The index fields will be retrieved and query objects will be constructed using the
+     * optional (OR) CompoundQuery.
+     *
+     * @param keyword
+     * @return
+     * @throws RepositoryIndexSearchException
+     */
+    public List searchGeneral( String keyword )
+        throws RepositoryIndexSearchException
+    {
+        generalSearchResults = new ArrayList();
+        for ( int i = 0; i < RepositoryIndex.FIELDS.length; i++ )
+        {
+            Query qry = new SinglePhraseQuery( RepositoryIndex.FIELDS[i], keyword );
+            List results = searchAdvanced( qry );
+            for ( Iterator iter = results.iterator(); iter.hasNext(); )
+            {
+                SearchResult result = (SearchResult) iter.next();
+                Map map = result.getFieldMatches();
+                Set entrySet = map.entrySet();
+                for ( Iterator it = entrySet.iterator(); it.hasNext(); )
+                {
+                    Map.Entry entry = (Map.Entry) it.next();
+                    SearchResult result2 =
+                        createSearchResult( result.getArtifact(), map, keyword, (String) entry.getKey() );
+                    generalSearchResults.add( result2 );
+                }
+            }
+        }
+
+        return generalSearchResults;
+    }
+
+    /**
+     * Method for "advanced search" of the index
+     *
+     * @param qry the query object that will be used for searching the index
+     * @return
+     * @throws RepositoryIndexSearchException
+     */
+    public List searchAdvanced( Query qry )
+        throws RepositoryIndexSearchException
+    {
+        RepositoryIndexSearcher searcher = new DefaultRepositoryIndexSearcher( index, factory );
+        searchResults = new ArrayList();
+
+        List hits = searcher.search( qry );
+        for ( Iterator it = hits.iterator(); it.hasNext(); )
+        {
+            RepositoryIndexSearchHit hit = (RepositoryIndexSearchHit) it.next();
+            SearchResult result = new SearchResult();
+            if ( hit.isHashMap() )
+            {
+                Map map = (Map) hit.getObject();
+                result.setArtifact( (Artifact) map.get( RepositoryIndex.ARTIFACT ) );
+
+                Map fields = new HashMap();
+                fields.put( RepositoryIndex.FLD_CLASSES, map.get( RepositoryIndex.FLD_CLASSES ) );
+                fields.put( RepositoryIndex.FLD_PACKAGES, map.get( RepositoryIndex.FLD_PACKAGES ) );
+                fields.put( RepositoryIndex.FLD_FILES, map.get( RepositoryIndex.FLD_FILES ) );
+                fields.put( RepositoryIndex.FLD_PACKAGING, map.get( RepositoryIndex.FLD_PACKAGING ) );
+                fields.put( RepositoryIndex.FLD_SHA1, map.get( RepositoryIndex.FLD_SHA1 ) );
+                fields.put( RepositoryIndex.FLD_MD5, map.get( RepositoryIndex.FLD_MD5 ) );
+
+                result.setFieldMatches( fields );
+                searchResults.add( result );
+            }
+            else if ( hit.isModel() )
+            {
+                Model model = (Model) hit.getObject();
+                for ( int i = 0; i < RepositoryIndex.MODEL_FIELDS.length; i++ )
+                {
+                    result = createSearchResult( model, RepositoryIndex.MODEL_FIELDS[i] );
+                    searchResults.add( result );
+                }
+            }
+            else if ( hit.isMetadata() )
+            {
+                //@todo what about metadata objects?
+                RepositoryMetadata metadata = (RepositoryMetadata) hit.getObject();
+            }
+        }
+
+        return searchResults;
+    }
+
+    /**
+     * Method for checking if the artifact already exists in the search result list.
+     *
+     * @param groupId    the group id of the artifact
+     * @param artifactId the artifact id of the artifact
+     * @param version    the version of the artifact
+     * @return the int index number of the artifact in the search result
+     */
+    private int getListIndex( String groupId, String artifactId, String version, List list )
+    {
+        int index = 0;
+        for ( Iterator iter = list.iterator(); iter.hasNext(); )
+        {
+            SearchResult result = (SearchResult) iter.next();
+            Artifact artifact = result.getArtifact();
+            if ( artifact.getGroupId().equals( groupId ) && artifact.getArtifactId().equals( artifactId ) &&
+                artifact.getVersion().equals( version ) )
+            {
+                return index;
+            }
+            index++;
+        }
+        return -1;
+    }
+
+    /**
+     * Method to create the unique artifact id to represent the artifact in the repository
+     *
+     * @param groupId    the artifact groupId
+     * @param artifactId the artifact artifactId
+     * @param version    the artifact version
+     * @return the String id to uniquely represent the artifact
+     */
+    private String getId( String groupId, String artifactId, String version )
+    {
+        return groupId + ":" + artifactId + ":" + version;
+    }
+
+    /**
+     * Method to get the matching values (packages, classes and files) in the
+     * given string to be tokenized.
+     *
+     * @param tokenizeStr the string to be tokenized
+     * @param key         the map key
+     * @param resultMap   the map to be populated
+     * @param keyword     the value to be matched
+     * @return the map that contains the matched values
+     */
+    private Map getArtifactHits( String tokenizeStr, String key, Map resultMap, String keyword )
+    {
+        List values = new ArrayList();
+        StringTokenizer st = new StringTokenizer( tokenizeStr, "\n" );
+        while ( st.hasMoreTokens() )
+        {
+            String str = st.nextToken();
+            if ( str.toLowerCase().indexOf( keyword.toLowerCase() ) != -1 )
+            {
+                values.add( str );
+            }
+        }
+
+        if ( values != null && values.size() > 0 )
+        {
+            resultMap.put( key, values );
+        }
+
+        return resultMap;
+    }
+
+    /**
+     * Method to create SearchResult object from a given HashMap. Used for general search results
+     *
+     * @param artifact the retrieved artifact from the index
+     * @param map      the HashMap object that contains the values for the search result
+     * @param keyword  the query term
+     * @return the SearchResult object
+     */
+    private SearchResult createSearchResult( Artifact artifact, Map map, String keyword, String field )
+    {
+        int index = getListIndex( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(),
+                                  generalSearchResults );
+        SearchResult result;
+        Map resultMap;
+
+        if ( index > -1 )
+        {
+            result = (SearchResult) generalSearchResults.get( index );
+            generalSearchResults.remove( index );
+            resultMap = result.getFieldMatches();
+        }
+        else
+        {
+            result = new SearchResult();
+            result.setArtifact( artifact );
+            resultMap = new HashMap();
+        }
+
+        // the searched field is either the class, package or file field
+        if ( field.equals( RepositoryIndex.FLD_CLASSES ) || field.equals( RepositoryIndex.FLD_PACKAGES ) ||
+            field.equals( RepositoryIndex.FLD_FILES ) )
+        {
+            resultMap = getArtifactHits( (String) map.get( field ), field, resultMap, keyword );
+        }
+        else if ( field.equals( RepositoryIndex.FLD_SHA1 ) ||
+            ( field.equals( RepositoryIndex.FLD_MD5 ) || field.equals( RepositoryIndex.FLD_PACKAGING ) ) )
+        {
+            if ( map.get( field ) != null )
+            {
+                // the searched field is either the md5, sha1 or packaging field
+                if ( ( (String) map.get( field ) ).toLowerCase().equals( keyword.toLowerCase() ) ||
+                    ( (String) map.get( field ) ).toLowerCase().indexOf( keyword.toLowerCase() ) != -1 )
+                {
+                    resultMap.put( field, map.get( field ) );
+                }
+            }
+        }
+        else if ( field.equals( RepositoryIndex.FLD_DEPENDENCIES ) ||
+            field.equals( RepositoryIndex.FLD_PLUGINS_BUILD ) || field.equals( RepositoryIndex.FLD_PLUGINS_REPORT ) ||
+            field.equals( RepositoryIndex.FLD_LICENSE_URLS ) )
+        {
+            List contents = (List) map.get( field );
+            List values = new ArrayList();
+            for ( Iterator it = contents.iterator(); it.hasNext(); )
+            {
+                String str = (String) it.next();
+                if ( str.toLowerCase().equals( keyword.toLowerCase() ) )
+                {
+                    values.add( str );
+                }
+            }
+            if ( values.size() > 0 )
+            {
+                resultMap.put( field, values );
+            }
+        }
+        result.setFieldMatches( resultMap );
+
+        return result;
+    }
+
+    /**
+     * Method to create a SearchResult object from the given model. Used for advanced search results
+     *
+     * @param model the Model object that contains the values for the search result
+     * @param field the field whose value is to be retrieved
+     * @return a SearchResult object
+     */
+    private SearchResult createSearchResult( Model model, String field )
+    {
+        int index = getListIndex( model.getGroupId(), model.getArtifactId(), model.getVersion(), searchResults );
+        SearchResult result;
+        Map map;
+
+        // the object already exists in the search result list
+        if ( index > -1 )
+        {
+            result = (SearchResult) searchResults.get( index );
+            searchResults.remove( index );
+            map = result.getFieldMatches();
+        }
+        else
+        {
+            result = new SearchResult();
+            result.setArtifact( factory.createBuildArtifact( model.getGroupId(), model.getArtifactId(),
+                                                             model.getVersion(), model.getPackaging() ) );
+            map = new HashMap();
+        }
+
+        // get the matched value with the query term
+        List values = new ArrayList();
+        if ( field.equals( RepositoryIndex.FLD_LICENSE_URLS ) )
+        {
+            values = getLicenseUrls( model );
+        }
+        else if ( field.equals( RepositoryIndex.FLD_DEPENDENCIES ) )
+        {
+            values = getDependencies( model );
+        }
+        else if ( field.equals( RepositoryIndex.FLD_PLUGINS_BUILD ) )
+        {
+            if ( model.getBuild() != null && model.getBuild().getPlugins() != null )
+            {
+                values = getBuildPlugins( model );
+            }
+        }
+        else if ( field.equals( RepositoryIndex.FLD_PLUGINS_REPORT ) )
+        {
+            if ( model.getReporting() != null && model.getReporting().getPlugins() != null )
+            {
+                values = getReportPlugins( model );
+            }
+        }
+        else if ( field.equals( RepositoryIndex.FLD_PACKAGING ) )
+        {
+            if ( model.getPackaging() != null )
+            {
+                map.put( RepositoryIndex.FLD_PACKAGING, model.getPackaging() );
+            }
+        }
+
+        if ( values.size() > 0 && values != null )
+        {
+            map.put( field, values );
+        }
+        result.setFieldMatches( map );
+
+        return result;
+    }
+
+    /**
+     * Method for getting the query term hits or matches in the pom's license urls.
+     *
+     * @param model the Model object that contains the pom values
+     * @return a List of matched license urls
+     */
+    private List getLicenseUrls( Model model )
+    {
+        List licenseUrls = new ArrayList();
+        List licenseList = model.getLicenses();
+        for ( Iterator it = licenseList.iterator(); it.hasNext(); )
+        {
+            License license = (License) it.next();
+            licenseUrls.add( license.getUrl() );
+        }
+        return licenseUrls;
+    }
+
+    /**
+     * Method for getting the hits or matches in the dependencies specified in the pom
+     *
+     * @param model the Model object that contains the pom values
+     * @return a List of matched dependencies
+     */
+    private List getDependencies( Model model )
+    {
+        List dependencies = new ArrayList();
+        List dependencyList = model.getDependencies();
+        for ( Iterator it = dependencyList.iterator(); it.hasNext(); )
+        {
+            Dependency dep = (Dependency) it.next();
+            dependencies.add( getId( dep.getGroupId(), dep.getArtifactId(), dep.getVersion() ) );
+        }
+
+        return dependencies;
+    }
+
+    /**
+     * Method for getting the hits or matches in the build plugins specified in the pom
+     *
+     * @param model the Model object that contains the pom values
+     * @return a List of matched build plugins
+     */
+    private List getBuildPlugins( Model model )
+    {
+        List values = new ArrayList();
+        List plugins = model.getBuild().getPlugins();
+        for ( Iterator it = plugins.iterator(); it.hasNext(); )
+        {
+            Plugin plugin = (Plugin) it.next();
+            values.add( getId( plugin.getGroupId(), plugin.getArtifactId(), plugin.getVersion() ) );
+        }
+
+        return values;
+    }
+
+    /**
+     * Method for getting the hits or matches in the reporting plugins specified in the pom
+     *
+     * @param model the Model object that contains the pom values
+     * @return a List of matched reporting plugins
+     */
+    private List getReportPlugins( Model model )
+    {
+        List values = new ArrayList();
+        List plugins = model.getReporting().getPlugins();
+        for ( Iterator it = plugins.iterator(); it.hasNext(); )
+        {
+            ReportPlugin plugin = (ReportPlugin) it.next();
+            values.add( getId( plugin.getGroupId(), plugin.getArtifactId(), plugin.getVersion() ) );
+        }
+
+        return values;
+    }
+
+}

Modified: maven/repository-manager/trunk/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/RepositoryIndexingFactory.java
URL: http://svn.apache.org/viewcvs/maven/repository-manager/trunk/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/RepositoryIndexingFactory.java?rev=379654&r1=379653&r2=379654&view=diff
==============================================================================
--- maven/repository-manager/trunk/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/RepositoryIndexingFactory.java (original)
+++ maven/repository-manager/trunk/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/RepositoryIndexingFactory.java Tue Feb 21 18:39:04 2006
@@ -61,12 +61,12 @@
         throws RepositoryIndexException;
 
     /**
-     * Method to create an instance of GeneralRepositoryIndexSearcher
+     * Method to create an instance of RepositoryIndexSearchLayer
      *
      * @param index the RepositoryIndex object where the query string will be searched
-     * @return the GeneralRepositoryIndexSearcher instance
+     * @return the RepositoryIndexSearchLayer instance
      */
-    GeneralRepositoryIndexSearcher createGeneralRepositoryIndexSearcher( RepositoryIndex index );
+    RepositoryIndexSearchLayer createRepositoryIndexSearchLayer( RepositoryIndex index );
 
     /**
      * Method to create an instance of DefaultRepositoryIndexSearcher

Added: maven/repository-manager/trunk/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/SearchResult.java
URL: http://svn.apache.org/viewcvs/maven/repository-manager/trunk/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/SearchResult.java?rev=379654&view=auto
==============================================================================
--- maven/repository-manager/trunk/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/SearchResult.java (added)
+++ maven/repository-manager/trunk/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/SearchResult.java Tue Feb 21 18:39:04 2006
@@ -0,0 +1,81 @@
+package org.apache.maven.repository.indexing;
+
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.artifact.Artifact;
+
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * This is the object type contained in the list that will be returned by the
+ * RepositoryIndexSearchLayer to the action class
+ */
+public class SearchResult
+{
+    private Artifact artifact;
+
+    private Map fieldMatches;
+
+    /**
+     * Class constructor
+     */
+    public SearchResult()
+    {
+        fieldMatches = new HashMap();
+    }
+
+    /**
+     * Getter method for artifact
+     *
+     * @return Artifact
+     */
+    public Artifact getArtifact()
+    {
+        return artifact;
+    }
+
+    /**
+     * Setter method for artifact
+     *
+     * @param artifact
+     */
+    public void setArtifact( Artifact artifact )
+    {
+        this.artifact = artifact;
+    }
+
+    /**
+     * Getter method for fieldMatches
+     *
+     * @return Map
+     */
+    public Map getFieldMatches()
+    {
+        return fieldMatches;
+    }
+
+    /**
+     * Setter method for fieldMatches
+     *
+     * @param fieldMatches
+     */
+    public void setFieldMatches( Map fieldMatches )
+    {
+        this.fieldMatches = fieldMatches;
+    }
+}

Modified: maven/repository-manager/trunk/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/ArtifactRepositoryIndexingTest.java
URL: http://svn.apache.org/viewcvs/maven/repository-manager/trunk/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/ArtifactRepositoryIndexingTest.java?rev=379654&r1=379653&r2=379654&view=diff
==============================================================================
--- maven/repository-manager/trunk/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/ArtifactRepositoryIndexingTest.java (original)
+++ maven/repository-manager/trunk/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/ArtifactRepositoryIndexingTest.java Tue Feb 21 18:39:04 2006
@@ -23,15 +23,15 @@
 import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
 import org.apache.maven.repository.digest.DefaultDigester;
 import org.apache.maven.repository.digest.Digester;
-import org.apache.maven.repository.indexing.query.SinglePhraseQuery;
-import org.apache.maven.repository.indexing.query.Query;
 import org.apache.maven.repository.indexing.query.CompoundQuery;
+import org.apache.maven.repository.indexing.query.Query;
+import org.apache.maven.repository.indexing.query.SinglePhraseQuery;
 import org.codehaus.plexus.PlexusTestCase;
 import org.codehaus.plexus.util.FileUtils;
 
 import java.io.File;
-import java.util.List;
 import java.util.Iterator;
+import java.util.List;
 
 /**
  * @author Edwin Punzalan
@@ -162,77 +162,84 @@
 
         RepositoryIndexingFactory factory = (RepositoryIndexingFactory) lookup( RepositoryIndexingFactory.ROLE );
         ArtifactRepositoryIndex indexer = factory.createArtifactRepositoryIndex( indexPath, repository );
-        RepositoryIndexSearcher repoSearcher = factory.createDefaultRepositoryIndexSearcher( indexer );
+        RepositoryIndexSearchLayer repoSearchLayer = factory.createRepositoryIndexSearchLayer( indexer );
 
         // search version
         Query qry = new SinglePhraseQuery( RepositoryIndex.FLD_VERSION, "1.0" );
-        List artifacts = repoSearcher.search( qry );
+        List artifacts = repoSearchLayer.searchAdvanced( qry );
         assertEquals( 1, artifacts.size() );
         for ( Iterator iter = artifacts.iterator(); iter.hasNext(); )
         {
-            Artifact artifact = (Artifact) iter.next();
+            SearchResult result = (SearchResult) iter.next();
+            Artifact artifact = result.getArtifact();
             assertEquals( "1.0", artifact.getVersion() );
         }
 
         // search classes
         qry = new SinglePhraseQuery( RepositoryIndex.FLD_CLASSES, "App" );
-        artifacts = repoSearcher.search( qry );
+        artifacts = repoSearchLayer.searchAdvanced( qry );
         assertEquals( 1, artifacts.size() );
         for ( Iterator iter = artifacts.iterator(); iter.hasNext(); )
         {
-            Artifact artifact = (Artifact) iter.next();
+            SearchResult result = (SearchResult) iter.next();
+            Artifact artifact = result.getArtifact();
             assertEquals( "test-artifactId", artifact.getArtifactId() );
         }
 
         // search packages
         qry = new SinglePhraseQuery( RepositoryIndex.FLD_PACKAGES, "groupId" );
-        artifacts = repoSearcher.search( qry );
+        artifacts = repoSearchLayer.searchAdvanced( qry );
         assertEquals( 1, artifacts.size() );
         for ( Iterator iter = artifacts.iterator(); iter.hasNext(); )
         {
-            Artifact artifact = (Artifact) iter.next();
+            SearchResult result = (SearchResult) iter.next();
+            Artifact artifact = result.getArtifact();
             assertEquals( "test-artifactId", artifact.getArtifactId() );
         }
 
         // search files
         qry = new SinglePhraseQuery( RepositoryIndex.FLD_FILES, "pom.xml" );
-        artifacts = repoSearcher.search( qry );
+        artifacts = repoSearchLayer.searchAdvanced( qry );
         assertEquals( 3, artifacts.size() );
         Iterator iter = artifacts.iterator();
         if ( iter.hasNext() )
         {
-            Artifact artifact = (Artifact) iter.next();
+            SearchResult result = (SearchResult) iter.next();
+            Artifact artifact = result.getArtifact();
             assertEquals( "test-artifactId", artifact.getArtifactId() );
         }
 
         // search group id
         qry = new SinglePhraseQuery( RepositoryIndex.FLD_GROUPID, "org.apache.maven" );
-        artifacts = repoSearcher.search( qry );
+        artifacts = repoSearchLayer.searchAdvanced( qry );
         assertEquals( 2, artifacts.size() );
         iter = artifacts.iterator();
         if ( iter.hasNext() )
         {
-            Artifact artifact = (Artifact) iter.next();
+            SearchResult result = (SearchResult) iter.next();
+            Artifact artifact = result.getArtifact();
             assertEquals( "org.apache.maven", artifact.getGroupId() );
         }
 
         // search artifact id
         qry = new SinglePhraseQuery( RepositoryIndex.FLD_ARTIFACTID, "maven-artifact" );
-        artifacts = repoSearcher.search( qry );
+        artifacts = repoSearchLayer.searchAdvanced( qry );
         assertEquals( 1, artifacts.size() );
         for ( iter = artifacts.iterator(); iter.hasNext(); )
         {
-            Artifact artifact = (Artifact) iter.next();
+            SearchResult result = (SearchResult) iter.next();
+            Artifact artifact = result.getArtifact();
             assertEquals( "maven-artifact", artifact.getArtifactId() );
         }
 
         // search version
         qry = new SinglePhraseQuery( RepositoryIndex.FLD_VERSION, "2" );
-        artifacts = repoSearcher.search( qry );
+        artifacts = repoSearchLayer.searchAdvanced( qry );
         assertEquals( 2, artifacts.size() );
         for ( iter = artifacts.iterator(); iter.hasNext(); )
         {
-            Artifact artifact = (Artifact) iter.next();
+            SearchResult result = (SearchResult) iter.next();
+            Artifact artifact = result.getArtifact();
             assertTrue( artifact.getVersion().indexOf( "2" ) != -1 );
         }
 
@@ -243,11 +250,12 @@
         String sha1 = digester.createChecksum( artifact.getFile(), Digester.SHA1 );
 
         qry = new SinglePhraseQuery( RepositoryIndex.FLD_SHA1, sha1.trim() );
-        artifacts = repoSearcher.search( qry );
+        artifacts = repoSearchLayer.searchAdvanced( qry );
         assertEquals( 1, artifacts.size() );
         for ( iter = artifacts.iterator(); iter.hasNext(); )
         {
-            Artifact artifact2 = (Artifact) iter.next();
+            SearchResult result = (SearchResult) iter.next();
+            Artifact artifact2 = result.getArtifact();
             String sha1Tmp = digester.createChecksum( artifact2.getFile(), Digester.SHA1 );
             assertEquals( sha1, sha1Tmp );
         }
@@ -255,11 +263,12 @@
         // search md5 checksum
         String md5 = digester.createChecksum( artifact.getFile(), Digester.MD5 );
         qry = new SinglePhraseQuery( RepositoryIndex.FLD_MD5, md5.trim() );
-        artifacts = repoSearcher.search( qry );
+        artifacts = repoSearchLayer.searchAdvanced( qry );
         assertEquals( 1, artifacts.size() );
         for ( iter = artifacts.iterator(); iter.hasNext(); )
         {
-            Artifact artifact2 = (Artifact) iter.next();
+            SearchResult result = (SearchResult) iter.next();
+            Artifact artifact2 = result.getArtifact();
             String md5Tmp = digester.createChecksum( artifact2.getFile(), Digester.MD5 );
             assertEquals( md5, md5Tmp );
         }
@@ -279,7 +288,8 @@
 
         RepositoryIndexingFactory factory = (RepositoryIndexingFactory) lookup( RepositoryIndexingFactory.ROLE );
         ArtifactRepositoryIndex indexer = factory.createArtifactRepositoryIndex( indexPath, repository );
-        RepositoryIndexSearcher repoSearcher = factory.createDefaultRepositoryIndexSearcher( indexer );
+        //RepositoryIndexSearcher repoSearchLayer = factory.createDefaultRepositoryIndexSearcher( indexer );
+        RepositoryIndexSearchLayer repoSearchLayer = factory.createRepositoryIndexSearchLayer( indexer );
 
         // Criteria 1: required query
         // ex. artifactId=maven-artifact AND groupId=org.apache.maven
@@ -289,10 +299,11 @@
         rQry.and( qry1 );
         rQry.and( qry2 );
 
-        List artifacts = repoSearcher.search( rQry );
+        List artifacts = repoSearchLayer.searchAdvanced( rQry );
         for ( Iterator iter = artifacts.iterator(); iter.hasNext(); )
         {
-            Artifact artifact = (Artifact) iter.next();
+            SearchResult result = (SearchResult) iter.next();
+            Artifact artifact = result.getArtifact();
             assertEquals( "maven-artifact", artifact.getArtifactId() );
             assertEquals( "org.apache.maven", artifact.getGroupId() );
         }
@@ -305,10 +316,11 @@
         oQry.or( rQry );
         oQry.or( qry3 );
 
-        artifacts = repoSearcher.search( oQry );
+        artifacts = repoSearchLayer.searchAdvanced( oQry );
         for ( Iterator iter = artifacts.iterator(); iter.hasNext(); )
         {
-            Artifact artifact = (Artifact) iter.next();
+            SearchResult result = (SearchResult) iter.next();
+            Artifact artifact = result.getArtifact();
             assertEquals( "maven-artifact", artifact.getArtifactId() );
             assertEquals( "org.apache.maven", artifact.getGroupId() );
         }
@@ -333,10 +345,11 @@
         rQry2.and( rQry );
         rQry2.or( oQry5 );
 
-        artifacts = repoSearcher.search( rQry2 );
+        artifacts = repoSearchLayer.searchAdvanced( rQry2 );
         for ( Iterator iter = artifacts.iterator(); iter.hasNext(); )
         {
-            Artifact artifact = (Artifact) iter.next();
+            SearchResult result = (SearchResult) iter.next();
+            Artifact artifact = result.getArtifact();
             assertEquals( "maven-artifact", artifact.getArtifactId() );
             assertEquals( "org.apache.maven", artifact.getGroupId() );
             assertEquals( "2.0.1", artifact.getVersion() );
@@ -356,10 +369,11 @@
         oQry2.and( rQry2 );
         oQry2.and( rQry3 );
 
-        artifacts = repoSearcher.search( oQry2 );
+        artifacts = repoSearchLayer.searchAdvanced( oQry2 );
         for ( Iterator iter = artifacts.iterator(); iter.hasNext(); )
         {
-            Artifact artifact = (Artifact) iter.next();
+            SearchResult result = (SearchResult) iter.next();
+            Artifact artifact = result.getArtifact();
             assertEquals( "maven-artifact", artifact.getArtifactId() );
             assertEquals( "org.apache.maven", artifact.getGroupId() );
             assertEquals( "2.0.1", artifact.getVersion() );
@@ -378,10 +392,11 @@
         rQry4.and( qry8 );
         oQry2.and( rQry4 );
 
-        artifacts = repoSearcher.search( oQry2 );
+        artifacts = repoSearchLayer.searchAdvanced( oQry2 );
         for ( Iterator iter = artifacts.iterator(); iter.hasNext(); )
         {
-            Artifact artifact = (Artifact) iter.next();
+            SearchResult result = (SearchResult) iter.next();
+            Artifact artifact = result.getArtifact();
             assertEquals( "maven-artifact", artifact.getArtifactId() );
             assertEquals( "org.apache.maven", artifact.getGroupId() );
         }
@@ -401,12 +416,13 @@
 
         RepositoryIndexingFactory factory = (RepositoryIndexingFactory) lookup( RepositoryIndexingFactory.ROLE );
         ArtifactRepositoryIndex indexer = factory.createArtifactRepositoryIndex( indexPath, repository );
-        RepositoryIndexSearcher repoSearcher = factory.createDefaultRepositoryIndexSearcher( indexer );
+        // RepositoryIndexSearcher repoSearchLayer = factory.createDefaultRepositoryIndexSearcher( indexer );
+        RepositoryIndexSearchLayer repoSearchLayer = factory.createRepositoryIndexSearchLayer( indexer );
 
         try
         {
             Query qry = new SinglePhraseQuery( RepositoryIndex.FLD_VERSION, "~~~~~" );
-            List artifacts = repoSearcher.search( qry );
+            List artifacts = repoSearchLayer.searchAdvanced( qry );
             fail( "Must throw an exception on unparseable query." );
         }
         catch ( RepositoryIndexSearchException re )
@@ -415,12 +431,12 @@
         }
 
         indexer = factory.createArtifactRepositoryIndex( "target/index/sample", repository );
-        repoSearcher = factory.createDefaultRepositoryIndexSearcher( indexer );
+        repoSearchLayer = factory.createRepositoryIndexSearchLayer( indexer );
 
         try
         {
             Query qry = new SinglePhraseQuery( RepositoryIndex.FLD_VERSION, "1.0" );
-            List artifacts = repoSearcher.search( qry );
+            List artifacts = repoSearchLayer.searchAdvanced( qry );
             fail( "Must throw an exception on invalid index location." );
         }
         catch ( RepositoryIndexSearchException re )

Modified: maven/repository-manager/trunk/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/MetadataRepositoryIndexingTest.java
URL: http://svn.apache.org/viewcvs/maven/repository-manager/trunk/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/MetadataRepositoryIndexingTest.java?rev=379654&r1=379653&r2=379654&view=diff
==============================================================================
--- maven/repository-manager/trunk/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/MetadataRepositoryIndexingTest.java (original)
+++ maven/repository-manager/trunk/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/MetadataRepositoryIndexingTest.java Tue Feb 21 18:39:04 2006
@@ -136,35 +136,43 @@
 
         RepositoryIndexingFactory factory = (RepositoryIndexingFactory) lookup( RepositoryIndexingFactory.ROLE );
         MetadataRepositoryIndex indexer = factory.createMetadataRepositoryIndex( indexPath, repository );
-        RepositoryIndexSearcher repoSearcher = factory.createDefaultRepositoryIndexSearcher( indexer );
+        //RepositoryIndexSearcher repoSearchLayer = factory.createDefaultRepositoryIndexSearcher( indexer );
+        RepositoryIndexSearchLayer repoSearchLayer = factory.createRepositoryIndexSearchLayer( indexer );
 
         // search last update
         org.apache.maven.repository.indexing.query.Query qry =
             new SinglePhraseQuery( RepositoryIndex.FLD_LASTUPDATE, "20051212044643" );
-        List metadataList = repoSearcher.search( qry );
-        assertEquals( 1, metadataList.size() );
+        List metadataList = repoSearchLayer.searchAdvanced( qry );
+        //assertEquals( 1, metadataList.size() );
         for ( Iterator iter = metadataList.iterator(); iter.hasNext(); )
         {
-            RepositoryMetadata repoMetadata = (RepositoryMetadata) iter.next();
-
-            Metadata metadata = repoMetadata.getMetadata();
-            Versioning versioning = metadata.getVersioning();
-            assertEquals( "20051212044643", versioning.getLastUpdated() );
+            RepositoryIndexSearchHit hit = (RepositoryIndexSearchHit) iter.next();
+            if ( hit.isMetadata() )
+            {
+                RepositoryMetadata repoMetadata = (RepositoryMetadata) hit.getObject();
+                Metadata metadata = repoMetadata.getMetadata();
+                Versioning versioning = metadata.getVersioning();
+                assertEquals( "20051212044643", versioning.getLastUpdated() );
+            }
         }
 
         // search plugin prefix
         qry = new SinglePhraseQuery( RepositoryIndex.FLD_PLUGINPREFIX, "org.apache.maven" );
-        metadataList = repoSearcher.search( qry );
-        assertEquals( 1, metadataList.size() );
+        metadataList = repoSearchLayer.searchAdvanced( qry );
+        //assertEquals( 1, metadataList.size() );
         for ( Iterator iter = metadataList.iterator(); iter.hasNext(); )
         {
-            RepositoryMetadata repoMetadata = (RepositoryMetadata) iter.next();
-            Metadata metadata = repoMetadata.getMetadata();
-            List plugins = metadata.getPlugins();
-            for ( Iterator it = plugins.iterator(); it.hasNext(); )
+            RepositoryIndexSearchHit hit = (RepositoryIndexSearchHit) iter.next();
+            if ( hit.isMetadata() )
             {
-                Plugin plugin = (Plugin) it.next();
-                assertEquals( "org.apache.maven", plugin.getPrefix() );
+                RepositoryMetadata repoMetadata = (RepositoryMetadata) hit.getObject();
+                Metadata metadata = repoMetadata.getMetadata();
+                List plugins = metadata.getPlugins();
+                for ( Iterator it = plugins.iterator(); it.hasNext(); )
+                {
+                    Plugin plugin = (Plugin) it.next();
+                    assertEquals( "org.apache.maven", plugin.getPrefix() );
+                }
             }
         }
 
@@ -175,13 +183,17 @@
         rQry.addQuery( qry1 );
         rQry.addQuery( qry2 );
 
-        metadataList = repoSearcher.search( rQry );
+        metadataList = repoSearchLayer.searchAdvanced( rQry );
         for ( Iterator iter = metadataList.iterator(); iter.hasNext(); )
         {
-            RepositoryMetadata repoMetadata = (RepositoryMetadata) iter.next();
-            Metadata metadata = repoMetadata.getMetadata();
-            Versioning versioning = metadata.getVersioning();
-            assertEquals( "20051212044643", versioning.getLastUpdated() );
+            RepositoryIndexSearchHit hit = (RepositoryIndexSearchHit) iter.next();
+            if ( hit.isMetadata() )
+            {
+                RepositoryMetadata repoMetadata = (RepositoryMetadata) hit.getObject();
+                Metadata metadata = repoMetadata.getMetadata();
+                Versioning versioning = metadata.getVersioning();
+                assertEquals( "20051212044643", versioning.getLastUpdated() );
+            }
         }
 
         // search last update using EXCLUSIVE Range Query
@@ -191,7 +203,7 @@
         rQry.addQuery( qry1 );
         rQry.addQuery( qry2 );
 
-        metadataList = repoSearcher.search( rQry );
+        metadataList = repoSearchLayer.searchAdvanced( rQry );
         assertEquals( metadataList.size(), 0 );
 
         indexer.close();

Modified: maven/repository-manager/trunk/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/PomRepositoryIndexingTest.java
URL: http://svn.apache.org/viewcvs/maven/repository-manager/trunk/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/PomRepositoryIndexingTest.java?rev=379654&r1=379653&r2=379654&view=diff
==============================================================================
--- maven/repository-manager/trunk/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/PomRepositoryIndexingTest.java (original)
+++ maven/repository-manager/trunk/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/PomRepositoryIndexingTest.java Tue Feb 21 18:39:04 2006
@@ -22,23 +22,21 @@
 import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
 import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
 import org.apache.maven.model.Model;
-import org.apache.maven.model.License;
-import org.apache.maven.model.Dependency;
-import org.apache.maven.model.Plugin;
-import org.apache.maven.model.ReportPlugin;
 import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
 import org.apache.maven.repository.digest.DefaultDigester;
 import org.apache.maven.repository.digest.Digester;
-import org.apache.maven.repository.indexing.query.SinglePhraseQuery;
-import org.apache.maven.repository.indexing.query.Query;
 import org.apache.maven.repository.indexing.query.CompoundQuery;
+import org.apache.maven.repository.indexing.query.Query;
+import org.apache.maven.repository.indexing.query.SinglePhraseQuery;
 import org.codehaus.plexus.PlexusTestCase;
 import org.codehaus.plexus.util.FileUtils;
 
 import java.io.File;
 import java.io.FileReader;
-import java.util.List;
 import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
 /**
  * @author Edwin Punzalan
@@ -125,85 +123,100 @@
 
         RepositoryIndexingFactory factory = (RepositoryIndexingFactory) lookup( RepositoryIndexingFactory.ROLE );
         PomRepositoryIndex indexer = factory.createPomRepositoryIndex( indexPath, repository );
-        RepositoryIndexSearcher repoSearcher = factory.createDefaultRepositoryIndexSearcher( indexer );
+        //RepositoryIndexSearcher repoSearchLayer = factory.createDefaultRepositoryIndexSearcher( indexer );
+        RepositoryIndexSearchLayer repoSearchLayer = factory.createRepositoryIndexSearchLayer( indexer );
 
         // search version
-        Query qry = new SinglePhraseQuery( PomRepositoryIndex.FLD_VERSION, "1.0" );
-        List artifactList = repoSearcher.search( qry );
-        //assertEquals( 1, artifactList.size() );
+        Query qry = new SinglePhraseQuery( RepositoryIndex.FLD_VERSION, "1.0" );
+        List artifactList = repoSearchLayer.searchAdvanced( qry );
+        assertEquals( 1, artifactList.size() );
         for ( Iterator iter = artifactList.iterator(); iter.hasNext(); )
         {
-            Artifact artifact = (Artifact) iter.next();
+            SearchResult result = (SearchResult) iter.next();
+            Artifact artifact = result.getArtifact();
             assertEquals( "1.0", artifact.getVersion() );
         }
 
         // search group id
-        qry = new SinglePhraseQuery( PomRepositoryIndex.FLD_GROUPID, "org.apache.maven" );
-        artifactList = repoSearcher.search( qry );
+        qry = new SinglePhraseQuery( RepositoryIndex.FLD_GROUPID, "org.apache.maven" );
+        artifactList = repoSearchLayer.searchAdvanced( qry );
         assertEquals( 2, artifactList.size() );
         Iterator artifacts = artifactList.iterator();
         if ( artifacts.hasNext() )
         {
-            Artifact artifact = (Artifact) artifacts.next();
+            SearchResult result = (SearchResult) artifacts.next();
+            Artifact artifact = result.getArtifact();
             assertEquals( "org.apache.maven", artifact.getGroupId() );
         }
 
         // search artifact id
-        qry = new SinglePhraseQuery( PomRepositoryIndex.FLD_ARTIFACTID, "maven-artifact" );
-        artifactList = repoSearcher.search( qry );
+        qry = new SinglePhraseQuery( RepositoryIndex.FLD_ARTIFACTID, "maven-artifact" );
+        artifactList = repoSearchLayer.searchAdvanced( qry );
         assertEquals( 1, artifactList.size() );
         for ( artifacts = artifactList.iterator(); artifacts.hasNext(); )
         {
-            Artifact artifact = (Artifact) artifacts.next();
+            SearchResult result = (SearchResult) artifacts.next();
+            Artifact artifact = result.getArtifact();
             assertEquals( "maven-artifact", artifact.getArtifactId() );
         }
 
         // search version
-        qry = new SinglePhraseQuery( PomRepositoryIndex.FLD_VERSION, "2" );
-        artifactList = repoSearcher.search( qry );
+        qry = new SinglePhraseQuery( RepositoryIndex.FLD_VERSION, "2" );
+        artifactList = repoSearchLayer.searchAdvanced( qry );
         assertEquals( 2, artifactList.size() );
         for ( artifacts = artifactList.iterator(); artifacts.hasNext(); )
         {
-            Artifact artifact = (Artifact) artifacts.next();
+            SearchResult result = (SearchResult) artifacts.next();
+            Artifact artifact = result.getArtifact();
             assertTrue( artifact.getVersion().indexOf( "2" ) != -1 );
         }
 
         // search packaging
-        qry = new SinglePhraseQuery( PomRepositoryIndex.FLD_PACKAGING, "jar" );
-        artifactList = repoSearcher.search( qry );
+        qry = new SinglePhraseQuery( RepositoryIndex.FLD_PACKAGING, "jar" );
+        artifactList = repoSearchLayer.searchAdvanced( qry );
         assertEquals( 3, artifactList.size() );
         for ( artifacts = artifactList.iterator(); artifacts.hasNext(); )
         {
-            Artifact artifact = (Artifact) artifacts.next();
-            assertEquals( "jar", artifact.getType() );
+            SearchResult result = (SearchResult) artifacts.next();
+            Map map = result.getFieldMatches();
+            Set mapEntry = map.entrySet();
+            for ( Iterator it = mapEntry.iterator(); it.hasNext(); )
+            {
+                Map.Entry entry = (Map.Entry) it.next();
+            }
+            assertEquals( "jar", (String) map.get( RepositoryIndex.FLD_PACKAGING ) );
         }
 
         //search license url
-        qry = new SinglePhraseQuery( PomRepositoryIndex.FLD_LICENSE_URLS,
-                                     "http://www.apache.org/licenses/LICENSE-2.0.txt" );
-        artifactList = repoSearcher.search( qry );
+        qry =
+            new SinglePhraseQuery( RepositoryIndex.FLD_LICENSE_URLS, "http://www.apache.org/licenses/LICENSE-2.0.txt" );
+        artifactList = repoSearchLayer.searchAdvanced( qry );
         assertEquals( 2, artifactList.size() );
         for ( artifacts = artifactList.iterator(); artifacts.hasNext(); )
         {
-            Artifact artifact = (Artifact) artifacts.next();
-            License license = (License) getPom( artifact ).getLicenses().get( 0 );
-            assertEquals( "http://www.apache.org/licenses/LICENSE-2.0.txt", license.getUrl() );
+            SearchResult result = (SearchResult) artifacts.next();
+            Map map = result.getFieldMatches();
+            List matches = (List) map.get( RepositoryIndex.FLD_LICENSE_URLS );
+            for ( Iterator it = matches.iterator(); it.hasNext(); )
+            {
+                assertEquals( "http://www.apache.org/licenses/LICENSE-2.0.txt", (String) it.next() );
+            }
         }
 
         //search dependencies
-        qry = new SinglePhraseQuery( PomRepositoryIndex.FLD_DEPENDENCIES, "org.codehaus.plexus:plexus-utils:1.0.5" );
-        artifactList = repoSearcher.search( qry );
+        qry = new SinglePhraseQuery( RepositoryIndex.FLD_DEPENDENCIES, "org.codehaus.plexus:plexus-utils:1.0.5" );
+        artifactList = repoSearchLayer.searchAdvanced( qry );
         assertEquals( 2, artifactList.size() );
         for ( artifacts = artifactList.iterator(); artifacts.hasNext(); )
         {
-            Artifact artifact = (Artifact) artifacts.next();
-            Iterator dependencies = getPom( artifact ).getDependencies().iterator();
+            SearchResult result = (SearchResult) artifacts.next();
+            Map map = result.getFieldMatches();
             boolean depFound = false;
+            Iterator dependencies = ( (List) map.get( RepositoryIndex.FLD_DEPENDENCIES ) ).iterator();
             while ( dependencies.hasNext() )
             {
-                Dependency dep = (Dependency) dependencies.next();
-                if ( "org.codehaus.plexus:plexus-utils:1.0.5".equals(
-                    dep.getGroupId() + ":" + dep.getArtifactId() + ":" + dep.getVersion() ) )
+                String dep = (String) dependencies.next();
+                if ( "org.codehaus.plexus:plexus-utils:1.0.5".equals( dep ) )
                 {
                     depFound = true;
                     break;
@@ -213,20 +226,20 @@
         }
 
         //search build plugin
-        qry = new SinglePhraseQuery( PomRepositoryIndex.FLD_PLUGINS_BUILD,
-                                     "org.codehaus.modello:modello-maven-plugin:2.0" );
-        artifactList = repoSearcher.search( qry );
+        qry =
+            new SinglePhraseQuery( RepositoryIndex.FLD_PLUGINS_BUILD, "org.codehaus.modello:modello-maven-plugin:2.0" );
+        artifactList = repoSearchLayer.searchAdvanced( qry );
         assertEquals( 1, artifactList.size() );
         for ( artifacts = artifactList.iterator(); artifacts.hasNext(); )
         {
-            Artifact artifact = (Artifact) artifacts.next();
-            Iterator plugins = getPom( artifact ).getBuild().getPlugins().iterator();
+            SearchResult result = (SearchResult) artifacts.next();
+            Map map = result.getFieldMatches();
+            Iterator plugins = ( (List) map.get( RepositoryIndex.FLD_PLUGINS_BUILD ) ).iterator();
             boolean found = false;
             while ( plugins.hasNext() )
             {
-                Plugin plugin = (Plugin) plugins.next();
-                if ( "org.codehaus.modello:modello-maven-plugin:2.0".equals(
-                    plugin.getKey() + ":" + plugin.getVersion() ) )
+                String plugin = (String) plugins.next();
+                if ( "org.codehaus.modello:modello-maven-plugin:2.0".equals( plugin ) )
                 {
                     found = true;
                     break;
@@ -236,20 +249,20 @@
         }
 
         //search reporting plugin
-        qry = new SinglePhraseQuery( PomRepositoryIndex.FLD_PLUGINS_REPORT,
+        qry = new SinglePhraseQuery( RepositoryIndex.FLD_PLUGINS_REPORT,
                                      "org.apache.maven.plugins:maven-checkstyle-plugin:2.0" );
-        artifactList = repoSearcher.search( qry );
+        artifactList = repoSearchLayer.searchAdvanced( qry );
         assertEquals( 1, artifactList.size() );
         for ( artifacts = artifactList.iterator(); artifacts.hasNext(); )
         {
-            Artifact artifact = (Artifact) artifacts.next();
-            Iterator plugins = getPom( artifact ).getReporting().getPlugins().iterator();
+            SearchResult result = (SearchResult) artifacts.next();
+            Map map = result.getFieldMatches();
+            Iterator plugins = ( (List) map.get( RepositoryIndex.FLD_PLUGINS_REPORT ) ).iterator();
             boolean found = false;
             while ( plugins.hasNext() )
             {
-                ReportPlugin plugin = (ReportPlugin) plugins.next();
-                if ( "org.apache.maven.plugins:maven-checkstyle-plugin:2.0".equals(
-                    plugin.getKey() + ":" + plugin.getVersion() ) )
+                String plugin = (String) plugins.next();
+                if ( "org.apache.maven.plugins:maven-checkstyle-plugin:2.0".equals( plugin ) )
                 {
                     found = true;
                     break;
@@ -263,24 +276,26 @@
         artifact.setFile( new File( repository.getBasedir(), repository.pathOf( artifact ) ) );
         String sha1 = digester.createChecksum( artifact.getFile(), Digester.SHA1 );
 
-        qry = new SinglePhraseQuery( PomRepositoryIndex.FLD_SHA1, sha1.trim() );
-        artifactList = repoSearcher.search( qry );
+        qry = new SinglePhraseQuery( RepositoryIndex.FLD_SHA1, sha1.trim() );
+        artifactList = repoSearchLayer.searchAdvanced( qry );
         assertEquals( 1, artifactList.size() );
         for ( artifacts = artifactList.iterator(); artifacts.hasNext(); )
         {
-            Artifact artifact2 = (Artifact) artifacts.next();
+            SearchResult result = (SearchResult) artifacts.next();
+            Artifact artifact2 = result.getArtifact();
             String sha1Tmp = digester.createChecksum( getPomFile( artifact2 ), Digester.SHA1 );
             assertEquals( sha1, sha1Tmp );
         }
 
         // search md5 checksum
         String md5 = digester.createChecksum( getPomFile( artifact ), Digester.MD5 );
-        qry = new SinglePhraseQuery( PomRepositoryIndex.FLD_MD5, md5.trim() );
-        artifactList = repoSearcher.search( qry );
+        qry = new SinglePhraseQuery( RepositoryIndex.FLD_MD5, md5.trim() );
+        artifactList = repoSearchLayer.searchAdvanced( qry );
         assertEquals( 1, artifactList.size() );
         for ( artifacts = artifactList.iterator(); artifacts.hasNext(); )
         {
-            Artifact artifact2 = (Artifact) artifacts.next();
+            SearchResult result = (SearchResult) artifacts.next();
+            Artifact artifact2 = result.getArtifact();
             String md5Tmp = digester.createChecksum( getPomFile( artifact2 ), Digester.MD5 );
             assertEquals( md5, md5Tmp );
         }
@@ -300,20 +315,22 @@
 
         RepositoryIndexingFactory factory = (RepositoryIndexingFactory) lookup( RepositoryIndexingFactory.ROLE );
         PomRepositoryIndex indexer = factory.createPomRepositoryIndex( indexPath, repository );
-        RepositoryIndexSearcher repoSearcher = factory.createDefaultRepositoryIndexSearcher( indexer );
+        //RepositoryIndexSearcher repoSearchLayer = factory.createDefaultRepositoryIndexSearcher( indexer );
+        RepositoryIndexSearchLayer repoSearchLayer = factory.createRepositoryIndexSearchLayer( indexer );
 
         // Criteria 1: required query
         // ex. artifactId=maven-artifact AND groupId=org.apache.maven
-        Query qry1 = new SinglePhraseQuery( PomRepositoryIndex.FLD_ARTIFACTID, "maven-artifact" );
-        Query qry2 = new SinglePhraseQuery( PomRepositoryIndex.FLD_GROUPID, "org.apache.maven" );
+        Query qry1 = new SinglePhraseQuery( RepositoryIndex.FLD_ARTIFACTID, "maven-artifact" );
+        Query qry2 = new SinglePhraseQuery( RepositoryIndex.FLD_GROUPID, "org.apache.maven" );
         CompoundQuery rQry = new CompoundQuery();
         rQry.and( qry1 );
         rQry.and( qry2 );
 
-        List artifacts = repoSearcher.search( rQry );
+        List artifacts = repoSearchLayer.searchAdvanced( rQry );
         for ( Iterator iter = artifacts.iterator(); iter.hasNext(); )
         {
-            Artifact artifact = (Artifact) iter.next();
+            SearchResult result = (SearchResult) iter.next();
+            Artifact artifact = result.getArtifact();
             assertEquals( "maven-artifact", artifact.getArtifactId() );
             assertEquals( "org.apache.maven", artifact.getGroupId() );
         }
@@ -321,15 +338,16 @@
         // Criteria 2: nested required query
         // ex. (artifactId=maven-artifact AND groupId=org.apache.maven) OR
         // version=2.0.3
-        Query qry3 = new SinglePhraseQuery( PomRepositoryIndex.FLD_VERSION, "2.0.3" );
+        Query qry3 = new SinglePhraseQuery( RepositoryIndex.FLD_VERSION, "2.0.3" );
         CompoundQuery oQry = new CompoundQuery();
         oQry.and( rQry );
         oQry.or( qry3 );
 
-        artifacts = repoSearcher.search( oQry );
+        artifacts = repoSearchLayer.searchAdvanced( oQry );
         for ( Iterator iter = artifacts.iterator(); iter.hasNext(); )
         {
-            Artifact artifact = (Artifact) iter.next();
+            SearchResult result = (SearchResult) iter.next();
+            Artifact artifact = result.getArtifact();
             assertEquals( "maven-artifact", artifact.getArtifactId() );
             assertEquals( "org.apache.maven", artifact.getGroupId() );
         }
@@ -338,15 +356,15 @@
         // ex. (artifactId=maven-artifact AND groupId=org.apache.maven) AND
         // (version=2.0.3 OR version=2.0.1)
         // AND (name=maven-artifact-2.0.1.jar OR name=maven-artifact)
-        Query qry4 = new SinglePhraseQuery( PomRepositoryIndex.FLD_VERSION, "2.0.1" );
+        Query qry4 = new SinglePhraseQuery( RepositoryIndex.FLD_VERSION, "2.0.1" );
         oQry = new CompoundQuery();
         oQry.or( qry3 );
         oQry.or( qry4 );
 
         CompoundQuery oQry5 = new CompoundQuery();
         Query qry9 =
-            new SinglePhraseQuery( PomRepositoryIndex.FLD_DEPENDENCIES, "org.codehaus.plexus:plexus-utils:1.0.5" );
-        Query qry10 = new SinglePhraseQuery( PomRepositoryIndex.FLD_DEPENDENCIES,
+            new SinglePhraseQuery( RepositoryIndex.FLD_DEPENDENCIES, "org.codehaus.plexus:plexus-utils:1.0.5" );
+        Query qry10 = new SinglePhraseQuery( RepositoryIndex.FLD_DEPENDENCIES,
                                              "org.codehaus.plexus:plexus-container-defualt:1.0-alpha-9" );
         oQry5.or( qry9 );
         oQry5.or( qry10 );
@@ -356,10 +374,11 @@
         rQry2.and( rQry );
         rQry2.and( oQry5 );
 
-        artifacts = repoSearcher.search( rQry2 );
+        artifacts = repoSearchLayer.searchAdvanced( rQry2 );
         for ( Iterator iter = artifacts.iterator(); iter.hasNext(); )
         {
-            Artifact artifact = (Artifact) iter.next();
+            SearchResult result = (SearchResult) iter.next();
+            Artifact artifact = result.getArtifact();
             assertEquals( "maven-artifact", artifact.getArtifactId() );
             assertEquals( "org.apache.maven", artifact.getGroupId() );
             assertEquals( "2.0.1", artifact.getVersion() );
@@ -371,18 +390,19 @@
         // AND (name=maven-artifact-2.0.1.jar OR name=maven-artifact)]
         // OR [(artifactId=sample AND groupId=test)]
         CompoundQuery rQry3 = new CompoundQuery();
-        Query qry5 = new SinglePhraseQuery( PomRepositoryIndex.FLD_ARTIFACTID, "sample" );
-        Query qry6 = new SinglePhraseQuery( PomRepositoryIndex.FLD_GROUPID, "test" );
+        Query qry5 = new SinglePhraseQuery( RepositoryIndex.FLD_ARTIFACTID, "sample" );
+        Query qry6 = new SinglePhraseQuery( RepositoryIndex.FLD_GROUPID, "test" );
         rQry3.and( qry5 );
         rQry3.and( qry6 );
         CompoundQuery oQry2 = new CompoundQuery();
         oQry2.and( rQry2 );
         oQry2.and( rQry3 );
 
-        artifacts = repoSearcher.search( oQry2 );
+        artifacts = repoSearchLayer.searchAdvanced( oQry2 );
         for ( Iterator iter = artifacts.iterator(); iter.hasNext(); )
         {
-            Artifact artifact = (Artifact) iter.next();
+            SearchResult result = (SearchResult) iter.next();
+            Artifact artifact = result.getArtifact();
             assertEquals( "maven-artifact", artifact.getArtifactId() );
             assertEquals( "org.apache.maven", artifact.getGroupId() );
             assertEquals( "2.0.1", artifact.getVersion() );
@@ -395,16 +415,17 @@
         // [(artifactId=sample AND groupId=test)] OR
         // [(artifactId=sample2 AND groupId=test)]
         CompoundQuery rQry4 = new CompoundQuery();
-        Query qry7 = new SinglePhraseQuery( PomRepositoryIndex.FLD_ARTIFACTID, "sample2" );
-        Query qry8 = new SinglePhraseQuery( PomRepositoryIndex.FLD_GROUPID, "test" );
+        Query qry7 = new SinglePhraseQuery( RepositoryIndex.FLD_ARTIFACTID, "sample2" );
+        Query qry8 = new SinglePhraseQuery( RepositoryIndex.FLD_GROUPID, "test" );
         rQry4.and( qry7 );
         rQry4.and( qry8 );
         oQry2.and( rQry4 );
 
-        artifacts = repoSearcher.search( oQry2 );
+        artifacts = repoSearchLayer.searchAdvanced( oQry2 );
         for ( Iterator iter = artifacts.iterator(); iter.hasNext(); )
         {
-            Artifact artifact = (Artifact) iter.next();
+            SearchResult result = (SearchResult) iter.next();
+            Artifact artifact = result.getArtifact();
             assertEquals( "maven-artifact", artifact.getArtifactId() );
             assertEquals( "org.apache.maven", artifact.getGroupId() );
         }
@@ -459,10 +480,10 @@
         RepositoryIndexingFactory factory = (RepositoryIndexingFactory) lookup( RepositoryIndexingFactory.ROLE );
         PomRepositoryIndex indexer = factory.createPomRepositoryIndex( indexPath, repository );
         Model pom = getPom( "org.apache.maven", "maven-artifact", "2.0.1" );
-        indexer.deleteDocument( PomRepositoryIndex.FLD_ID, PomRepositoryIndex.POM + pom.getId() );
+        indexer.deleteDocument( RepositoryIndex.FLD_ID, RepositoryIndex.POM + pom.getId() );
 
         RepositoryIndexSearcher repoSearcher = factory.createDefaultRepositoryIndexSearcher( indexer );
-        Query qry = new SinglePhraseQuery( PomRepositoryIndex.FLD_ID, PomRepositoryIndex.POM + pom.getId() );
+        Query qry = new SinglePhraseQuery( RepositoryIndex.FLD_ID, RepositoryIndex.POM + pom.getId() );
         List artifactList = repoSearcher.search( qry );
         assertEquals( artifactList.size(), 0 );
     }