<commit_before>package uk.ac.wellcome.platform.api.services

import com.sksamuel.elastic4s.http.ElasticDsl._
import com.sksamuel.elastic4s.http.HttpClient
import com.sksamuel.elastic4s.http.get.GetResponse
import com.sksamuel.elastic4s.http.search.SearchResponse
import com.twitter.inject.annotations.Flag
import javax.inject.{Inject, Singleton}

import scala.concurrent.Future

@Singleton
class ElasticSearchService @Inject()(@Flag("es.type") documentType: String,
                                     elasticClient: HttpClient) {

  def findResultById(canonicalId: String,
                     indexName: String): Future[GetResponse] =
    elasticClient
      .execute {
        get(canonicalId).from(s"${indexName}/$documentType")
      }

  def listResults(sortByField: String,
                  indexName: String,
                  limit: Int = 10,
                  from: Int = 0): Future[SearchResponse] =
    elasticClient
      .execute {
        search(s"${indexName}/$documentType")
          .query(termQuery("visible", true))
          .sortBy(fieldSort(sortByField))
          .limit(limit)
          .from(from)
      }

  def simpleStringQueryResults(queryString: String,
                               limit: Int = 10,
                               from: Int = 0,
                               indexName: String): Future[SearchResponse] =
    elasticClient
      .execute {
        search(s"${indexName}/$documentType")
          .query(
            must(
              simpleStringQuery(queryString),
              termQuery("visible", true)
            ))
          .limit(limit)
          .from(from)
      }

}
<commit_msg>Don't use @Flag in ElasticSearchService<commit_after>package uk.ac.wellcome.platform.api.services

import com.sksamuel.elastic4s.http.ElasticDsl._
import com.sksamuel.elastic4s.http.HttpClient
import com.sksamuel.elastic4s.http.get.GetResponse
import com.sksamuel.elastic4s.http.search.SearchResponse
import javax.inject.{Inject, Singleton}

import uk.ac.wellcome.elasticsearch.ElasticConfig

import scala.concurrent.Future

@Singleton
class ElasticSearchService @Inject()(elasticClient: HttpClient,
                                     elasticConfig: ElasticConfig) {

  val documentType = elasticConfig.documentType

  def findResultById(canonicalId: String,
                     indexName: String): Future[GetResponse] =
    elasticClient
      .execute {
        get(canonicalId).from(s"${indexName}/$documentType")
      }

  def listResults(sortByField: String,
                  indexName: String,
                  limit: Int = 10,
                  from: Int = 0): Future[SearchResponse] =
    elasticClient
      .execute {
        search(s"${indexName}/$documentType")
          .query(termQuery("visible", true))
          .sortBy(fieldSort(sortByField))
          .limit(limit)
          .from(from)
      }

  def simpleStringQueryResults(queryString: String,
                               limit: Int = 10,
                               from: Int = 0,
                               indexName: String): Future[SearchResponse] =
    elasticClient
      .execute {
        search(s"${indexName}/$documentType")
          .query(
            must(
              simpleStringQuery(queryString),
              termQuery("visible", true)
            ))
          .limit(limit)
          .from(from)
      }

}

{'fraction_non_alphanumeric': 0.10101010101010101, 'fraction_numerical': 0.0059417706476530005, 'mean_word_length': 2.0224416517055657, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3878094', 'n_tokens_mistral': 957, 'n_tokens_neox': 917, 'n_words': 158}