use of org.apache.lucene.search.similarities.LMJelinekMercerSimilarity in project lucene-solr by apache.
the class TestLMJelinekMercerSimilarityFactory method testParameters.
/** jelinek-mercer with parameters */
public void testParameters() throws Exception {
Similarity sim = getSimilarity("text_params");
assertEquals(LMJelinekMercerSimilarity.class, sim.getClass());
LMJelinekMercerSimilarity lm = (LMJelinekMercerSimilarity) sim;
assertEquals(0.4f, lm.getLambda(), 0.01f);
}
use of org.apache.lucene.search.similarities.LMJelinekMercerSimilarity in project lucene-solr by apache.
the class LMJelinekMercerSimilarityFactory method getSimilarity.
@Override
public Similarity getSimilarity() {
LMJelinekMercerSimilarity sim = new LMJelinekMercerSimilarity(lambda);
sim.setDiscountOverlaps(discountOverlaps);
return sim;
}
use of org.apache.lucene.search.similarities.LMJelinekMercerSimilarity in project elasticsearch by elastic.
the class SimilarityTests method testResolveSimilaritiesFromMapping_LMJelinekMercer.
public void testResolveSimilaritiesFromMapping_LMJelinekMercer() throws IOException {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties").startObject("field1").field("type", "text").field("similarity", "my_similarity").endObject().endObject().endObject().endObject().string();
Settings indexSettings = Settings.builder().put("index.similarity.my_similarity.type", "LMJelinekMercer").put("index.similarity.my_similarity.lambda", 0.7f).build();
IndexService indexService = createIndex("foo", indexSettings);
DocumentMapper documentMapper = indexService.mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
assertThat(documentMapper.mappers().getMapper("field1").fieldType().similarity(), instanceOf(LMJelinekMercerSimilarityProvider.class));
LMJelinekMercerSimilarity similarity = (LMJelinekMercerSimilarity) documentMapper.mappers().getMapper("field1").fieldType().similarity().get();
assertThat(similarity.getLambda(), equalTo(0.7f));
}
Aggregations