|
45 | 45 | import org.elasticsearch.index.analysis.NormalizingCharFilterFactory; |
46 | 46 | import org.elasticsearch.index.analysis.TokenizerFactory; |
47 | 47 | import org.elasticsearch.index.query.BoolQueryBuilder; |
48 | | -import org.elasticsearch.index.query.DistanceFeatureQueryBuilder; |
49 | 48 | import org.elasticsearch.index.query.MatchQueryBuilder; |
50 | 49 | import org.elasticsearch.index.query.MultiMatchQueryBuilder; |
51 | 50 | import org.elasticsearch.index.query.Operator; |
@@ -1627,33 +1626,6 @@ public void testRangeQueryWithLocaleMapping() throws Exception { |
1627 | 1626 | assertHitCount(searchResponse, 2L); |
1628 | 1627 | } |
1629 | 1628 |
|
1630 | | - public void testDistanceFeatureQuery() { |
1631 | | - assertAcked(prepareCreate("test").setMapping("date", "type=date")); |
1632 | | - client().prepareIndex("test").setId("1").setSource("date", "2020-12-03T00:00:00Z").get(); |
1633 | | - client().prepareIndex("test").setId("2").setSource("date", "2020-12-02T00:00:00Z").get(); |
1634 | | - client().prepareIndex("test").setId("3").setSource("date", "2020-12-01T00:00:00Z").get(); |
1635 | | - refresh(); |
1636 | | - |
1637 | | - DistanceFeatureQueryBuilder dqb = QueryBuilders.distanceFeatureQuery( |
1638 | | - "date", new DistanceFeatureQueryBuilder.Origin("2020-12-01T00:00:00Z"), "1d"); |
1639 | | - SearchResponse searchResponse = client().prepareSearch("test").setQuery(dqb).get(); |
1640 | | - assertHitCount(searchResponse, 3L); |
1641 | | - SearchHit[] hits = searchResponse.getHits().getHits(); |
1642 | | - assertEquals(1.0f, hits[0].getScore(), 0.1f); |
1643 | | - assertEquals(0.5f, hits[1].getScore(), 0.1f); |
1644 | | - assertEquals(0.33f, hits[2].getScore(), 0.1f); |
1645 | | - |
1646 | | - DistanceFeatureQueryBuilder dqb2 = QueryBuilders.distanceFeatureQuery( |
1647 | | - "date", new DistanceFeatureQueryBuilder.Origin("2020-12-01T00:00:00Z"), "1d"); |
1648 | | - dqb2.boost(2.0f); |
1649 | | - SearchResponse searchResponse2 = client().prepareSearch("test").setQuery(dqb2).get(); |
1650 | | - assertHitCount(searchResponse2, 3L); |
1651 | | - SearchHit[] hits2 = searchResponse2.getHits().getHits(); |
1652 | | - assertEquals(2.0f, hits2[0].getScore(), 0.1f); |
1653 | | - assertEquals(1.0f, hits2[1].getScore(), 0.1f); |
1654 | | - assertEquals(0.66f, hits2[2].getScore(),0.1f); |
1655 | | - } |
1656 | | - |
1657 | 1629 | public void testSearchEmptyDoc() { |
1658 | 1630 | assertAcked(prepareCreate("test").setSettings("{\"index.analysis.analyzer.default.type\":\"keyword\"}", XContentType.JSON)); |
1659 | 1631 | client().prepareIndex("test").setId("1").setSource("{}", XContentType.JSON).get(); |
|
0 commit comments