org.biacode.escommons.toolkit.component.SearchResponseComponent.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of escommons-toolkit Show documentation
Show all versions of escommons-toolkit Show documentation
Elasticsearch commons library.
package org.biacode.escommons.toolkit.component
import org.biacode.escommons.core.model.document.AbstractEsDocument
import org.biacode.escommons.core.model.response.DocumentsAndTotalCount
import org.elasticsearch.action.get.GetResponse
import org.elasticsearch.action.search.SearchResponse
/**
* Created by Arthur Asatryan.
* Date: 7/10/17
* Time: 6:11 PM
*/
interface SearchResponseComponent {
/**
* Converts search response to documents and total count.
*
* @param the type parameter
* @param searchResponse the search response
* @param clazz the clazz
* @return the documents and total count
*/
fun documentsAndTotalCount(searchResponse: SearchResponse, clazz: Class): DocumentsAndTotalCount
/**
* Converts get response to documents and total count
*
* @param the type parameter
* @param getResponse the get response
* @param clazz the clazz
* @return the documents and total count
*/
fun document(getResponse: GetResponse, clazz: Class): T
/**
* Convert search response to documents list.
*
* @param the type parameter
* @param getResponse the get response
* @param clazz the clazz
* @return the documents list
*/
fun documents(getResponse: SearchResponse, clazz: Class): List
/**
* Extracts _id fields from given search response
*
* @param searchResponse the search response
* @return list of ids
*/
fun ids(searchResponse: SearchResponse): List
}