All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sksamuel.elastic4s.handlers.searches.queries.PercolateQueryBodyFn.scala Maven / Gradle / Ivy

package com.sksamuel.elastic4s.handlers.searches.queries

import com.sksamuel.elastic4s.json.{XContentBuilder, XContentFactory}
import com.sksamuel.elastic4s.requests.searches.queries.PercolateQuery

object PercolateQueryBodyFn {

  def apply(q: PercolateQuery): XContentBuilder = {
    val builder = XContentFactory.jsonBuilder()
    builder.startObject("percolate")
    builder.field("field", q.field)
    q.ref.foreach { ref =>
      builder.field("index", ref.index.name)
      builder.field("id", ref.id)
    }
    q.source.foreach { source =>
      builder.rawField("document", source)
    }
    builder.endObject()
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy