Fixed tests that failed now that BM25 is the default similarity.

This commit is contained in:
Jim Ferenczi 2016-06-21 15:42:42 +02:00
parent 0160d91c2c
commit 881afcba60
10 changed files with 38 additions and 29 deletions

View File

@ -254,10 +254,19 @@ public class DecayFunctionScoreIT extends ESIntegTestCase {
}
public void testBoostModeSettingWorks() throws Exception {
assertAcked(prepareCreate("test").addMapping(
Settings settings = Settings.builder().put(IndexMetaData.INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), 1).build();
assertAcked(prepareCreate("test").setSettings(settings)
.addMapping(
"type1",
jsonBuilder().startObject().startObject("type1").startObject("properties").startObject("test").field("type", "text")
.endObject().startObject("loc").field("type", "geo_point").endObject().endObject().endObject().endObject()));
jsonBuilder()
.startObject()
.startObject("type1")
.startObject("properties")
.startObject("test").field("type", "text").endObject()
.startObject("loc").field("type", "geo_point").endObject()
.endObject()
.endObject()
.endObject()));
ensureYellow();
List<IndexRequestBuilder> indexBuilders = new ArrayList<>();

View File

@ -86,7 +86,7 @@ public class ExplainableScriptIT extends ESIntegTestCase {
assertThat(hit.getId(), equalTo(Integer.toString(idCounter)));
assertThat(hit.explanation().toString(),
containsString(Double.toString(idCounter) + " = This script returned " + Double.toString(idCounter)));
assertThat(hit.explanation().toString(), containsString("1.0 = tf(freq=1.0), with freq of"));
assertThat(hit.explanation().toString(), containsString("freq=1.0 = termFreq=1.0"));
assertThat(hit.explanation().getDetails().length, equalTo(2));
idCounter--;
}

View File

@ -317,8 +317,8 @@ public class SimpleNestedIT extends ESIntegTestCase {
assertNoFailures(searchResponse);
assertThat(searchResponse.getHits().totalHits(), equalTo(1L));
Explanation explanation = searchResponse.getHits().hits()[0].explanation();
assertThat(explanation.getValue(), equalTo(2f));
assertThat(explanation.toString(), startsWith("2.0 = sum of:\n 2.0 = Score based on 2 child docs in range from 0 to 1"));
assertThat(explanation.getValue(), equalTo(searchResponse.getHits().getHits()[0].score()));
assertThat(explanation.toString(), startsWith("0.36464313 = sum of:\n 0.36464313 = Score based on 2 child docs in range from 0 to 1"));
}
public void testSimpleNestedSorting() throws Exception {

View File

@ -439,8 +439,8 @@ public class MultiMatchQueryIT extends ESIntegTestCase {
.setQuery(randomizeType(multiMatchQuery("marvel hero captain america", "full_name", "first_name", "last_name", "category")
.type(MultiMatchQueryBuilder.Type.CROSS_FIELDS)
.operator(Operator.OR))).get();
assertFirstHit(searchResponse, hasId("theone"));
assertSecondHit(searchResponse, hasId("theother"));
assertFirstHit(searchResponse, hasId("theother"));
assertSecondHit(searchResponse, hasId("theone"));
assertThat(searchResponse.getHits().hits()[0].getScore(), greaterThan(searchResponse.getHits().hits()[1].getScore()));
searchResponse = client().prepareSearch("test")

View File

@ -283,8 +283,8 @@ public class SearchQueryIT extends ESIntegTestCase {
searchResponse = client().prepareSearch("test").setQuery(
boolQuery().must(matchAllQuery()).must(constantScoreQuery(matchAllQuery()))).get();
assertHitCount(searchResponse, 2L);
assertThat((double)searchResponse.getHits().getAt(0).score(), closeTo(Math.sqrt(2), 0.1));
assertThat((double)searchResponse.getHits().getAt(1).score(),closeTo(Math.sqrt(2), 0.1));
assertThat((double)searchResponse.getHits().getAt(0).score(), closeTo(2.0, 0.1));
assertThat((double)searchResponse.getHits().getAt(1).score(),closeTo(2.0, 0.1));
}
}
@ -336,8 +336,8 @@ public class SearchQueryIT extends ESIntegTestCase {
searchResponse = client().prepareSearch().setQuery(commonTermsQuery("field1", "the lazy fox brown").cutoffFrequency(1).highFreqMinimumShouldMatch("3")).get();
assertHitCount(searchResponse, 2L);
assertFirstHit(searchResponse, hasId("1"));
assertSecondHit(searchResponse, hasId("2"));
assertFirstHit(searchResponse, hasId("2"));
assertSecondHit(searchResponse, hasId("1"));
searchResponse = client().prepareSearch().setQuery(commonTermsQuery("field1", "the lazy fox brown").cutoffFrequency(1).highFreqMinimumShouldMatch("4")).get();
assertHitCount(searchResponse, 1L);
@ -377,9 +377,9 @@ public class SearchQueryIT extends ESIntegTestCase {
// try the same with multi match query
searchResponse = client().prepareSearch().setQuery(multiMatchQuery("the quick brown", "field1", "field2").cutoffFrequency(3).operator(Operator.AND)).get();
assertHitCount(searchResponse, 3L);
assertFirstHit(searchResponse, hasId("1"));
assertSecondHit(searchResponse, hasId("2"));
assertThirdHit(searchResponse, hasId("3"));
assertFirstHit(searchResponse, hasId("3"));
assertSecondHit(searchResponse, hasId("1"));
assertThirdHit(searchResponse, hasId("2"));
}
public void testCommonTermsQueryStackedTokens() throws Exception {
@ -423,8 +423,8 @@ public class SearchQueryIT extends ESIntegTestCase {
searchResponse = client().prepareSearch().setQuery(commonTermsQuery("field1", "the fast lazy fox brown").cutoffFrequency(1).highFreqMinimumShouldMatch("5")).get();
assertHitCount(searchResponse, 2L);
assertFirstHit(searchResponse, hasId("1"));
assertSecondHit(searchResponse, hasId("2"));
assertFirstHit(searchResponse, hasId("2"));
assertSecondHit(searchResponse, hasId("1"));
searchResponse = client().prepareSearch().setQuery(commonTermsQuery("field1", "the fast lazy fox brown").cutoffFrequency(1).highFreqMinimumShouldMatch("6")).get();
assertHitCount(searchResponse, 1L);
@ -469,9 +469,9 @@ public class SearchQueryIT extends ESIntegTestCase {
// try the same with multi match query
searchResponse = client().prepareSearch().setQuery(multiMatchQuery("the fast brown", "field1", "field2").cutoffFrequency(3).operator(Operator.AND)).get();
assertHitCount(searchResponse, 3L);
assertFirstHit(searchResponse, hasId("1"));
assertSecondHit(searchResponse, hasId("2"));
assertThirdHit(searchResponse, hasId("3"));
assertFirstHit(searchResponse, hasId("3"));
assertSecondHit(searchResponse, hasId("1"));
assertThirdHit(searchResponse, hasId("2"));
}
public void testQueryStringAnalyzedWildcard() throws Exception {

View File

@ -88,10 +88,10 @@ If you get a hit for your indexed document, the plugin should be installed and w
"took": 53,
"hits": {
"total": 1,
"max_score": 0.3125,
"max_score": 0.25811607,
"hits": [
{
"_score": 0.3125,
"_score": 0.25811607,
"_index": "trying-out-mapper-attachments",
"_type": "person",
"_id": "1",

View File

@ -230,13 +230,13 @@ The output from the above is:
},
"hits": {
"total": 1,
"max_score": 0.4375,
"max_score": 0.2824934,
"hits": [
{
"_index": "my_index",
"_type": "my_doc",
"_id": "1",
"_score": 0.4375,
"_score": 0.2824934,
"_source": {
"text": "The fooBarBaz method"
},

View File

@ -302,13 +302,13 @@ GET my_index/_search
},
"hits": {
"total": 1,
"max_score": 0.44194174,
"max_score": 0.51623213,
"hits": [
{
"_index": "my_index",
"_type": "doc",
"_id": "1",
"_score": 0.44194174,
"_score": 0.51623213,
"_source": {
"title": "Quick Foxes"
}

View File

@ -27,13 +27,13 @@ And here is a sample response:
},
"hits":{
"total" : 1,
"max_score": 1.0,
"max_score": 0.2876821,
"hits" : [
{
"_index" : "twitter",
"_type" : "tweet",
"_id" : "0",
"_score": 1.0,
"_score": 0.2876821,
"_source" : {
"user" : "kimchy",
"date" : "2009-11-15T14:12:12",

View File

@ -114,5 +114,5 @@
term:
tag: tag1
- match: {'matches': [{_index: percolator_index, _id: test_percolator, _score: 1.0}]}
- match: {'matches': [{_index: percolator_index, _id: test_percolator, _score: 0.2876821}]}