I’m trying to query some nodes by a given string checking if the string is either in the node title OR if the string is an exact match of concatenating the value of two strings.
I know this should be possible in normal mysql but not sure it can be translated in an entity query. Has anyone stumbled upon this problem before?
Is there some sort of ‘free text’ condition which is not tied up to fields.
At the moment the below code complains about the fact that CONCAT_WS(…) is not a field which is true.
Maybe there is a simpler solution to this but I’m just not seeing it.
$query = Drupal::entityQuery('node') ->condition('status', 1) ->condition('type', 'CONTENT_TYPE'); $group = $query->orConditionGroup() ->condition('title', $string , 'CONTAINS') ->condition("CONCAT_WS('',FIELD_1,FIELD_2)", $string); $query->condition($group); $nids = $query->execute();