如何将自定义Json添加到elastic4s搜索中

时间:2017-08-01 16:00:19

标签: elastic4s

有没有办法让elastic4s允许我构建这个搜索请求:

 {
  "size" : 100,
  "query" : {
    "bool" : {
      "must" : {
        "term" : {
          "disabled" : false
        }
      }
    }
  },
  "gas-filter" : {
      "name" : "SearchResultCypherFilter",
      "query" : "MATCH (a)-[:KNOWS*]->(d{referenceId:'522d8b956819338605a53948c5dcef1a'}) RETURN distinct a.referenceId as guid",
      "exclude" : true
    }
  }

1 个答案:

答案 0 :(得分:0)

elastic4s版本2.3.1及更高版本允许您添加额外的源Json

search in "maalka" bool matchAllQuery limit 10 extraSource Json.stringify(Json.obj(
  "gas-filter" -> Json.obj(
      "name" -> "SearchResultCypherFilter",
      "query" -> "MATCH (a)-[:KNOWS*]->(d{referenceId:'522d8b956819338605a53948c5dcef1a'}) RETURN distinct a.referenceId as guid",
      "exclude" -> true)
))