Hello,

I currently have a filter set up to search the content's body by using "contains." The problem is that this only searches the body and not the title.

Is there a way to create a single filter that searches both the body and title?
I have tried Search: Terms, but it does not have partial word searching (contains function) that I am looking for
-Thanks

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner’s picture

Status: Active » Fixed
FileSize
3.79 KB

Here is a view which should work for you. The key for the solution of the problem is the filter: combine

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

jibran’s picture

Title: Single Filter to search Title and Body of a node » Single Filter to search Title and Body of a node (Combine or Multiple fields filter)
geerlingguy’s picture

The key for the solution of the problem is the filter: combine

I'm trying to find this filter, but can't (using Views 7.x-3.3) find it. I know I can add views and/or groups, but there's no way that I can find to combine two text fields' exposed filters (outside of a views_query_alter()...

[Edit: Nevermind. Looks like this was added in #1421382: "Compounded Filter" - create filter for filtering several concatenated fields which, which was part of 7.x-3.4. I need to upgrade.]

Ludo.R’s picture

Hi,

I'm using Views 7.x-3.5 and try to use "Combine fields filter" on title, body and summary (which is a text field on its own).

But I don't know how to make it work. Anything that I type in the filter textfield returns all results.
It seems the keywords are not applied to the query :

SELECT node.title AS node_title, node.nid AS nid, node.language AS node_language, DATE_FORMAT((DATE_ADD('19700101', INTERVAL node.created SECOND) + INTERVAL 7200 SECOND), '%Y%m%d%H%i') AS node_created_minute
FROM 
{node} node
LEFT JOIN {field_data_body} field_data_body ON node.nid = field_data_body.entity_id
 AND (field_data_body.entity_type = 'node' AND field_data_body.deleted = '0')
LEFT JOIN {field_data_field_report_summary} field_data_field_report_summary ON node.nid = field_data_field_report_summary.entity_id
 AND (field_data_field_report_summary.entity_type = 'node' AND field_data_field_report_summary.deleted = '0')
WHERE (( (node.status = '1')
 AND (node.type IN  ('special_report'))
 AND (node.language IN  ('fr', 'und')) )
 AND( (node.title LIKE '%%' ESCAPE '\\') OR (field_data_body.body_value LIKE '%%' ESCAPE '\\') OR (field_data_field_report_summary.field_report_summary_value LIKE '%%' ESCAPE '\\') ))
ORDER BY node_created_minute DESC
LIMIT 10 OFFSET 0

Please see attached screenshot.

Any help would appreciated!

Ludo.R’s picture

Category: task » support
Status: Closed (fixed) » Active
eloiguell’s picture

Hi dolu,
Just add the fields you want to search to the view's Fields section, then add a 'Global: Combine fields filter' and select all the fields you want to search.

If doesn't work, remove filter first and create it.

http://www.midwesternmac.com/blogs/jeff-geerling/filtersearch-multiple-f...

Views 7.x-3.5 and Combine fields filter is great, i love it!

Ludo.R’s picture

Component: Miscellaneous » exposed filters
Status: Active » Closed (fixed)

Yes, I just found out yesterday.

Thanks for your help!

LTech’s picture

I'm trying to use global:combine fields filter but what ever I put in the search just comes up with 'no results found'.
I've exposed the filter, checked 'single filter' and under 'choose field for filtering' selected just a simple title field and still it doesn't work, What am I doing wrong?
Thanks

jenlampton’s picture

Issue summary: View changes

Fantastic solution, thank you! :)