private def makeQueryBit()

in media-api/app/lib/elasticsearch/QueryBuilder.scala [49:85]


  private def makeQueryBit(condition: Match): Query = condition.field match {
    case AnyField => makeMultiQuery(condition.value, matchFields)
    case MultipleField(fields) => makeMultiQuery(condition.value, fields)
    case SingleField(field) => condition.value match {
      // Force AND operator else it will only require *any* of the words, not *all*
      case Words(value) =>
        matchQuery(resolveFieldPath(field), value).operator(Operator.AND)
      case Phrase(value) => value match {
        case "Added to Photo Sales" =>
          matchPhraseQuery(resolveFieldPath(field), "syndication")
        case _ => matchPhraseQuery(resolveFieldPath(field), value)
      }
      case DateRange(start, end) => rangeQuery(resolveFieldPath(field)).gte(printDateTime(start)).lte(printDateTime(end))
      case e => throw InvalidQuery(s"Cannot do single field query on $e")
    }
    case HierarchyField => condition.value match {
      case Phrase(value) => termQuery(resolveFieldPath("pathHierarchy"), value)
      case _ => throw InvalidQuery("Cannot accept non-Phrase value for HierarchyField Match")
    }
    case HasField => condition.value match {
      case HasValue(value) => boolQuery().filter(existsQuery(resolveFieldPath(value)))
      case _ => throw InvalidQuery(s"Cannot perform has field on ${condition.value}")
    }
    case IsField => condition.value match {
      case IsValue(value) => IsQueryFilter.apply(value, overQuotaAgencies, config) match {
        case Some(isQuery) => isQuery.query
        case _ => {
          logger.info(s"Cannot perform IS query on ${condition.value}")
          matchNoneQuery()
        }
      }
      case _ => {
        logger.info(s"Cannot perform IS query on ${condition.value}")
        matchNoneQuery()
      }
    }
  }