From: James William Dumay Date: Sat, 13 Dec 2008 07:18:52 +0000 (+0000) Subject: boost artifactid fields X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=1d3352a6a4939327e96ad3583b43f6cff743e492;p=archiva.git boost artifactid fields git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/archiva-search-improvements@726179 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/filecontent/FileContentConverter.java b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/filecontent/FileContentConverter.java index 68edf4555..96c8295dd 100644 --- a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/filecontent/FileContentConverter.java +++ b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/filecontent/FileContentConverter.java @@ -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() ); diff --git a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/LuceneDocumentMaker.java b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/LuceneDocumentMaker.java index 169058be1..347e0e91a 100644 --- a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/LuceneDocumentMaker.java +++ b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/LuceneDocumentMaker.java @@ -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;