I am able to reproduce this bug on a clean d7.21 with views 7.x-3.6 and 7.x-3.5
All I did was create a single node with some text in the body and created a view of all node types with Search Term added to the filter and exposed. When I search for a single word or multiple words that are over the minimum word length it works. When I search for two words, one over the minimum length and one under the view returns multiple entries of the one node. Using Distinct does not help either.
The text I used in the body of my node was
"This is a test of the emergency broadcasting system!"
Searching for "emergency" returns the node
Searching for "emergency system" returns the node
Searching for "emergency a" returns the node twice.
I also tested this search on the default search system www.site.com/search and it works fine.
Here is an export of the view I created
$view = new view();
$view->name = 'test_search';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'node';
$view->human_name = 'test search';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'test search';
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['query']['options']['distinct'] = TRUE;
$handler->display->display_options['query']['options']['pure_distinct'] = TRUE;
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['pager']['options']['items_per_page'] = '10';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['row_plugin'] = 'node';
/* Field: Content: Title */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'node';
$handler->display->display_options['fields']['title']['field'] = 'title';
$handler->display->display_options['fields']['title']['label'] = '';
$handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE;
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE;
/* Sort criterion: Content: Post date */
$handler->display->display_options['sorts']['created']['id'] = 'created';
$handler->display->display_options['sorts']['created']['table'] = 'node';
$handler->display->display_options['sorts']['created']['field'] = 'created';
$handler->display->display_options['sorts']['created']['order'] = 'DESC';
/* Filter criterion: Content: Published */
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'node';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['value'] = 1;
$handler->display->display_options['filters']['status']['group'] = 1;
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
/* Filter criterion: Search: Search Terms */
$handler->display->display_options['filters']['keys']['id'] = 'keys';
$handler->display->display_options['filters']['keys']['table'] = 'search_index';
$handler->display->display_options['filters']['keys']['field'] = 'keys';
$handler->display->display_options['filters']['keys']['operator'] = 'required';
$handler->display->display_options['filters']['keys']['exposed'] = TRUE;
$handler->display->display_options['filters']['keys']['expose']['operator_id'] = 'keys_op';
$handler->display->display_options['filters']['keys']['expose']['label'] = 'Search Terms';
$handler->display->display_options['filters']['keys']['expose']['operator'] = 'keys_op';
$handler->display->display_options['filters']['keys']['expose']['identifier'] = 'keys';
$handler->display->display_options['filters']['keys']['expose']['remember_roles'] = array(
2 => '2',
1 => 0,
3 => 0,
);
/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page');
$handler->display->display_options['path'] = 'test-search';
Comments
Comment #1
StevenJay CreditAttribution: StevenJay commentedAfter further investigation I believe this is caused by the 'score' field being added to the GROUP_BY list in the search. Because score is almost always unique search results are never grouped and therefore not counted properly. All the views fields are added to the GROUP_BY including the score based on the logic in the views_plugin_query_default.inc files query function around line 1328.
For those who need a quick fix I used hook_views_pre_execute to remove the score from the group.
Comment #2
codewhisper CreditAttribution: codewhisper commentedThanks for the hint. This solves the problem on my side as well!
Comment #3
TechNikh CreditAttribution: TechNikh commentedAwesome!. that worked like a charm.
now searching with quotes doesn't return multiple results.
Comment #4
esmerel CreditAttribution: esmerel commentedComment #5
TechNikh CreditAttribution: TechNikh commentedisin't this a bug and should be committed to views module?
Comment #6
esmerel CreditAttribution: esmerel commentedIf someone wants to make a patch and see if it'll get committed, sure. It looks to me more or less like that's how it has to work, but if one of the other maintainers wants to disagree, that's fine too.
Comment #7.0
(not verified) CreditAttribution: commentedAdded an example
Comment #8
happysnowmantech CreditAttribution: happysnowmantech commentedThis is likely a duplicate of #1677692: Remove duplicates from exposed search filter results. I believe a fix has been commited.
For problems like the "GROUP BY score" mentioned in #1, or if you go from having duplicates to having fewer than expected results, also try related issue #1615438: Search terms: nodes dont appear when using multiple arguments.