从scala中的elastic4s获取搜索结果

时间:2015-03-16 16:34:03

标签: scala elasticsearch elastic4s

我有以下代码,我正在尝试从elasticsearch获取所有匹配。如果我尝试在没有查询部分的情况下编写,那么当我调用.getHits时,它只会给出10个结果。

    val resultFuture = client.execute {
      search in "reports/reportOutput" query{ termQuery("mainReportID", reportId.toString)}
    }.await

另一个问题是查询部分实际上没有工作,我什么也得不到。这是我的弹性搜索的结构。

"hits": {

    "total": 266,
    "max_score": 1,
    "hits":[
{
    "_index": "reports",
    "_type": "reportOutput",
    "_id": "AUwjbAuKTetnUx12_a97",
    "_score": 1,
    "_source": 
    {
        "displayName": "Classic BMW / MINI",
        "model": "Cooper Clubman",
        "dayInStock": "10",
        "stockNumber": "Q323A",
        "miles": "81093",
        "interiorColorGeneric": "Black",
        "year": "2009",
        "trimLevel": "",
        "mainReportID": "4d9e4fd3-7fdf-41c8-8c29-45c5acaf78b1",
        "modelNumber": "",
        "exteriorColorGeneric": "White",
        "exteriorColor": "Pepper White",
        "vin": "WMWML33509TX35944",
        "make": "MINI",
        "transmission": "A",
        "exteriorColorCode": "850",
        "interiorColor": "Gray/Carbon Black",
        "interiorColorCode": "K8E1"
    }
},

1 个答案:

答案 0 :(得分:0)

您可以通过设置请求限制来增加返回的结果数量,例如:

search in "index" limit 100

但默认限制10不是由elastic4s设置,而是由elasticsearch itself设置,并且您无法更改它以默认返回所有结果。