Class SchemaSimilarityFactory
- java.lang.Object
-
- org.apache.solr.schema.SimilarityFactory
-
- org.apache.solr.search.similarities.SchemaSimilarityFactory
-
- All Implemented Interfaces:
SolrCoreAware
public class SchemaSimilarityFactory extends SimilarityFactory implements SolrCoreAware
SimilarityFactory
that returns a globalPerFieldSimilarityWrapper
that delegates to the field type, if it's configured. For field types that do not have aSimilarity
explicitly configured, the globalSimilarity
will use per fieldtype defaults -- either based on an explicitly configureddefaultSimFromFieldType
a sensible default:luceneMatchVersion >= 8.0
=BM25Similarity
The
defaultSimFromFieldType
option accepts the name of any fieldtype, and uses whateverSimilarity
is explicitly configured for that fieldType as the default for all other field types. For example:<similarity class="solr.SchemaSimilarityFactory" > <str name="defaultSimFromFieldType">type-using-custom-dfr</str> </similarity> ... <fieldType name="type-using-custom-dfr" class="solr.TextField"> ... <similarity class="solr.DFRSimilarityFactory"> <str name="basicModel">I(F)</str> <str name="afterEffect">B</str> <str name="normalization">H3</str> <float name="mu">900</float> </similarity> </fieldType>
In the example above, any fieldtypes that do not define their own
</similarity/>
will use theSimilarity
configured for thetype-using-custom-dfr
.NOTE: Users should be aware that even when this factory uses a single default
Similarity
for some or all fields in a Query, the behavior can be inconsistent with the behavior of explicitly configuring that sameSimilarity
globally, because of differences in how some multi-field / multi-clause behavior is defined inPerFieldSimilarityWrapper
.- See Also:
FieldType.getSimilarity()
-
-
Field Summary
-
Fields inherited from class org.apache.solr.schema.SimilarityFactory
CLASS_NAME, params
-
-
Constructor Summary
Constructors Constructor Description SchemaSimilarityFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.apache.lucene.search.similarities.Similarity
getSimilarity()
void
inform(SolrCore core)
void
init(org.apache.solr.common.params.SolrParams args)
-
Methods inherited from class org.apache.solr.schema.SimilarityFactory
getClassArg, getNamedPropertyValues, getParams
-
-
-
-
Method Detail
-
inform
public void inform(SolrCore core)
- Specified by:
inform
in interfaceSolrCoreAware
-
init
public void init(org.apache.solr.common.params.SolrParams args)
- Overrides:
init
in classSimilarityFactory
-
getSimilarity
public org.apache.lucene.search.similarities.Similarity getSimilarity()
- Specified by:
getSimilarity
in classSimilarityFactory
-
-