]> source.dussan.org Git - archiva.git/commitdiff
boost artifactid fields
authorJames William Dumay <jdumay@apache.org>
Sat, 13 Dec 2008 07:18:52 +0000 (07:18 +0000)
committerJames William Dumay <jdumay@apache.org>
Sat, 13 Dec 2008 07:18:52 +0000 (07:18 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/archiva-search-improvements@726179 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/filecontent/FileContentConverter.java
archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/LuceneDocumentMaker.java

index 68edf4555ad7775c1149b5d1884541b137706f08..96c8295ddcd9185283fdab35c210fbacb44dc61a 100644 (file)
@@ -54,8 +54,8 @@ public class FileContentConverter
             // Artifact Reference
             doc.addFieldTokenized( ArtifactKeys.GROUPID, filecontent.getArtifact().getGroupId() );
             doc.addFieldExact( ArtifactKeys.GROUPID_EXACT, filecontent.getArtifact().getGroupId() );
-            doc.addFieldTokenized( ArtifactKeys.ARTIFACTID, filecontent.getArtifact().getArtifactId() );
-            doc.addFieldExact( ArtifactKeys.ARTIFACTID_EXACT, filecontent.getArtifact().getArtifactId() );
+            doc.addFieldTokenized( ArtifactKeys.ARTIFACTID, filecontent.getArtifact().getArtifactId(), 1.5f );
+            doc.addFieldExact( ArtifactKeys.ARTIFACTID_EXACT, filecontent.getArtifact().getArtifactId(), 1.5f );
             doc.addFieldTokenized( ArtifactKeys.VERSION, filecontent.getArtifact().getVersion() );
             doc.addFieldExact( ArtifactKeys.VERSION_EXACT, filecontent.getArtifact().getVersion() );
             doc.addFieldTokenized( ArtifactKeys.TYPE, filecontent.getArtifact().getType() );
index 169058be1146d6997f4af81390a464936769e334..347e0e91a2d4879c2509a99a570e867700471802 100644 (file)
@@ -81,6 +81,18 @@ public class LuceneDocumentMaker
         return this;
     }
 
+    public LuceneDocumentMaker addFieldTokenized( String key, String value, float boost )
+    {
+        if ( value != null )
+        {
+            Field field = new Field( key, value, Field.Store.YES, Field.Index.TOKENIZED );
+            field.setBoost(boost);
+            document.add( field );
+        }
+
+        return this;
+    }
+
     public LuceneDocumentMaker addFieldTokenized( String key, List list )
     {
         if ( ( list != null ) && ( !list.isEmpty() ) )
@@ -101,6 +113,18 @@ public class LuceneDocumentMaker
         return this;
     }
 
+    public LuceneDocumentMaker addFieldUntokenized( String name, String value, float boost )
+    {
+        if ( value != null )
+        {
+            Field field = new Field( name, value, Field.Store.YES, Field.Index.UN_TOKENIZED );
+            field.setBoost(boost);
+            document.add( field );
+        }
+
+        return this;
+    }
+
     public LuceneDocumentMaker addFieldExact( String name, String value )
     {
         if ( value != null )
@@ -111,6 +135,18 @@ public class LuceneDocumentMaker
         return this;
     }
 
+    public LuceneDocumentMaker addFieldExact( String name, String value, float boost )
+    {
+        if ( value != null )
+        {
+            Field field = new Field( name, value, Field.Store.NO, Field.Index.UN_TOKENIZED );
+            field.setBoost(boost);
+            document.add( field );
+        }
+
+        return this;
+    }
+
     public Document getDocument()
     {
         return this.document;