/**
  * Map field value to a proper Solr representation
  *
  * @param Criterion $criterion
  * @param CriterionVisitor $subVisitor
  *
  * @return string
  */
 public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null)
 {
     $queries = array("text:" . $criterion->value);
     foreach ($criterion->boost as $field => $boost) {
         $fields = $this->fieldMap->getFieldTypes($criterion);
         if (!isset($fields[$field])) {
             continue;
         }
         foreach ($fields[$field] as $fieldNames) {
             foreach ($fieldNames as $fieldName) {
                 $queries[] = $fieldName . ":" . $criterion->value . "^" . $boost;
             }
         }
     }
     return "(" . implode(') OR (', array_map(function ($search) use($criterion) {
         return $search . ($criterion->fuzziness < 1 ? sprintf("~%.1f", $criterion->fuzziness) : "");
     }, $queries)) . ")";
 }
 /**
  * Get field type information
  *
  * @param \eZ\Publish\API\Repository\Values\Content\Query\CustomFieldInterface $sortClause
  *
  * @return array
  */
 protected function getFieldTypes(CustomFieldInterface $sortClause)
 {
     return $this->fieldMap->getFieldTypes($sortClause);
 }
Esempio n. 3
0
 /**
  * Get field type information
  *
  * @param CustomFieldInterface $criterion
  * @return array
  */
 protected function getFieldTypes(CustomFieldInterface $criterion)
 {
     return $this->fieldMap->getFieldTypes($criterion);
 }