Add 'Or Condition' to specific field in Entity Query I'm building an entity query and I would like to check if one field contains one string or another. I'm building the query like so.

$searchname = 'test'; 
$searchtype' = 'type_1';

$query-&gt;condition('status', NODE_PUBLISHED);
$query-&gt;condition('field_type', $searchtype); 
$query-&gt;sort('created','DESC');


However I'd like to check if field_type is either $searchtype or 'both'
I attempted to do so using an orConditionGroup like so

$orCondition = $query-&gt;orConditionGroup();
$query-&gt;condition('status', NODE_PUBLISHED);
$orCondition-&gt;condition('status', NODE_PUBLISHED);

$query-&gt;condition('field_type', $searchtype); 
$orCondition-&gt;condition('field_type','both');
$query-&gt;condition($orCondition);
$query-&gt;sort('created','DESC');
$nids = $query-&gt;execute();


However it acts like the orCondition isn't being considered at all. Using $orCondition it still does not produce nodes that have 'field_type' = 'both'. How would you go about checking whether a field contains one string or another in an entity query?

UPDATE: I added the field name to the or condition because I figured I would need to add it to both if I want it checked in both conditions. If there's a way around that, that'd be even better.

UPDATE 2:  I made a second attempt using this code but I receive a 504 Timeout error when loading the page

$searchtype = 'test';
$query        = \Drupal::entityQuery('node');
$conditionOne = $query-&gt;orConditionGroup();
$conditionTwo = $query-&gt;orConditionGroup();

$conditionOne-&gt;condition('status', NODE_PUBLISHED);
$conditionTwo-&gt;condition('status', NODE_PUBLISHED);

$conditionOne-&gt;condition('field_type', $searchtype); 
$conditionTwo-&gt;condition('field_type','both');

$query-&gt;condition($conditionOne);
$query-&gt;condition($conditionTwo);
$query-&gt;sort('created', 'DESC');
$nids = $query-&gt;execute();


What I'm ultimately trying to accomplish is this logic

(status = true) AND (field_type = 'foo' or 'both')
So, the simplest way to rewrite this, would be:

$searchname = 'test'; 
$searchtype = 'type_1';

$field_types_array = [$searchtype, 'both'];
$query-&gt;condition('status', NODE_PUBLISHED);
$query-&gt;condition('field_type', $field_types_array, 'IN');
$query-&gt;sort('created','DESC');


The use of an array for the condition method forces the SQL query to be written as an IN query.

Reference documentation: QueryInterface::condition