返回Elasticsearch中具有唯一标题的热门搜索结果

时间:2016-11-07 14:56:02

标签: elasticsearch

我有Elasticsearch生成的搜索结果如下:

查询:苹果派

1. title: apple pie, score: 144.67503
2. title: apple pie, score: 128.19138
3. title: apple, score: 59.768208
4. title: apple, score: 39.49909
5. title: red apple, score: 34.314064
6. title: apple red, score: 34.014064

我希望得到以下内容:

1. title: apple pie, score: 144.67503
2. title: apple, score: 59.768208
3. title: red apple, score: 34.314064
4. title: apple red, score: 34.014064

我怎样才能在Elasticsearch中做到这一点?如果在DSL中获得响应,那就太好了。

1 个答案:

答案 0 :(得分:0)

Actions action = new Actions(driver);

//1st Way
action.moveToElement(driver.findElement(By.xpath("//div[@arid='app1575']//a"))).moveToElement(driver.findElement(By.xpath("//div[@arid='app1589']//a"))).click().build().perform();

//2nd Way
   action.moveToElement(driver.findElement(By.xpath("//div[@arid='app1575']//a"))).perform();
   By locator = By.xpath("//div[@arid='app1589']//a");
   driver.findElement(locator).click();

此查询应以为您提供标题,并在scoreAgg聚合下将其评分为