Field Collection另类?需要通过Search API(Drupal 7)搜索子字段

时间:2014-03-11 00:12:12

标签: drupal-7 drupal-views drupal-search drupal-field-collection

我希望找到Field Collection模块的替代方案。问题是我想搜索(我正在使用Search API + Views)字段集合中的子字段。

例如,如果我有一个字段集合“字段”,如Research Paper,则包含以下字段: -

  • 研究题目
  • PDF文件。

我可以在我的网页中添加尽可能多的Research Papers,其中我添加了Research Paper作为内容类型。

以下是我添加的典型研究论文: -

  • “Botany”,“寻找可持续的blah blah.pdf来源”
  • “经济学”,“客户支出与天气状况相关性研究.pdf”
  • “数学”,“估计Rational numbers.pdf中的Pi系列”

现在,问题出现了,如果我通过搜索API通过视图创建搜索页面,并搜索“可持续的blah blah来源”,我怎样才能获得“研究论文”的链接“植物学”的入口,“寻找可持续的blah blah.pdf来源”?

我正在使用视图并搜索“全文搜索(已曝光)”。

以下是视图,以防万一:

$view = new view;
$view->name = 'advanced_search';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'search_api_index_advanced_search_index';
$view->human_name = 'Advanced 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'] = 'Advanced Search';
$handler->display->display_options['access']['type'] = 'none';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['exposed_form']['options']['submit_button'] = 'Search';
$handler->display->display_options['exposed_form']['options']['autosubmit'] = 0;
$handler->display->display_options['exposed_form']['options']['autosubmit_hide'] = 1;
$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'] = 'fields';
/* Field: Indexed Node: Title */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'search_api_index_advanced_search_index';
$handler->display->display_options['fields']['title']['field'] = 'title';
$handler->display->display_options['fields']['title']['label'] = '';
$handler->display->display_options['fields']['title']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['title']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['title']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['title']['alter']['external'] = 0;
$handler->display->display_options['fields']['title']['alter']['replace_spaces'] = 0;
$handler->display->display_options['fields']['title']['alter']['trim_whitespace'] = 0;
$handler->display->display_options['fields']['title']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['title']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['title']['alter']['trim'] = 0;
$handler->display->display_options['fields']['title']['alter']['html'] = 0;
$handler->display->display_options['fields']['title']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['title']['element_default_classes'] = 1;
$handler->display->display_options['fields']['title']['hide_empty'] = 0;
$handler->display->display_options['fields']['title']['empty_zero'] = 0;
$handler->display->display_options['fields']['title']['hide_alter_empty'] = 1;
$handler->display->display_options['fields']['title']['link_to_entity'] = 1;
/* Field: Indexed Node: The main body text » Summary */
$handler->display->display_options['fields']['body_summary']['id'] = 'body_summary';
$handler->display->display_options['fields']['body_summary']['table'] = 'search_api_index_advanced_search_index';
$handler->display->display_options['fields']['body_summary']['field'] = 'body_summary';
$handler->display->display_options['fields']['body_summary']['label'] = '';
$handler->display->display_options['fields']['body_summary']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['body_summary']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['body_summary']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['body_summary']['alter']['external'] = 0;
$handler->display->display_options['fields']['body_summary']['alter']['replace_spaces'] = 0;
$handler->display->display_options['fields']['body_summary']['alter']['trim_whitespace'] = 0;
$handler->display->display_options['fields']['body_summary']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['body_summary']['alter']['max_length'] = '200';
$handler->display->display_options['fields']['body_summary']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['body_summary']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['body_summary']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['body_summary']['alter']['trim'] = 1;
$handler->display->display_options['fields']['body_summary']['alter']['html'] = 0;
$handler->display->display_options['fields']['body_summary']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['body_summary']['element_default_classes'] = 1;
$handler->display->display_options['fields']['body_summary']['empty'] = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam vitae est id metus vestibulum mattis. Donec sed dictum sapien. Proin facilisis vehicula elit nec molestie. Nullam scelerisque, urna non venenatis mattis, dolor neque ultricies tellus, quis lacinia mi ligula id risus. Curabitur congue gravida quam. Maecenas et luctus dui. Aliquam erat volutpat ...';
$handler->display->display_options['fields']['body_summary']['hide_empty'] = 0;
$handler->display->display_options['fields']['body_summary']['empty_zero'] = 1;
$handler->display->display_options['fields']['body_summary']['hide_alter_empty'] = 0;
$handler->display->display_options['fields']['body_summary']['link_to_entity'] = 0;
/* Field: Document Category » Uploaded File » The file.: Title Text (indexed) */
$handler->display->display_options['fields']['field_document_cat_field_field_document_file_field_file_image_title_text']['id'] = 'field_document_cat_field_field_document_file_field_file_image_title_text';
$handler->display->display_options['fields']['field_document_cat_field_field_document_file_field_file_image_title_text']['table'] = 'search_api_index_advanced_search_index';
$handler->display->display_options['fields']['field_document_cat_field_field_document_file_field_file_image_title_text']['field'] = 'field_document_cat_field_field_document_file_field_file_image_title_text';
$handler->display->display_options['fields']['field_document_cat_field_field_document_file_field_file_image_title_text']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['field_document_cat_field_field_document_file_field_file_image_title_text']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['field_document_cat_field_field_document_file_field_file_image_title_text']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['field_document_cat_field_field_document_file_field_file_image_title_text']['alter']['external'] = 0;
$handler->display->display_options['fields']['field_document_cat_field_field_document_file_field_file_image_title_text']['alter']['replace_spaces'] = 0;
$handler->display->display_options['fields']['field_document_cat_field_field_document_file_field_file_image_title_text']['alter']['trim_whitespace'] = 0;
$handler->display->display_options['fields']['field_document_cat_field_field_document_file_field_file_image_title_text']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['field_document_cat_field_field_document_file_field_file_image_title_text']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['field_document_cat_field_field_document_file_field_file_image_title_text']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['field_document_cat_field_field_document_file_field_file_image_title_text']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['field_document_cat_field_field_document_file_field_file_image_title_text']['alter']['trim'] = 0;
$handler->display->display_options['fields']['field_document_cat_field_field_document_file_field_file_image_title_text']['alter']['html'] = 0;
$handler->display->display_options['fields']['field_document_cat_field_field_document_file_field_file_image_title_text']['element_label_colon'] = 1;
$handler->display->display_options['fields']['field_document_cat_field_field_document_file_field_file_image_title_text']['element_default_classes'] = 1;
$handler->display->display_options['fields']['field_document_cat_field_field_document_file_field_file_image_title_text']['hide_empty'] = 0;
$handler->display->display_options['fields']['field_document_cat_field_field_document_file_field_file_image_title_text']['empty_zero'] = 0;
$handler->display->display_options['fields']['field_document_cat_field_field_document_file_field_file_image_title_text']['hide_alter_empty'] = 1;
$handler->display->display_options['fields']['field_document_cat_field_field_document_file_field_file_image_title_text']['field_api_classes'] = 0;
/* Filter criterion: Search: Fulltext search */
$handler->display->display_options['filters']['search_api_views_fulltext']['id'] = 'search_api_views_fulltext';
$handler->display->display_options['filters']['search_api_views_fulltext']['table'] = 'search_api_index_advanced_search_index';
$handler->display->display_options['filters']['search_api_views_fulltext']['field'] = 'search_api_views_fulltext';
$handler->display->display_options['filters']['search_api_views_fulltext']['group'] = 1;
$handler->display->display_options['filters']['search_api_views_fulltext']['exposed'] = TRUE;
$handler->display->display_options['filters']['search_api_views_fulltext']['expose']['operator_id'] = 'search_api_views_fulltext_op';
$handler->display->display_options['filters']['search_api_views_fulltext']['expose']['label'] = 'Search me';
$handler->display->display_options['filters']['search_api_views_fulltext']['expose']['use_operator'] = 1;
$handler->display->display_options['filters']['search_api_views_fulltext']['expose']['operator'] = 'search_api_views_fulltext_op';
$handler->display->display_options['filters']['search_api_views_fulltext']['expose']['identifier'] = 'search_api_views_fulltext';
$handler->display->display_options['filters']['search_api_views_fulltext']['expose']['required'] = 1;
$handler->display->display_options['filters']['search_api_views_fulltext']['fields'] = array(
  'title' => 'title',
  'body:value' => 'body:value',
  'field_document_cat_field:field_document:file:name' => 'field_document_cat_field:field_document:file:name',
  'field_document_cat_field:field_document:file:field_file_image_title_text' => 'field_document_cat_field:field_document:file:field_file_image_title_text',
);

/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page');
$handler->display->display_options['path'] = 'advanced-search';

1 个答案:

答案 0 :(得分:0)