You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2011/08/23 14:51:47 UTC

svn commit: r1160668 [1/3] - in /lucene/dev/branches/flexscoring: lucene/contrib/instantiated/src/java/org/apache/lucene/store/instantiated/ lucene/contrib/memory/src/java/org/apache/lucene/index/memory/ lucene/contrib/misc/src/java/org/apache/lucene/i...

Author: rmuir
Date: Tue Aug 23 12:51:44 2011
New Revision: 1160668

URL: http://svn.apache.org/viewvc?rev=1160668&view=rev
Log:
LUCENE-3386: integrate bm25, lm, tfidf into similarities

Added:
    lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/similarities/DefaultSimilarity.java   (with props)
    lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/similarities/DefaultSimilarityProvider.java   (with props)
    lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/similarities/Similarity.java   (with props)
    lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/similarities/SimilarityProvider.java   (with props)
    lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/similarities/TFIDFSimilarity.java   (with props)
Removed:
    lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/DefaultSimilarity.java
    lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/DefaultSimilarityProvider.java
    lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/Similarity.java
    lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/SimilarityProvider.java
    lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/TFIDFSimilarity.java
Modified:
    lucene/dev/branches/flexscoring/lucene/contrib/instantiated/src/java/org/apache/lucene/store/instantiated/InstantiatedIndexWriter.java
    lucene/dev/branches/flexscoring/lucene/contrib/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java
    lucene/dev/branches/flexscoring/lucene/contrib/misc/src/java/org/apache/lucene/index/FieldNormModifier.java
    lucene/dev/branches/flexscoring/lucene/contrib/misc/src/java/org/apache/lucene/misc/SweetSpotSimilarity.java
    lucene/dev/branches/flexscoring/lucene/contrib/misc/src/test/org/apache/lucene/index/TestFieldNormModifier.java
    lucene/dev/branches/flexscoring/lucene/contrib/misc/src/test/org/apache/lucene/misc/SweetSpotSimilarityTest.java
    lucene/dev/branches/flexscoring/lucene/contrib/misc/src/test/org/apache/lucene/misc/TestLengthNormModifier.java
    lucene/dev/branches/flexscoring/lucene/contrib/queries/src/java/org/apache/lucene/search/FuzzyLikeThisQuery.java
    lucene/dev/branches/flexscoring/lucene/contrib/xml-query-parser/LuceneCoreQuery.dtd
    lucene/dev/branches/flexscoring/lucene/contrib/xml-query-parser/docs/LuceneCoreQuery.dtd.org.html
    lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/document/AbstractField.java
    lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/document/Document.java
    lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/document/Fieldable.java
    lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/index/DocumentsWriter.java
    lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java
    lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/index/IndexReader.java
    lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/index/IndexWriterConfig.java
    lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/index/NormsWriterPerField.java
    lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/BooleanQuery.java
    lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/BooleanScorer2.java
    lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/ExactPhraseScorer.java
    lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/IndexSearcher.java
    lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/MultiPhraseQuery.java
    lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/PhraseQuery.java
    lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/PhraseScorer.java
    lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/SloppyPhraseScorer.java
    lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/TermQuery.java
    lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/TermScorer.java
    lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/Weight.java
    lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/package.html
    lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/payloads/PayloadNearQuery.java
    lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/payloads/PayloadTermQuery.java
    lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/similarities/BM25Similarity.java
    lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/similarities/BM25SimilarityProvider.java
    lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/similarities/EasySimilarity.java
    lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/similarities/EasyStats.java
    lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/similarities/LMJelinekMercerSimilarity.java
    lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/spans/SpanScorer.java
    lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/spans/SpanWeight.java
    lucene/dev/branches/flexscoring/lucene/src/test-framework/org/apache/lucene/index/DocHelper.java
    lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
    lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/index/TestDeletionPolicy.java
    lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/index/TestIndexFileDeleter.java
    lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/index/TestIndexReader.java
    lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/index/TestIndexReaderClone.java
    lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/index/TestIndexReaderCloneNorms.java
    lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/index/TestIndexReaderOnDiskFull.java
    lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/index/TestIndexReaderReopen.java
    lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/index/TestIndexWriterConfig.java
    lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/index/TestMaxTermFrequency.java
    lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/index/TestNorms.java
    lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/index/TestOmitTf.java
    lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/index/TestParallelReader.java
    lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/index/TestUniqueTermCount.java
    lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/search/JustCompileSearch.java
    lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/search/TestBoolean2.java
    lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/search/TestComplexExplanations.java
    lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/search/TestConstantScoreQuery.java
    lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/search/TestDisjunctionMaxQuery.java
    lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/search/TestDocValuesScoring.java
    lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/search/TestMultiPhraseQuery.java
    lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/search/TestSetNorm.java
    lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/search/TestSimilarity.java
    lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/search/TestSimilarityProvider.java
    lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/search/payloads/PayloadHelper.java
    lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/search/payloads/TestPayloadNearQuery.java
    lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/search/payloads/TestPayloadTermQuery.java
    lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/search/similarities/TestEasySimilarity.java
    lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/search/spans/JustCompileSearchSpans.java
    lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/search/spans/TestPayloadSpans.java
    lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/search/spans/TestSpans.java
    lucene/dev/branches/flexscoring/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/IDFValueSource.java
    lucene/dev/branches/flexscoring/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/NormValueSource.java
    lucene/dev/branches/flexscoring/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/TFValueSource.java
    lucene/dev/branches/flexscoring/modules/queries/src/java/org/apache/lucene/queries/mlt/MoreLikeThis.java
    lucene/dev/branches/flexscoring/modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/builders/StandardBooleanQueryNodeBuilder.java
    lucene/dev/branches/flexscoring/modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/nodes/StandardBooleanQueryNode.java
    lucene/dev/branches/flexscoring/solr/client/ruby/solr-ruby/solr/conf/schema.xml
    lucene/dev/branches/flexscoring/solr/client/ruby/solr-ruby/test/conf/schema.xml
    lucene/dev/branches/flexscoring/solr/contrib/clustering/src/test-files/solr-clustering/conf/schema.xml
    lucene/dev/branches/flexscoring/solr/contrib/uima/src/test-files/solr-uima/conf/schema.xml
    lucene/dev/branches/flexscoring/solr/core/src/java/org/apache/solr/schema/FieldType.java
    lucene/dev/branches/flexscoring/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
    lucene/dev/branches/flexscoring/solr/core/src/java/org/apache/solr/schema/SimilarityFactory.java
    lucene/dev/branches/flexscoring/solr/core/src/java/org/apache/solr/search/JoinQParserPlugin.java
    lucene/dev/branches/flexscoring/solr/core/src/java/org/apache/solr/search/SolrSimilarityProvider.java
    lucene/dev/branches/flexscoring/solr/core/src/test-files/solr/conf/schema-copyfield-test.xml
    lucene/dev/branches/flexscoring/solr/core/src/test-files/solr/conf/schema-required-fields.xml
    lucene/dev/branches/flexscoring/solr/core/src/test/org/apache/solr/schema/CustomSimilarityFactory.java
    lucene/dev/branches/flexscoring/solr/core/src/test/org/apache/solr/schema/IndexSchemaTest.java
    lucene/dev/branches/flexscoring/solr/core/src/test/org/apache/solr/schema/MockConfigurableSimilarity.java
    lucene/dev/branches/flexscoring/solr/core/src/test/org/apache/solr/schema/TestPerFieldSimilarity.java
    lucene/dev/branches/flexscoring/solr/core/src/test/org/apache/solr/search/function/TestFunctionQuery.java
    lucene/dev/branches/flexscoring/solr/example/example-DIH/solr/db/conf/schema.xml
    lucene/dev/branches/flexscoring/solr/example/solr/conf/schema.xml

Modified: lucene/dev/branches/flexscoring/lucene/contrib/instantiated/src/java/org/apache/lucene/store/instantiated/InstantiatedIndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/flexscoring/lucene/contrib/instantiated/src/java/org/apache/lucene/store/instantiated/InstantiatedIndexWriter.java?rev=1160668&r1=1160667&r2=1160668&view=diff
==============================================================================
--- lucene/dev/branches/flexscoring/lucene/contrib/instantiated/src/java/org/apache/lucene/store/instantiated/InstantiatedIndexWriter.java (original)
+++ lucene/dev/branches/flexscoring/lucene/contrib/instantiated/src/java/org/apache/lucene/store/instantiated/InstantiatedIndexWriter.java Tue Aug 23 12:51:44 2011
@@ -43,7 +43,7 @@ import org.apache.lucene.index.IndexRead
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermVectorOffsetInfo;
 import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.search.SimilarityProvider;
+import org.apache.lucene.search.similarities.SimilarityProvider;
 import org.apache.lucene.util.ArrayUtil;
 import org.apache.lucene.util.CollectionUtil;
 import org.apache.lucene.util.AttributeImpl;

Modified: lucene/dev/branches/flexscoring/lucene/contrib/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/flexscoring/lucene/contrib/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java?rev=1160668&r1=1160667&r2=1160668&view=diff
==============================================================================
--- lucene/dev/branches/flexscoring/lucene/contrib/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java (original)
+++ lucene/dev/branches/flexscoring/lucene/contrib/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java Tue Aug 23 12:51:44 2011
@@ -56,8 +56,8 @@ import org.apache.lucene.search.Collecto
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.Scorer;
-import org.apache.lucene.search.Similarity;
-import org.apache.lucene.search.SimilarityProvider;
+import org.apache.lucene.search.similarities.Similarity;
+import org.apache.lucene.search.similarities.SimilarityProvider;
 import org.apache.lucene.store.RAMDirectory; // for javadocs
 import org.apache.lucene.util.ArrayUtil;
 import org.apache.lucene.util.BytesRef;

Modified: lucene/dev/branches/flexscoring/lucene/contrib/misc/src/java/org/apache/lucene/index/FieldNormModifier.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/flexscoring/lucene/contrib/misc/src/java/org/apache/lucene/index/FieldNormModifier.java?rev=1160668&r1=1160667&r2=1160668&view=diff
==============================================================================
--- lucene/dev/branches/flexscoring/lucene/contrib/misc/src/java/org/apache/lucene/index/FieldNormModifier.java (original)
+++ lucene/dev/branches/flexscoring/lucene/contrib/misc/src/java/org/apache/lucene/index/FieldNormModifier.java Tue Aug 23 12:51:44 2011
@@ -22,9 +22,9 @@ import java.util.Date;
 import java.util.List;
 import java.util.ArrayList;
 
-import org.apache.lucene.search.DefaultSimilarity;
-import org.apache.lucene.search.Similarity;
-import org.apache.lucene.search.SimilarityProvider;
+import org.apache.lucene.search.similarities.DefaultSimilarity;
+import org.apache.lucene.search.similarities.Similarity;
+import org.apache.lucene.search.similarities.SimilarityProvider;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.FSDirectory;
 import org.apache.lucene.util.Bits;

Modified: lucene/dev/branches/flexscoring/lucene/contrib/misc/src/java/org/apache/lucene/misc/SweetSpotSimilarity.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/flexscoring/lucene/contrib/misc/src/java/org/apache/lucene/misc/SweetSpotSimilarity.java?rev=1160668&r1=1160667&r2=1160668&view=diff
==============================================================================
--- lucene/dev/branches/flexscoring/lucene/contrib/misc/src/java/org/apache/lucene/misc/SweetSpotSimilarity.java (original)
+++ lucene/dev/branches/flexscoring/lucene/contrib/misc/src/java/org/apache/lucene/misc/SweetSpotSimilarity.java Tue Aug 23 12:51:44 2011
@@ -17,7 +17,7 @@
 
 package org.apache.lucene.misc;
 
-import org.apache.lucene.search.DefaultSimilarity;
+import org.apache.lucene.search.similarities.DefaultSimilarity;
 import org.apache.lucene.index.FieldInvertState;
 
 /**

Modified: lucene/dev/branches/flexscoring/lucene/contrib/misc/src/test/org/apache/lucene/index/TestFieldNormModifier.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/flexscoring/lucene/contrib/misc/src/test/org/apache/lucene/index/TestFieldNormModifier.java?rev=1160668&r1=1160667&r2=1160668&view=diff
==============================================================================
--- lucene/dev/branches/flexscoring/lucene/contrib/misc/src/test/org/apache/lucene/index/TestFieldNormModifier.java (original)
+++ lucene/dev/branches/flexscoring/lucene/contrib/misc/src/test/org/apache/lucene/index/TestFieldNormModifier.java Tue Aug 23 12:51:44 2011
@@ -25,13 +25,13 @@ import org.apache.lucene.document.Docume
 import org.apache.lucene.document.Field;
 import org.apache.lucene.index.IndexReader.AtomicReaderContext;
 import org.apache.lucene.search.Collector;
-import org.apache.lucene.search.DefaultSimilarity;
-import org.apache.lucene.search.DefaultSimilarityProvider;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.Scorer;
-import org.apache.lucene.search.Similarity;
-import org.apache.lucene.search.SimilarityProvider;
 import org.apache.lucene.search.TermQuery;
+import org.apache.lucene.search.similarities.DefaultSimilarity;
+import org.apache.lucene.search.similarities.DefaultSimilarityProvider;
+import org.apache.lucene.search.similarities.Similarity;
+import org.apache.lucene.search.similarities.SimilarityProvider;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.util.LuceneTestCase;
 

Modified: lucene/dev/branches/flexscoring/lucene/contrib/misc/src/test/org/apache/lucene/misc/SweetSpotSimilarityTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/flexscoring/lucene/contrib/misc/src/test/org/apache/lucene/misc/SweetSpotSimilarityTest.java?rev=1160668&r1=1160667&r2=1160668&view=diff
==============================================================================
--- lucene/dev/branches/flexscoring/lucene/contrib/misc/src/test/org/apache/lucene/misc/SweetSpotSimilarityTest.java (original)
+++ lucene/dev/branches/flexscoring/lucene/contrib/misc/src/test/org/apache/lucene/misc/SweetSpotSimilarityTest.java Tue Aug 23 12:51:44 2011
@@ -18,11 +18,11 @@
 
 package org.apache.lucene.misc;
 
-import org.apache.lucene.search.DefaultSimilarity;
-import org.apache.lucene.search.DefaultSimilarityProvider;
-import org.apache.lucene.search.Similarity;
-import org.apache.lucene.search.TFIDFSimilarity;
-import org.apache.lucene.search.SimilarityProvider;
+import org.apache.lucene.search.similarities.DefaultSimilarity;
+import org.apache.lucene.search.similarities.DefaultSimilarityProvider;
+import org.apache.lucene.search.similarities.Similarity;
+import org.apache.lucene.search.similarities.SimilarityProvider;
+import org.apache.lucene.search.similarities.TFIDFSimilarity;
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.lucene.index.FieldInvertState;
 

Modified: lucene/dev/branches/flexscoring/lucene/contrib/misc/src/test/org/apache/lucene/misc/TestLengthNormModifier.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/flexscoring/lucene/contrib/misc/src/test/org/apache/lucene/misc/TestLengthNormModifier.java?rev=1160668&r1=1160667&r2=1160668&view=diff
==============================================================================
--- lucene/dev/branches/flexscoring/lucene/contrib/misc/src/test/org/apache/lucene/misc/TestLengthNormModifier.java (original)
+++ lucene/dev/branches/flexscoring/lucene/contrib/misc/src/test/org/apache/lucene/misc/TestLengthNormModifier.java Tue Aug 23 12:51:44 2011
@@ -30,13 +30,13 @@ import org.apache.lucene.index.IndexWrit
 import org.apache.lucene.index.MultiNorms;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.search.Collector;
-import org.apache.lucene.search.DefaultSimilarity;
-import org.apache.lucene.search.DefaultSimilarityProvider;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.Scorer;
-import org.apache.lucene.search.Similarity;
-import org.apache.lucene.search.SimilarityProvider;
 import org.apache.lucene.search.TermQuery;
+import org.apache.lucene.search.similarities.DefaultSimilarity;
+import org.apache.lucene.search.similarities.DefaultSimilarityProvider;
+import org.apache.lucene.search.similarities.Similarity;
+import org.apache.lucene.search.similarities.SimilarityProvider;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.util.LuceneTestCase;
 

Modified: lucene/dev/branches/flexscoring/lucene/contrib/queries/src/java/org/apache/lucene/search/FuzzyLikeThisQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/flexscoring/lucene/contrib/queries/src/java/org/apache/lucene/search/FuzzyLikeThisQuery.java?rev=1160668&r1=1160667&r2=1160668&view=diff
==============================================================================
--- lucene/dev/branches/flexscoring/lucene/contrib/queries/src/java/org/apache/lucene/search/FuzzyLikeThisQuery.java (original)
+++ lucene/dev/branches/flexscoring/lucene/contrib/queries/src/java/org/apache/lucene/search/FuzzyLikeThisQuery.java Tue Aug 23 12:51:44 2011
@@ -30,6 +30,8 @@ import org.apache.lucene.analysis.tokena
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.MultiFields;
 import org.apache.lucene.index.Term;
+import org.apache.lucene.search.similarities.DefaultSimilarity;
+import org.apache.lucene.search.similarities.TFIDFSimilarity;
 import org.apache.lucene.util.AttributeSource;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.PriorityQueue;

Modified: lucene/dev/branches/flexscoring/lucene/contrib/xml-query-parser/LuceneCoreQuery.dtd
URL: http://svn.apache.org/viewvc/lucene/dev/branches/flexscoring/lucene/contrib/xml-query-parser/LuceneCoreQuery.dtd?rev=1160668&r1=1160667&r2=1160668&view=diff
==============================================================================
--- lucene/dev/branches/flexscoring/lucene/contrib/xml-query-parser/LuceneCoreQuery.dtd (original)
+++ lucene/dev/branches/flexscoring/lucene/contrib/xml-query-parser/LuceneCoreQuery.dtd Tue Aug 23 12:51:44 2011
@@ -195,12 +195,12 @@ Passes content directly through to the s
   that it factors in the value of the payload located at each of the positions where the
   {@link org.apache.lucene.index.Term} occurs.
 
-  In order to take advantage of this, you must override {@link org.apache.lucene.search.Similarity#scorePayload(String, byte[],int,int)}
+  In order to take advantage of this, you must override {@link org.apache.lucene.search.similarities.Similarity#scorePayload(String, byte[],int,int)}
   which returns 1 by default.
 
   Payload scores are averaged across term occurrences in the document.
 
-  @see org.apache.lucene.search.Similarity#scorePayload(String, byte[], int, int)
+  @see org.apache.lucene.search.similarities.Similarity#scorePayload(String, byte[], int, int)
 -->
 <!ELEMENT BoostingTermQuery (#PCDATA)>
 <!-- Optional boost for matches on this query. Values > 1 -->

Modified: lucene/dev/branches/flexscoring/lucene/contrib/xml-query-parser/docs/LuceneCoreQuery.dtd.org.html
URL: http://svn.apache.org/viewvc/lucene/dev/branches/flexscoring/lucene/contrib/xml-query-parser/docs/LuceneCoreQuery.dtd.org.html?rev=1160668&r1=1160667&r2=1160668&view=diff
==============================================================================
--- lucene/dev/branches/flexscoring/lucene/contrib/xml-query-parser/docs/LuceneCoreQuery.dtd.org.html (original)
+++ lucene/dev/branches/flexscoring/lucene/contrib/xml-query-parser/docs/LuceneCoreQuery.dtd.org.html Tue Aug 23 12:51:44 2011
@@ -201,12 +201,12 @@
 <span class="dtd_comment">  that it factors in the value of the payload located at each of the positions where the</span>
 <span class="dtd_comment">  {@link org.apache.lucene.index.Term} occurs.</span>
 
-<span class="dtd_comment">  In order to take advantage of this, you must override {@link org.apache.lucene.search.Similarity#scorePayload(String, byte[],int,int)}</span>
+<span class="dtd_comment">  In order to take advantage of this, you must override {@link org.apache.lucene.search.similarities.Similarity#scorePayload(String, byte[],int,int)}</span>
 <span class="dtd_comment">  which returns 1 by default.</span>
 
 <span class="dtd_comment">  Payload scores are averaged across term occurrences in the document.</span>
 
-<span class="dtd_comment">  @see org.apache.lucene.search.Similarity#scorePayload(String, byte[], int, int)</span>
+<span class="dtd_comment">  @see org.apache.lucene.search.similarities.Similarity#scorePayload(String, byte[], int, int)</span>
 <span class="dtd_comment">--&gt;</span>
 <span class="dtd_tag_symbols">&lt;!</span><span class="dtd_tag_name">ELEMENT</span><span class="dtd_plain"> </span><span class="dtd_attribute_name">BoostingTermQuery</span><span class="dtd_plain"> (</span><span class="dtd_keyword">#PCDATA</span><span class="dtd_plain">)</span><span class="dtd_tag_symbols">&gt;</span>
 <span class="dtd_comment">&lt;!-- Optional boost for matches on this query. Values &gt; 1 --&gt;</span>

Modified: lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/document/AbstractField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/document/AbstractField.java?rev=1160668&r1=1160667&r2=1160668&view=diff
==============================================================================
--- lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/document/AbstractField.java (original)
+++ lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/document/AbstractField.java Tue Aug 23 12:51:44 2011
@@ -79,15 +79,15 @@ public abstract class AbstractField impl
    * name, all such values are multiplied together.  This product is then
    * used to compute the norm factor for the field.  By
    * default, in the {@link
-   * org.apache.lucene.search.Similarity#computeNorm(FieldInvertState)} method, the boost value is multiplied
+   * org.apache.lucene.search.similarities.Similarity#computeNorm(FieldInvertState)} method, the boost value is multiplied
    * by the length normalization factor and then
-   * rounded by {@link org.apache.lucene.search.DefaultSimilarity#encodeNormValue(float)} before it is stored in the
+   * rounded by {@link org.apache.lucene.search.similarities.DefaultSimilarity#encodeNormValue(float)} before it is stored in the
    * index.  One should attempt to ensure that this product does not overflow
    * the range of that encoding.
    *
    * @see org.apache.lucene.document.Document#setBoost(float)
-   * @see org.apache.lucene.search.Similarity#computeNorm(FieldInvertState)
-   * @see org.apache.lucene.search.DefaultSimilarity#encodeNormValue(float)
+   * @see org.apache.lucene.search.similarities.Similarity#computeNorm(FieldInvertState)
+   * @see org.apache.lucene.search.similarities.DefaultSimilarity#encodeNormValue(float)
    */
   public void setBoost(float boost) {
     this.boost = boost;

Modified: lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/document/Document.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/document/Document.java?rev=1160668&r1=1160667&r2=1160668&view=diff
==============================================================================
--- lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/document/Document.java (original)
+++ lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/document/Document.java Tue Aug 23 12:51:44 2011
@@ -66,7 +66,7 @@ public final class Document {
    * time was ignored - it was just combined with other indexing time factors and 
    * stored elsewhere, for better indexing and search performance. (For more 
    * information see the "norm(t,d)" part of the scoring formula in 
-   * {@link org.apache.lucene.search.Similarity Similarity}.)
+   * {@link org.apache.lucene.search.similarities.Similarity Similarity}.)
    *
    * @see #setBoost(float)
    */

Modified: lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/document/Fieldable.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/document/Fieldable.java?rev=1160668&r1=1160667&r2=1160668&view=diff
==============================================================================
--- lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/document/Fieldable.java (original)
+++ lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/document/Fieldable.java Tue Aug 23 12:51:44 2011
@@ -47,15 +47,15 @@ public interface Fieldable {
    * name, all such values are multiplied together.  This product is then
    * used to compute the norm factor for the field.  By
    * default, in the {@link
-   * org.apache.lucene.search.Similarity#computeNorm(FieldInvertState)} method, the boost value is multiplied
+   * org.apache.lucene.search.similarities.Similarity#computeNorm(FieldInvertState)} method, the boost value is multiplied
    * by the length normalization factor
-   * and then rounded by {@link org.apache.lucene.search.DefaultSimilarity#encodeNormValue(float)} before it is stored in the
+   * and then rounded by {@link org.apache.lucene.search.similarities.DefaultSimilarity#encodeNormValue(float)} before it is stored in the
    * index.  One should attempt to ensure that this product does not overflow
    * the range of that encoding.
    *
    * @see org.apache.lucene.document.Document#setBoost(float)
-   * @see org.apache.lucene.search.Similarity#computeNorm(FieldInvertState)
-   * @see org.apache.lucene.search.DefaultSimilarity#encodeNormValue(float)
+   * @see org.apache.lucene.search.similarities.Similarity#computeNorm(FieldInvertState)
+   * @see org.apache.lucene.search.similarities.DefaultSimilarity#encodeNormValue(float)
    */
   void setBoost(float boost);
 

Modified: lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/index/DocumentsWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/index/DocumentsWriter.java?rev=1160668&r1=1160667&r2=1160668&view=diff
==============================================================================
--- lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/index/DocumentsWriter.java (original)
+++ lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/index/DocumentsWriter.java Tue Aug 23 12:51:44 2011
@@ -33,7 +33,7 @@ import org.apache.lucene.index.Documents
 import org.apache.lucene.index.DocumentsWriterPerThreadPool.ThreadState;
 import org.apache.lucene.index.FieldInfos.FieldNumberBiMap;
 import org.apache.lucene.search.Query;
-import org.apache.lucene.search.SimilarityProvider;
+import org.apache.lucene.search.similarities.SimilarityProvider;
 import org.apache.lucene.store.AlreadyClosedException;
 import org.apache.lucene.store.Directory;
 

Modified: lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java?rev=1160668&r1=1160667&r2=1160668&view=diff
==============================================================================
--- lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java (original)
+++ lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java Tue Aug 23 12:51:44 2011
@@ -28,7 +28,7 @@ import java.util.concurrent.atomic.Atomi
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.index.DocumentsWriterDeleteQueue.DeleteSlice;
-import org.apache.lucene.search.SimilarityProvider;
+import org.apache.lucene.search.similarities.SimilarityProvider;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.FlushInfo;
 import org.apache.lucene.store.IOContext;

Modified: lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/index/IndexReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/index/IndexReader.java?rev=1160668&r1=1160667&r2=1160668&view=diff
==============================================================================
--- lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/index/IndexReader.java (original)
+++ lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/index/IndexReader.java Tue Aug 23 12:51:44 2011
@@ -20,7 +20,7 @@ package org.apache.lucene.index;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.FieldSelector;
 import org.apache.lucene.search.FieldCache; // javadocs
-import org.apache.lucene.search.Similarity;
+import org.apache.lucene.search.similarities.Similarity;
 import org.apache.lucene.index.codecs.Codec;
 import org.apache.lucene.index.codecs.CodecProvider;
 import org.apache.lucene.index.codecs.PerDocValues;
@@ -1027,7 +1027,7 @@ public abstract class IndexReader implem
    *
    * @see #norms(String)
    * @see Similarity#computeNorm(FieldInvertState)
-   * @see org.apache.lucene.search.DefaultSimilarity#decodeNormValue(byte)
+   * @see org.apache.lucene.search.similarities.DefaultSimilarity#decodeNormValue(byte)
    * @throws StaleReaderException if the index has changed
    *  since this reader was opened
    * @throws CorruptIndexException if the index is corrupt

Modified: lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/index/IndexWriterConfig.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/index/IndexWriterConfig.java?rev=1160668&r1=1160667&r2=1160668&view=diff
==============================================================================
--- lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/index/IndexWriterConfig.java (original)
+++ lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/index/IndexWriterConfig.java Tue Aug 23 12:51:44 2011
@@ -22,7 +22,7 @@ import org.apache.lucene.index.Documents
 import org.apache.lucene.index.IndexWriter.IndexReaderWarmer;
 import org.apache.lucene.index.codecs.CodecProvider;
 import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.search.SimilarityProvider;
+import org.apache.lucene.search.similarities.SimilarityProvider;
 import org.apache.lucene.util.Version;
 
 /**

Modified: lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/index/NormsWriterPerField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/index/NormsWriterPerField.java?rev=1160668&r1=1160667&r2=1160668&view=diff
==============================================================================
--- lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/index/NormsWriterPerField.java (original)
+++ lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/index/NormsWriterPerField.java Tue Aug 23 12:51:44 2011
@@ -17,7 +17,7 @@ package org.apache.lucene.index;
  * limitations under the License.
  */
 
-import org.apache.lucene.search.Similarity;
+import org.apache.lucene.search.similarities.Similarity;
 import org.apache.lucene.util.ArrayUtil;
 
 /** Taps into DocInverter, as an InvertedDocEndConsumer,

Modified: lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/BooleanQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/BooleanQuery.java?rev=1160668&r1=1160667&r2=1160668&view=diff
==============================================================================
--- lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/BooleanQuery.java (original)
+++ lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/BooleanQuery.java Tue Aug 23 12:51:44 2011
@@ -22,6 +22,7 @@ import org.apache.lucene.index.IndexRead
 import org.apache.lucene.index.Term;
 import org.apache.lucene.util.ToStringUtils;
 import org.apache.lucene.search.BooleanClause.Occur;
+import org.apache.lucene.search.similarities.SimilarityProvider;
 
 import java.io.IOException;
 import java.util.*;

Modified: lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/BooleanScorer2.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/BooleanScorer2.java?rev=1160668&r1=1160667&r2=1160668&view=diff
==============================================================================
--- lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/BooleanScorer2.java (original)
+++ lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/BooleanScorer2.java Tue Aug 23 12:51:44 2011
@@ -23,6 +23,7 @@ import java.util.List;
 
 import org.apache.lucene.search.BooleanClause.Occur;
 import org.apache.lucene.search.BooleanQuery.BooleanWeight;
+import org.apache.lucene.search.similarities.Similarity;
 
 /* See the description in BooleanScorer.java, comparing
  * BooleanScorer & BooleanScorer2 */

Modified: lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/ExactPhraseScorer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/ExactPhraseScorer.java?rev=1160668&r1=1160667&r2=1160668&view=diff
==============================================================================
--- lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/ExactPhraseScorer.java (original)
+++ lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/ExactPhraseScorer.java Tue Aug 23 12:51:44 2011
@@ -21,6 +21,7 @@ import java.io.IOException;
 import java.util.Arrays;
 
 import org.apache.lucene.index.*;
+import org.apache.lucene.search.similarities.Similarity;
 
 final class ExactPhraseScorer extends Scorer {
   private final int endMinus1;

Modified: lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/IndexSearcher.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/IndexSearcher.java?rev=1160668&r1=1160667&r2=1160668&view=diff
==============================================================================
--- lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/IndexSearcher.java (original)
+++ lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/IndexSearcher.java Tue Aug 23 12:51:44 2011
@@ -37,6 +37,8 @@ import org.apache.lucene.index.IndexRead
 import org.apache.lucene.index.IndexReader.ReaderContext;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.search.Weight.ScorerContext;
+import org.apache.lucene.search.similarities.DefaultSimilarityProvider;
+import org.apache.lucene.search.similarities.SimilarityProvider;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.NIOFSDirectory;    // javadoc
 import org.apache.lucene.util.ReaderUtil;

Modified: lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/MultiPhraseQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/MultiPhraseQuery.java?rev=1160668&r1=1160667&r2=1160668&view=diff
==============================================================================
--- lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/MultiPhraseQuery.java (original)
+++ lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/MultiPhraseQuery.java Tue Aug 23 12:51:44 2011
@@ -26,7 +26,8 @@ import org.apache.lucene.index.IndexRead
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.DocsEnum;
 import org.apache.lucene.index.DocsAndPositionsEnum;
-import org.apache.lucene.search.Similarity.SloppyDocScorer;
+import org.apache.lucene.search.similarities.Similarity;
+import org.apache.lucene.search.similarities.Similarity.SloppyDocScorer;
 import org.apache.lucene.util.ArrayUtil;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.TermContext;

Modified: lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/PhraseQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/PhraseQuery.java?rev=1160668&r1=1160667&r2=1160668&view=diff
==============================================================================
--- lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/PhraseQuery.java (original)
+++ lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/PhraseQuery.java Tue Aug 23 12:51:44 2011
@@ -29,7 +29,8 @@ import org.apache.lucene.index.IndexRead
 import org.apache.lucene.index.TermState;
 import org.apache.lucene.index.Terms;
 import org.apache.lucene.index.TermsEnum;
-import org.apache.lucene.search.Similarity.SloppyDocScorer;
+import org.apache.lucene.search.similarities.Similarity;
+import org.apache.lucene.search.similarities.Similarity.SloppyDocScorer;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.TermContext;
 import org.apache.lucene.util.ToStringUtils;

Modified: lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/PhraseScorer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/PhraseScorer.java?rev=1160668&r1=1160667&r2=1160668&view=diff
==============================================================================
--- lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/PhraseScorer.java (original)
+++ lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/PhraseScorer.java Tue Aug 23 12:51:44 2011
@@ -19,6 +19,8 @@ package org.apache.lucene.search;
 
 import java.io.IOException;
 
+import org.apache.lucene.search.similarities.Similarity;
+
 /** Expert: Scoring functionality for phrase queries.
  * <br>A document is considered matching if it contains the phrase-query terms  
  * at "valid" positions. What "valid positions" are

Modified: lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/SloppyPhraseScorer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/SloppyPhraseScorer.java?rev=1160668&r1=1160667&r2=1160668&view=diff
==============================================================================
--- lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/SloppyPhraseScorer.java (original)
+++ lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/SloppyPhraseScorer.java Tue Aug 23 12:51:44 2011
@@ -20,6 +20,8 @@ package org.apache.lucene.search;
 import java.io.IOException;
 import java.util.HashSet;
 
+import org.apache.lucene.search.similarities.Similarity;
+
 final class SloppyPhraseScorer extends PhraseScorer {
     private int slop;
     private PhrasePositions repeats[];

Modified: lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/TermQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/TermQuery.java?rev=1160668&r1=1160667&r2=1160668&view=diff
==============================================================================
--- lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/TermQuery.java (original)
+++ lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/TermQuery.java Tue Aug 23 12:51:44 2011
@@ -27,7 +27,8 @@ import org.apache.lucene.index.Terms;
 import org.apache.lucene.index.IndexReader.AtomicReaderContext;
 import org.apache.lucene.index.IndexReader.ReaderContext;
 import org.apache.lucene.index.Term;
-import org.apache.lucene.search.Similarity.ExactDocScorer;
+import org.apache.lucene.search.similarities.Similarity;
+import org.apache.lucene.search.similarities.Similarity.ExactDocScorer;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.TermContext;
 import org.apache.lucene.util.ReaderUtil;

Modified: lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/TermScorer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/TermScorer.java?rev=1160668&r1=1160667&r2=1160668&view=diff
==============================================================================
--- lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/TermScorer.java (original)
+++ lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/TermScorer.java Tue Aug 23 12:51:44 2011
@@ -20,6 +20,7 @@ package org.apache.lucene.search;
 import java.io.IOException;
 
 import org.apache.lucene.index.DocsEnum;
+import org.apache.lucene.search.similarities.Similarity;
 
 /** Expert: A <code>Scorer</code> for documents matching a <code>Term</code>.
  */

Modified: lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/Weight.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/Weight.java?rev=1160668&r1=1160667&r2=1160668&view=diff
==============================================================================
--- lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/Weight.java (original)
+++ lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/Weight.java Tue Aug 23 12:51:44 2011
@@ -22,6 +22,7 @@ import java.io.IOException;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.IndexReader.AtomicReaderContext;
 import org.apache.lucene.index.IndexReader.ReaderContext;
+import org.apache.lucene.search.similarities.SimilarityProvider;
 
 /**
  * Expert: Calculate query weights and build query scorers.

Modified: lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/package.html
URL: http://svn.apache.org/viewvc/lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/package.html?rev=1160668&r1=1160667&r2=1160668&view=diff
==============================================================================
--- lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/package.html (original)
+++ lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/package.html Tue Aug 23 12:51:44 2011
@@ -223,9 +223,9 @@ org.apache.lucene.search.IndexSearcher#s
     you'll want to simply subclass
     <a href="DefaultSimilarity.html">DefaultSimilarity</a>) and then use the new
     class by calling
-    <a href="../index/IndexWriter.html#setSimilarity(org.apache.lucene.search.Similarity)">IndexWriter.setSimilarity</a>
+    <a href="../index/IndexWriter.html#setSimilarity(org.apache.lucene.search.similarities.Similarity)">IndexWriter.setSimilarity</a>
     before indexing and
-    <a href="Searcher.html#setSimilarity(org.apache.lucene.search.Similarity)">Searcher.setSimilarity</a>
+    <a href="Searcher.html#setSimilarity(org.apache.lucene.search.similarities.Similarity)">Searcher.setSimilarity</a>
     before searching.
 </p>
 

Modified: lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/payloads/PayloadNearQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/payloads/PayloadNearQuery.java?rev=1160668&r1=1160667&r2=1160668&view=diff
==============================================================================
--- lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/payloads/PayloadNearQuery.java (original)
+++ lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/payloads/PayloadNearQuery.java Tue Aug 23 12:51:44 2011
@@ -22,10 +22,10 @@ import org.apache.lucene.search.ComplexE
 import org.apache.lucene.search.Explanation;
 import org.apache.lucene.search.Scorer;
 import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.search.Similarity;
-import org.apache.lucene.search.DefaultSimilarity; // javadocs only
 import org.apache.lucene.search.Weight;
-import org.apache.lucene.search.Similarity.SloppyDocScorer;
+import org.apache.lucene.search.similarities.DefaultSimilarity;
+import org.apache.lucene.search.similarities.Similarity;
+import org.apache.lucene.search.similarities.Similarity.SloppyDocScorer;
 import org.apache.lucene.search.spans.NearSpansOrdered;
 import org.apache.lucene.search.spans.NearSpansUnordered;
 import org.apache.lucene.search.spans.SpanNearQuery;
@@ -52,7 +52,7 @@ import java.util.Iterator;
  * <p/>
  * Payload scores are aggregated using a pluggable {@link PayloadFunction}.
  * 
- * @see org.apache.lucene.search.Similarity.SloppyDocScorer#computePayloadFactor(int, int, int, BytesRef)
+ * @see org.apache.lucene.search.similarities.Similarity.SloppyDocScorer#computePayloadFactor(int, int, int, BytesRef)
  */
 public class PayloadNearQuery extends SpanNearQuery {
   protected String fieldName;

Modified: lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/payloads/PayloadTermQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/payloads/PayloadTermQuery.java?rev=1160668&r1=1160667&r2=1160668&view=diff
==============================================================================
--- lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/payloads/PayloadTermQuery.java (original)
+++ lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/payloads/PayloadTermQuery.java Tue Aug 23 12:51:44 2011
@@ -20,16 +20,16 @@ package org.apache.lucene.search.payload
 import org.apache.lucene.index.IndexReader.AtomicReaderContext;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.DocsAndPositionsEnum;
-import org.apache.lucene.search.DefaultSimilarity; // javadocs only
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.Scorer;
 import org.apache.lucene.search.Weight;
-import org.apache.lucene.search.Similarity;
 import org.apache.lucene.search.Explanation;
 import org.apache.lucene.search.ComplexExplanation;
-import org.apache.lucene.search.Similarity.SloppyDocScorer;
 import org.apache.lucene.search.Weight.ScorerContext;
 import org.apache.lucene.search.payloads.PayloadNearQuery.PayloadNearSpanScorer;
+import org.apache.lucene.search.similarities.DefaultSimilarity;
+import org.apache.lucene.search.similarities.Similarity;
+import org.apache.lucene.search.similarities.Similarity.SloppyDocScorer;
 import org.apache.lucene.search.spans.TermSpans;
 import org.apache.lucene.search.spans.SpanTermQuery;
 import org.apache.lucene.search.spans.SpanWeight;
@@ -49,7 +49,7 @@ import java.io.IOException;
  * which returns 1 by default.
  * <p/>
  * Payload scores are aggregated using a pluggable {@link PayloadFunction}.
- * @see org.apache.lucene.search.Similarity.SloppyDocScorer#computePayloadFactor(int, int, int, BytesRef)
+ * @see org.apache.lucene.search.similarities.Similarity.SloppyDocScorer#computePayloadFactor(int, int, int, BytesRef)
  **/
 public class PayloadTermQuery extends SpanTermQuery {
   protected PayloadFunction function;

Modified: lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/similarities/BM25Similarity.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/similarities/BM25Similarity.java?rev=1160668&r1=1160667&r2=1160668&view=diff
==============================================================================
--- lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/similarities/BM25Similarity.java (original)
+++ lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/similarities/BM25Similarity.java Tue Aug 23 12:51:44 2011
@@ -23,7 +23,6 @@ import org.apache.lucene.index.FieldInve
 import org.apache.lucene.index.MultiFields;
 import org.apache.lucene.index.IndexReader.AtomicReaderContext;
 import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.search.Similarity;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.SmallFloat;
 import org.apache.lucene.util.TermContext;

Modified: lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/similarities/BM25SimilarityProvider.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/similarities/BM25SimilarityProvider.java?rev=1160668&r1=1160667&r2=1160668&view=diff
==============================================================================
--- lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/similarities/BM25SimilarityProvider.java (original)
+++ lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/similarities/BM25SimilarityProvider.java Tue Aug 23 12:51:44 2011
@@ -1,7 +1,5 @@
 package org.apache.lucene.search.similarities;
 
-import org.apache.lucene.search.DefaultSimilarityProvider;
-
 /**
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with

Added: lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/similarities/DefaultSimilarity.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/similarities/DefaultSimilarity.java?rev=1160668&view=auto
==============================================================================
--- lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/similarities/DefaultSimilarity.java (added)
+++ lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/similarities/DefaultSimilarity.java Tue Aug 23 12:51:44 2011
@@ -0,0 +1,88 @@
+package org.apache.lucene.search.similarities;
+
+import org.apache.lucene.index.FieldInvertState;
+import org.apache.lucene.util.BytesRef;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+/** Expert: Default scoring implementation. */
+public class DefaultSimilarity extends TFIDFSimilarity {
+
+  /** Implemented as
+   *  <code>state.getBoost()*lengthNorm(numTerms)</code>, where
+   *  <code>numTerms</code> is {@link FieldInvertState#getLength()} if {@link
+   *  #setDiscountOverlaps} is false, else it's {@link
+   *  FieldInvertState#getLength()} - {@link
+   *  FieldInvertState#getNumOverlap()}.
+   *
+   *  @lucene.experimental */
+  @Override
+  public byte computeNorm(FieldInvertState state) {
+    final int numTerms;
+    if (discountOverlaps)
+      numTerms = state.getLength() - state.getNumOverlap();
+    else
+      numTerms = state.getLength();
+    return encodeNormValue(state.getBoost() * ((float) (1.0 / Math.sqrt(numTerms))));
+  }
+
+  /** Implemented as <code>sqrt(freq)</code>. */
+  @Override
+  public float tf(float freq) {
+    return (float)Math.sqrt(freq);
+  }
+    
+  /** Implemented as <code>1 / (distance + 1)</code>. */
+  @Override
+  public float sloppyFreq(int distance) {
+    return 1.0f / (distance + 1);
+  }
+  
+  /** The default implementation returns <code>1</code> */
+  @Override
+  public float scorePayload(int doc, int start, int end, BytesRef payload) {
+    return 1;
+  }
+
+  /** Implemented as <code>log(numDocs/(docFreq+1)) + 1</code>. */
+  @Override
+  public float idf(int docFreq, int numDocs) {
+    return (float)(Math.log(numDocs/(double)(docFreq+1)) + 1.0);
+  }
+    
+  // Default true
+  protected boolean discountOverlaps = true;
+
+  /** Determines whether overlap tokens (Tokens with
+   *  0 position increment) are ignored when computing
+   *  norm.  By default this is true, meaning overlap
+   *  tokens do not count when computing norms.
+   *
+   *  @lucene.experimental
+   *
+   *  @see #computeNorm
+   */
+  public void setDiscountOverlaps(boolean v) {
+    discountOverlaps = v;
+  }
+
+  /** @see #setDiscountOverlaps */
+  public boolean getDiscountOverlaps() {
+    return discountOverlaps;
+  }
+}

Added: lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/similarities/DefaultSimilarityProvider.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/similarities/DefaultSimilarityProvider.java?rev=1160668&view=auto
==============================================================================
--- lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/similarities/DefaultSimilarityProvider.java (added)
+++ lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/similarities/DefaultSimilarityProvider.java Tue Aug 23 12:51:44 2011
@@ -0,0 +1,42 @@
+package org.apache.lucene.search.similarities;
+
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+/** 
+ * Expert: Default scoring provider. 
+ * <p>
+ * Returns {@link DefaultSimilarity} for every field
+ */
+public class DefaultSimilarityProvider implements SimilarityProvider {
+  private static final Similarity impl = new DefaultSimilarity();
+  
+  /** Implemented as <code>overlap / maxOverlap</code>. */
+  public float coord(int overlap, int maxOverlap) {
+    return overlap / (float)maxOverlap;
+  }
+
+  /** Implemented as <code>1/sqrt(sumOfSquaredWeights)</code>. */
+  public float queryNorm(float sumOfSquaredWeights) {
+    return (float)(1.0 / Math.sqrt(sumOfSquaredWeights));
+  }
+
+  public Similarity get(String field) {
+    return impl;
+  }
+}

Modified: lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/similarities/EasySimilarity.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/similarities/EasySimilarity.java?rev=1160668&r1=1160667&r2=1160668&view=diff
==============================================================================
--- lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/similarities/EasySimilarity.java (original)
+++ lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/similarities/EasySimilarity.java Tue Aug 23 12:51:44 2011
@@ -25,7 +25,6 @@ import org.apache.lucene.index.IndexRead
 import org.apache.lucene.index.MultiFields;
 import org.apache.lucene.search.Explanation;
 import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.search.Similarity;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.SmallFloat;
 import org.apache.lucene.util.TermContext;

Modified: lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/similarities/EasyStats.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/similarities/EasyStats.java?rev=1160668&r1=1160667&r2=1160668&view=diff
==============================================================================
--- lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/similarities/EasyStats.java (original)
+++ lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/similarities/EasyStats.java Tue Aug 23 12:51:44 2011
@@ -17,9 +17,7 @@ package org.apache.lucene.search.similar
  * limitations under the License.
  */
 
-import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.Terms;
-import org.apache.lucene.search.Similarity;
 
 /**
  * Stores all statistics commonly used ranking methods.

Modified: lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/similarities/LMJelinekMercerSimilarity.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/similarities/LMJelinekMercerSimilarity.java?rev=1160668&r1=1160667&r2=1160668&view=diff
==============================================================================
--- lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/similarities/LMJelinekMercerSimilarity.java (original)
+++ lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/similarities/LMJelinekMercerSimilarity.java Tue Aug 23 12:51:44 2011
@@ -18,7 +18,6 @@ package org.apache.lucene.search.similar
  */
 
 import org.apache.lucene.search.Explanation;
-import org.apache.lucene.search.similarities.LMSimilarity.LMStats;
 
 /**
  * Language model based on the Jelinek-Mercer smoothing method. From Chengxiang

Added: lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/similarities/Similarity.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/similarities/Similarity.java?rev=1160668&view=auto
==============================================================================
--- lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/similarities/Similarity.java (added)
+++ lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/similarities/Similarity.java Tue Aug 23 12:51:44 2011
@@ -0,0 +1,230 @@
+package org.apache.lucene.search.similarities;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 java.io.IOException;
+
+import org.apache.lucene.document.IndexDocValuesField; // javadoc
+import org.apache.lucene.index.FieldInvertState;
+import org.apache.lucene.index.IndexReader; // javadoc
+import org.apache.lucene.index.IndexReader.AtomicReaderContext;
+import org.apache.lucene.index.Terms; // javadoc
+import org.apache.lucene.search.BooleanQuery;
+import org.apache.lucene.search.Explanation;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.PhraseQuery;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.TermQuery;
+import org.apache.lucene.search.spans.SpanQuery; // javadoc
+import org.apache.lucene.util.BytesRef;
+import org.apache.lucene.util.SmallFloat; // javadoc
+import org.apache.lucene.util.TermContext;
+
+
+/** 
+ * Similarity defines the components of Lucene scoring.
+ * <p>
+ * Expert: Scoring API.
+ * <p>
+ * This is a low-level API, you should only extend this API if you want to implement 
+ * an information retrieval <i>model</i>.  If you are instead looking for a convenient way 
+ * to alter Lucene's scoring, consider extending a higher-level implementation
+ * such as {@link TFIDFSimilarity}, which implements the vector space model with this API, or 
+ * just tweaking the default implementation: {@link DefaultSimilarity}.
+ * <p>
+ * Similarity determines how Lucene weights terms, and Lucene interacts with
+ * this class at both <a href="#indextime">index-time</a> and 
+ * <a href="#querytime">query-time</a>.
+ * <p>
+ * <a name="indextime"/>
+ * At indexing time, the indexer calls {@link #computeNorm(FieldInvertState)}, allowing
+ * the Similarity implementation to return a per-document byte for the field that will 
+ * be later accessible via {@link IndexReader#norms(String)}.  Lucene makes no assumption
+ * about what is in this byte, but it is most useful for encoding length normalization 
+ * information.
+ * <p>
+ * Implementations should carefully consider how the normalization byte is encoded: while
+ * Lucene's classical {@link TFIDFSimilarity} encodes a combination of index-time boost
+ * and length normalization information with {@link SmallFloat}, this might not be suitable
+ * for all purposes.
+ * <p>
+ * Many formulas require the use of average document length, which can be computed via a 
+ * combination of {@link Terms#getSumTotalTermFreq()} and {@link IndexReader#maxDoc()},
+ * <p>
+ * Because index-time boost is handled entirely at the application level anyway,
+ * an application can alternatively store the index-time boost separately using an 
+ * {@link IndexDocValuesField}, and access this at query-time with 
+ * {@link IndexReader#docValues(String)}.
+ * <p>
+ * Finally, using index-time boosts (either via folding into the normalization byte or
+ * via IndexDocValues), is an inefficient way to boost the scores of different fields if the
+ * boost will be the same for every document, instead the Similarity can simply take a constant
+ * boost parameter <i>C</i>, and the SimilarityProvider can return different instances with
+ * different boosts depending upon field name.
+ * <p>
+ * <a name="querytime"/>
+ * At query-time, Queries interact with the Similarity via these steps:
+ * <ol>
+ *   <li>The {@link #computeStats(IndexSearcher, String, float, TermContext...)} method is called a single time,
+ *       allowing the implementation to compute any statistics (such as IDF, average document length, etc)
+ *       across <i>the entire collection</i>. The {@link TermContext}s passed in are already positioned
+ *       to the terms involved with the raw statistics involved, so a Similarity can freely use any combination
+ *       of term statistics without causing any additional I/O. Lucene makes no assumption about what is 
+ *       stored in the returned {@link Similarity.Stats} object.
+ *   <li>The query normalization process occurs a single time: {@link Similarity.Stats#getValueForNormalization()}
+ *       is called for each query leaf node, {@link SimilarityProvider#queryNorm(float)} is called for the top-level
+ *       query, and finally {@link Similarity.Stats#normalize(float, float)} passes down the normalization value
+ *       and any top-level boosts (e.g. from enclosing {@link BooleanQuery}s).
+ *   <li>For each segment in the index, the Query creates a {@link #exactDocScorer(Stats, String, IndexReader.AtomicReaderContext)}
+ *       (for queries with exact frequencies such as TermQuerys and exact PhraseQueries) or a 
+ *       {@link #sloppyDocScorer(Stats, String, IndexReader.AtomicReaderContext)} (for queries with sloppy frequencies such as
+ *       SpanQuerys and sloppy PhraseQueries). The score() method is called for each matching document.
+ * </ol>
+ * <p>
+ * <a name="explaintime"/>
+ * When {@link IndexSearcher#explain(Query, int)} is called, queries consult the Similarity's DocScorer for an 
+ * explanation of how it computed its score. The query passes in a the document id and an explanation of how the frequency
+ * was computed.
+ *
+ * @see org.apache.lucene.index.IndexWriterConfig#setSimilarityProvider(SimilarityProvider)
+ * @see IndexSearcher#setSimilarityProvider(SimilarityProvider)
+ * @lucene.experimental
+ */
+public abstract class Similarity {
+  /**
+   * Computes the normalization value for a field, given the accumulated
+   * state of term processing for this field (see {@link FieldInvertState}).
+   * 
+   * <p>Implementations should calculate a byte value based on the field
+   * state and then return that value.
+   *
+   * <p>Matches in longer fields are less precise, so implementations of this
+   * method usually return smaller values when <code>state.getLength()</code> is large,
+   * and larger values when <code>state.getLength()</code> is small.
+   * 
+   * @lucene.experimental
+   * 
+   * @param state current processing state for this field
+   * @return the calculated byte norm
+   */
+  public abstract byte computeNorm(FieldInvertState state);
+  
+  /**
+   * Compute any collection-level stats (e.g. IDF, average document length, etc) needed for scoring a query.
+   */
+  public abstract Stats computeStats(IndexSearcher searcher, String fieldName, float queryBoost, TermContext... termContexts) throws IOException;
+  
+  /**
+   * returns a new {@link Similarity.ExactDocScorer}.
+   */
+  public abstract ExactDocScorer exactDocScorer(Stats stats, String fieldName, AtomicReaderContext context) throws IOException;
+  
+  /**
+   * returns a new {@link Similarity.SloppyDocScorer}.
+   */
+  public abstract SloppyDocScorer sloppyDocScorer(Stats stats, String fieldName, AtomicReaderContext context) throws IOException;
+  
+  /**
+   * API for scoring exact queries such as {@link TermQuery} and 
+   * exact {@link PhraseQuery}.
+   * <p>
+   * Term frequencies are integers (the term or phrase's tf)
+   */
+  public abstract class ExactDocScorer {
+    /**
+     * Score a single document
+     * @param doc document id
+     * @param freq term frequency
+     * @return document's score
+     */
+    public abstract float score(int doc, int freq);
+    
+    /**
+     * Explain the score for a single document
+     * @param doc document id
+     * @param freq Explanation of how the term frequency was computed
+     * @return document's score
+     */
+    public Explanation explain(int doc, Explanation freq) {
+      Explanation result = new Explanation(score(doc, (int)freq.getValue()), 
+          "score(doc=" + doc + ",freq=" + freq.getValue() +"), with freq of:");
+      result.addDetail(freq);
+      return result;
+    }
+  }
+  
+  /**
+   * API for scoring "sloppy" queries such as {@link SpanQuery} and 
+   * sloppy {@link PhraseQuery}.
+   * <p>
+   * Term frequencies are floating point values.
+   */
+  public abstract class SloppyDocScorer {
+    /**
+     * Score a single document
+     * @param doc document id
+     * @param freq sloppy term frequency
+     * @return document's score
+     */
+    public abstract float score(int doc, float freq);
+
+    /** Computes the amount of a sloppy phrase match, based on an edit distance. */
+    public abstract float computeSlopFactor(int distance);
+    
+    /** Calculate a scoring factor based on the data in the payload. */
+    public abstract float computePayloadFactor(int doc, int start, int end, BytesRef payload);
+    
+    /**
+     * Explain the score for a single document
+     * @param doc document id
+     * @param freq Explanation of how the sloppy term frequency was computed
+     * @return document's score
+     */
+    public Explanation explain(int doc, Explanation freq) {
+      Explanation result = new Explanation(score(doc, freq.getValue()), 
+          "score(doc=" + doc + ",freq=" + freq.getValue() +"), with freq of:");
+      result.addDetail(freq);
+      return result;
+    }
+  }
+  
+  /** Stores the statistics for the indexed collection. This abstract
+   * implementation is empty; descendants of {@code Similarity} should
+   * subclass {@code Stats} and define the statistics they require in the
+   * subclass. Examples include idf, average field length, etc.
+   */
+  public static abstract class Stats {
+    
+    /** The value for normalization of contained query clauses (e.g. sum of squared weights).
+     * <p>
+     * NOTE: a Similarity implementation might not use any query normalization at all,
+     * its not required. However, if it wants to participate in query normalization,
+     * it can return a value here.
+     */
+    public abstract float getValueForNormalization();
+    
+    /** Assigns the query normalization factor and boost from parent queries to this.
+     * <p>
+     * NOTE: a Similarity implementation might not use this normalized value at all,
+     * its not required. However, its usually a good idea to at least incorporate 
+     * the topLevelBoost (e.g. from an outer BooleanQuery) into its score.
+     */
+    public abstract void normalize(float queryNorm, float topLevelBoost);
+  }
+}

Added: lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/similarities/SimilarityProvider.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/similarities/SimilarityProvider.java?rev=1160668&view=auto
==============================================================================
--- lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/similarities/SimilarityProvider.java (added)
+++ lucene/dev/branches/flexscoring/lucene/src/java/org/apache/lucene/search/similarities/SimilarityProvider.java Tue Aug 23 12:51:44 2011
@@ -0,0 +1,68 @@
+package org.apache.lucene.search.similarities;
+
+import org.apache.lucene.search.BooleanQuery;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+/**
+ * Expert: Scoring API.
+ * 
+ * Provides top-level scoring functions that aren't specific to a field,
+ * and work across multi-field queries (such as {@link BooleanQuery}).
+ * 
+ * Field-specific scoring is accomplished through {@link Similarity}.
+ * 
+ * @lucene.experimental
+ */
+public interface SimilarityProvider {
+
+  /** Computes a score factor based on the fraction of all query terms that a
+   * document contains.  This value is multiplied into scores.
+   *
+   * <p>The presence of a large portion of the query terms indicates a better
+   * match with the query, so implementations of this method usually return
+   * larger values when the ratio between these parameters is large and smaller
+   * values when the ratio between them is small.
+   *
+   * @param overlap the number of query terms matched in the document
+   * @param maxOverlap the total number of terms in the query
+   * @return a score factor based on term overlap with the query
+   */
+  public abstract float coord(int overlap, int maxOverlap);
+  
+  /** Computes the normalization value for a query given the sum of the squared
+   * weights of each of the query terms.  This value is multiplied into the
+   * weight of each query term. While the classic query normalization factor is
+   * computed as 1/sqrt(sumOfSquaredWeights), other implementations might
+   * completely ignore sumOfSquaredWeights (ie return 1).
+   *
+   * <p>This does not affect ranking, but the default implementation does make scores
+   * from different queries more comparable than they would be by eliminating the
+   * magnitude of the Query vector as a factor in the score.
+   *
+   * @param sumOfSquaredWeights the sum of the squares of query term weights
+   * @return a normalization factor for query weights
+   */
+  public abstract float queryNorm(float sumOfSquaredWeights);
+  
+  /** Returns a {@link Similarity} for scoring a field
+   * @param field field name.
+   * @return a field-specific Similarity.
+   */
+  public abstract Similarity get(String field);
+}