package dp.kotul.solrapimodel

import io.swagger.annotations.ApiModel
import io.swagger.annotations.ApiModelProperty

private const val QUERY_VALUE = "*:*"
private const val QUERY_NOTES = "Query string"

private const val FILTER_QUERY_VALUE = "(assetType:TEMPLATE OR assetType:TEMPLATE_GROUP)"
private const val FILTER_QUERY_NOTES = "Filter string, only documents matching these filters are returned"

private const val FIELD_LIST_VALUE = "title"
private const val FIELD_LIST_NOTES = "Filter list, specifies which fields from the documents to return"

private const val SORT_VALUE = "_docid_ DESC"
private const val SORT_NOTES = "Sorts returned documents by this field"

private const val START_VALUE = "0"
private const val START_NOTES = "Skip specified number of documents from top of the search"

private const val ROWS_VALUE = "10"
private const val ROWS_NOTES = "List specified number of rows"

private const val DEFAULT_QUERY_VALUE = "\"*:*\""
private const val DEFAULT_START = 0
private const val DEFAULT_ROWS = 10

@ApiModel(value = "Solr Search Parameters")
data class SolrApiSearchParameters(
        @ApiModelProperty(allowableValues = QUERY_VALUE, value = QUERY_NOTES)
        val q: String = DEFAULT_QUERY_VALUE,
        @ApiModelProperty(allowableValues = FILTER_QUERY_VALUE, value = FILTER_QUERY_NOTES)
        val fq: String? = null,
        @ApiModelProperty(allowableValues = FIELD_LIST_VALUE, value = FIELD_LIST_NOTES)
        val fl: List<String>? = null,
        @ApiModelProperty(allowableValues = SORT_VALUE, value = SORT_NOTES)
        val sort: List<String>? = null,
        @ApiModelProperty(allowableValues = START_VALUE, value = START_NOTES)
        val start: Int? = DEFAULT_START,
        @ApiModelProperty(allowableValues = ROWS_VALUE, value = ROWS_NOTES)
        val rows: Int? = DEFAULT_ROWS
)
