diff options
author | Olivier Lamy <olamy@apache.org> | 2012-08-24 14:27:05 +0000 |
---|---|---|
committer | Olivier Lamy <olamy@apache.org> | 2012-08-24 14:27:05 +0000 |
commit | 3e02de3e08b8ab6cb9da82f714bbb3eea96f516b (patch) | |
tree | f8b2a6fbd77df33a74fe63fd552a10dc6df772bc /archiva-modules/archiva-base/archiva-indexer | |
parent | b5621624eab7bb3976ef58affdc002aca76b4c44 (diff) | |
download | archiva-3e02de3e08b8ab6cb9da82f714bbb3eea96f516b.tar.gz archiva-3e02de3e08b8ab6cb9da82f714bbb3eea96f516b.zip |
change lucene query to treat user input as scored value and version as exact value
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1376938 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/archiva-base/archiva-indexer')
-rw-r--r-- | archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/NexusRepositorySearch.java | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/NexusRepositorySearch.java b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/NexusRepositorySearch.java index 3d84602ae..527d9f08c 100644 --- a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/NexusRepositorySearch.java +++ b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/NexusRepositorySearch.java @@ -40,7 +40,9 @@ import org.apache.maven.index.OSGI; import org.apache.maven.index.context.IndexCreator; import org.apache.maven.index.context.IndexingContext; import org.apache.maven.index.context.UnsupportedExistingLuceneIndexException; +import org.apache.maven.index.expr.SourcedSearchExpression; import org.apache.maven.index.expr.StringSearchExpression; +import org.apache.maven.index.expr.UserInputSearchExpression; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; @@ -152,95 +154,95 @@ public class NexusRepositorySearch BooleanQuery q = new BooleanQuery(); if ( StringUtils.isNotBlank( searchFields.getGroupId() ) ) { - q.add( indexer.constructQuery( MAVEN.GROUP_ID, new StringSearchExpression( searchFields.getGroupId() ) ), + q.add( indexer.constructQuery( MAVEN.GROUP_ID, new UserInputSearchExpression( searchFields.getGroupId() ) ), Occur.MUST ); } if ( StringUtils.isNotBlank( searchFields.getArtifactId() ) ) { q.add( - indexer.constructQuery( MAVEN.ARTIFACT_ID, new StringSearchExpression( searchFields.getArtifactId() ) ), + indexer.constructQuery( MAVEN.ARTIFACT_ID, new UserInputSearchExpression( searchFields.getArtifactId() ) ), Occur.MUST ); } if ( StringUtils.isNotBlank( searchFields.getVersion() ) ) { - q.add( indexer.constructQuery( MAVEN.VERSION, new StringSearchExpression( searchFields.getVersion() ) ), + q.add( indexer.constructQuery( MAVEN.VERSION, new SourcedSearchExpression( searchFields.getVersion() ) ), Occur.MUST ); } if ( StringUtils.isNotBlank( searchFields.getPackaging() ) ) { - q.add( indexer.constructQuery( MAVEN.PACKAGING, new StringSearchExpression( searchFields.getPackaging() ) ), + q.add( indexer.constructQuery( MAVEN.PACKAGING, new UserInputSearchExpression( searchFields.getPackaging() ) ), Occur.MUST ); } if ( StringUtils.isNotBlank( searchFields.getClassName() ) ) { q.add( - indexer.constructQuery( MAVEN.CLASSNAMES, new StringSearchExpression( searchFields.getClassName() ) ), + indexer.constructQuery( MAVEN.CLASSNAMES, new UserInputSearchExpression( searchFields.getClassName() ) ), Occur.MUST ); } if ( StringUtils.isNotBlank( searchFields.getBundleSymbolicName() ) ) { q.add( indexer.constructQuery( OSGI.SYMBOLIC_NAME, - new StringSearchExpression( searchFields.getBundleSymbolicName() ) ), + new UserInputSearchExpression( searchFields.getBundleSymbolicName() ) ), Occur.MUST ); } if ( StringUtils.isNotBlank( searchFields.getBundleVersion() ) ) { q.add( - indexer.constructQuery( OSGI.VERSION, new StringSearchExpression( searchFields.getBundleVersion() ) ), + indexer.constructQuery( OSGI.VERSION, new UserInputSearchExpression( searchFields.getBundleVersion() ) ), Occur.MUST ); } if ( StringUtils.isNotBlank( searchFields.getBundleExportPackage() ) ) { q.add( indexer.constructQuery( OSGI.EXPORT_PACKAGE, - new StringSearchExpression( searchFields.getBundleExportPackage() ) ), + new UserInputSearchExpression( searchFields.getBundleExportPackage() ) ), Occur.MUST ); } if ( StringUtils.isNotBlank( searchFields.getBundleExportService() ) ) { q.add( indexer.constructQuery( OSGI.EXPORT_SERVICE, - new StringSearchExpression( searchFields.getBundleExportService() ) ), + new UserInputSearchExpression( searchFields.getBundleExportService() ) ), Occur.MUST ); } if ( StringUtils.isNotBlank( searchFields.getBundleImportPackage() ) ) { q.add( indexer.constructQuery( OSGI.IMPORT_PACKAGE, - new StringSearchExpression( searchFields.getBundleImportPackage() ) ), + new UserInputSearchExpression( searchFields.getBundleImportPackage() ) ), Occur.MUST ); } if ( StringUtils.isNotBlank( searchFields.getBundleName() ) ) { - q.add( indexer.constructQuery( OSGI.NAME, new StringSearchExpression( searchFields.getBundleName() ) ), + q.add( indexer.constructQuery( OSGI.NAME, new UserInputSearchExpression( searchFields.getBundleName() ) ), Occur.MUST ); } if ( StringUtils.isNotBlank( searchFields.getBundleImportPackage() ) ) { q.add( indexer.constructQuery( OSGI.IMPORT_PACKAGE, - new StringSearchExpression( searchFields.getBundleImportPackage() ) ), + new UserInputSearchExpression( searchFields.getBundleImportPackage() ) ), Occur.MUST ); } if ( StringUtils.isNotBlank( searchFields.getBundleRequireBundle() ) ) { q.add( indexer.constructQuery( OSGI.REQUIRE_BUNDLE, - new StringSearchExpression( searchFields.getBundleRequireBundle() ) ), + new UserInputSearchExpression( searchFields.getBundleRequireBundle() ) ), Occur.MUST ); } if ( StringUtils.isNotBlank( searchFields.getClassifier() ) ) { q.add( - indexer.constructQuery( MAVEN.CLASSIFIER, new StringSearchExpression( searchFields.getClassifier() ) ), + indexer.constructQuery( MAVEN.CLASSIFIER, new UserInputSearchExpression( searchFields.getClassifier() ) ), Occur.MUST ); } @@ -308,11 +310,11 @@ public class NexusRepositorySearch private void constructQuery( String term, BooleanQuery q ) { - q.add( indexer.constructQuery( MAVEN.GROUP_ID, new StringSearchExpression( term ) ), Occur.SHOULD ); - q.add( indexer.constructQuery( MAVEN.ARTIFACT_ID, new StringSearchExpression( term ) ), Occur.SHOULD ); - q.add( indexer.constructQuery( MAVEN.VERSION, new StringSearchExpression( term ) ), Occur.SHOULD ); - q.add( indexer.constructQuery( MAVEN.PACKAGING, new StringSearchExpression( term ) ), Occur.SHOULD ); - q.add( indexer.constructQuery( MAVEN.CLASSNAMES, new StringSearchExpression( term ) ), Occur.SHOULD ); + q.add( indexer.constructQuery( MAVEN.GROUP_ID, new UserInputSearchExpression( term ) ), Occur.SHOULD ); + q.add( indexer.constructQuery( MAVEN.ARTIFACT_ID, new UserInputSearchExpression( term ) ), Occur.SHOULD ); + q.add( indexer.constructQuery( MAVEN.VERSION, new UserInputSearchExpression( term ) ), Occur.SHOULD ); + q.add( indexer.constructQuery( MAVEN.PACKAGING, new UserInputSearchExpression( term ) ), Occur.SHOULD ); + q.add( indexer.constructQuery( MAVEN.CLASSNAMES, new UserInputSearchExpression( term ) ), Occur.SHOULD ); //Query query = // new WildcardQuery( new Term( MAVEN.CLASSNAMES.getFieldName(), "*" ) ); |