EntityFieldQuery to search Content Type for text and select matching Nodes I have created Search page which searches Products (Content type) by selecting few option drop down menus (those are selecting taxonomy terms), but also i have an text input field, which is supposed to narrow or define search by keywords.

Now problem is that i need to search several fields at same time.

This script works perfectly (snippet):

$keywords=$_POST ['keywords'];
$query = new EntityFieldQuery();
$entities = $query-&gt;entityCondition('entity_type', 'node')
-&gt;propertyCondition('type', 'product')
-&gt;fieldCondition('field_main_category', 'tid', $category, 'IN') 
-&gt;fieldCondition('field_sku', 'value','%'. $keywords .'%', 'LIKE'); 
$result = $query-&gt;execute();


I got all the product that are matching user entry, even if partial (those %).
But i need to query some other fields too (description and name), to search for terms that user may enter. 

But, problem is that i must have one input field, and user may target 3 different fields, so three fieldConditions for same term will cause nothing to be found, because selection is excluding all  if term is not found in one field.

Could I,some way, write EntityFieldQuery query in a way to tell it to "forget" condition if keyword is not found ? (like in bellow example)

$keywords=$_POST ['keywords'];
$query = new EntityFieldQuery();
$entities = $query-&gt;entityCondition('entity_type', 'node')
-&gt;propertyCondition('type', 'product')
-&gt;fieldCondition('field_main_category', 'tid', $category, 'IN') 
-&gt;fieldCondition('field_sku', 'value','%'. $keywords .'%', 'LIKE'); 
-&gt;fieldCondition('field_name', 'value','%'. $keywords .'%', 'LIKE'); 
-&gt;fieldCondition('field_description', 'value','%'. $keywords .'%', 'LIKE'); 
$result = $query-&gt;execute();


Other workaround could be to look all three fields in one place, if i could get combined fields in one condition query (this could be done by hand, by adding another field only for search terms that will be filled with tags that will be searchable summary of all 3 fields, but i am hoping to find the way not to create more field and content, if possible).

Any suggestions or experiences with that ?
Thanks!
Do you mean something like this;

$keywords=$_POST ['keywords'];

$query = new EntityFieldQuery();
$entities = $query-&gt;entityCondition('entity_type', 'node')
-&gt;propertyCondition('type', 'product')
-&gt;fieldCondition('field_main_category', 'tid', $category, 'IN');

if(isset($keywords)) {
 $query  
   -&gt;fieldCondition('field_sku', 'value','%'. $keywords .'%', 'LIKE');
} 
$result = $query-&gt;execute();


UPDATE

You can do an OR for each of the field. SO to do this you add a tag to the query which you are building and then you can alter the query using the hook_query_TAG_alter

    $keywords=$_POST ['keywords'];

    $query = new EntityFieldQuery();
    $entities = $query-&gt;entityCondition('entity_type', 'node')
    -&gt;propertyCondition('type', 'product')
    -&gt;addTag('something');

    $result = $query-&gt;execute();


function modulename_query_**something**_alter(QueryAlterableInterface $query) {
  $or = db_or()
    -&gt;fieldCondition('field_sku', 'value','%'. $keywords .'%', 'LIKE')
    -&gt;fieldCondition('field_name', 'value','%'. $keywords .'%', 'LIKE');

  $query
      -&gt;condition($or);
}


This is just and example and you will have to make changes as per your requirements but this OR will definitely help.

Refer to the following links for a good example;
http://treehouseagency.com/blog/tim-cosgrove/2012/02/16/entityfieldquery-let-drupal-do-heavy-lifting-pt-1
http://treehouseagency.com/blog/neil-hastings/2011/09/06/building-energygov-without-views
http://treehouseagency.com/blog/fredric-mitchell/2012/02/21/or-queries-entityfieldquery