forked from apigee/apigee-devportal-kickstart-drupal
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[apigee#334] Add apigee_kickstart_search module
- Loading branch information
Showing
9 changed files
with
1,086 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Introduction | ||
The `apigee_kickstart_search` module Adds a search page for searching content and APIs. | ||
|
||
## Installation | ||
|
||
1. Visit **Extend --> Install new module** from the admin toolbar. | ||
2. Enable the `Apigee Kickstart Search` module. | ||
3. Visit `/admin/reports/status` and click on **Run cron** to re-index content. | ||
|
||
## Customization | ||
|
||
- To add new entity types to the search index or to configure fields *boost*, see the configuration form at `/admin/config/search/search-api/index/default/edit`. | ||
- To customize the search results, see the view at `admin/structure/views/view/apigee_kickstart_search`. | ||
|
||
### Note | ||
|
||
When enabled, the `apigee_kickstart_search` module redirects all search queries from the search form in the header to the `/search`. |
9 changes: 9 additions & 0 deletions
9
modules/custom/apigee_kickstart_search/apigee_kickstart_search.info.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
name: Apigee Kickstart Search | ||
description: "Adds a search page for searching content and APIs." | ||
type: module | ||
core: 8.x | ||
package: Apigee Kickstart (Experimental) | ||
dependencies: | ||
- apigee_api_catalog:apigee_api_catalog | ||
- drupal:views | ||
- search_api:search_api_db |
40 changes: 40 additions & 0 deletions
40
modules/custom/apigee_kickstart_search/apigee_kickstart_search.module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright 2020 Google Inc. | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* version 2 as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||
* MA 02110-1301, USA. | ||
*/ | ||
|
||
use Drupal\Core\Form\FormStateInterface; | ||
|
||
/** | ||
* Implements hook_form_FORM_ID_alter(). | ||
*/ | ||
function apigee_kickstart_search_form_search_block_form_alter(&$form, FormStateInterface $form_state, $form_id) { | ||
// Set the form action to the search page. | ||
$form['#action'] = '/search'; | ||
} | ||
|
||
/** | ||
* Implements hook_preprocess_HOOK(). | ||
*/ | ||
function apigee_kickstart_search_preprocess_views_view__apigee_kickstart_search(&$variables) { | ||
// Hide the exposed form on the search page. | ||
// Default to using the search form in the site header. | ||
$variables['exposed']["#access"] = FALSE; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "drupal/apigee_kickstart_search", | ||
"license": "GPL-2.0", | ||
"type": "drupal-module", | ||
"description": "Adds a search page for searching content and APIs.", | ||
"require": { | ||
"drupal/search_api": "^1.16" | ||
}, | ||
"config": { | ||
"sort-packages": true | ||
}, | ||
"minimum-stability": "dev", | ||
"prefer-stable": true | ||
} |
247 changes: 247 additions & 0 deletions
247
modules/custom/apigee_kickstart_search/config/optional/search_api.index.default.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,247 @@ | ||
langcode: en | ||
status: true | ||
dependencies: | ||
config: | ||
- field.storage.node.body | ||
- field.storage.node.field_answer | ||
- field.storage.node.field_content | ||
- field.storage.paragraph.field_text | ||
- search_api.server.default | ||
module: | ||
- apigee_api_catalog | ||
- paragraphs | ||
- node | ||
- search_api | ||
id: default | ||
name: Default | ||
description: 'The default index for Apigee Kickstart indexes content and API docs.' | ||
read_only: false | ||
field_settings: | ||
body: | ||
label: Body | ||
datasource_id: 'entity:node' | ||
property_path: 'body:processed' | ||
type: text | ||
boost: !!float 5 | ||
dependencies: | ||
config: | ||
- field.storage.node.body | ||
description: | ||
label: Description | ||
datasource_id: 'entity:apidoc' | ||
property_path: 'description:processed' | ||
type: text | ||
boost: !!float 5 | ||
dependencies: | ||
module: | ||
- apigee_api_catalog | ||
field_answer: | ||
label: Answer | ||
datasource_id: 'entity:node' | ||
property_path: 'field_answer:processed' | ||
type: text | ||
boost: !!float 5 | ||
dependencies: | ||
config: | ||
- field.storage.node.field_answer | ||
field_content: | ||
label: 'Content » Paragraph » Text » Processed text' | ||
datasource_id: 'entity:node' | ||
property_path: 'field_content:entity:field_text:processed' | ||
type: text | ||
dependencies: | ||
config: | ||
- field.storage.node.field_content | ||
- field.storage.paragraph.field_text | ||
module: | ||
- paragraphs | ||
name: | ||
label: Name | ||
datasource_id: 'entity:apidoc' | ||
property_path: name | ||
type: text | ||
boost: !!float 8 | ||
dependencies: | ||
module: | ||
- apigee_api_catalog | ||
node_grants: | ||
label: 'Node access information' | ||
property_path: search_api_node_grants | ||
type: string | ||
indexed_locked: true | ||
type_locked: true | ||
hidden: true | ||
status: | ||
label: status | ||
datasource_id: 'entity:node' | ||
property_path: status | ||
type: boolean | ||
indexed_locked: true | ||
type_locked: true | ||
dependencies: | ||
module: | ||
- node | ||
title: | ||
label: Title | ||
datasource_id: 'entity:node' | ||
property_path: title | ||
type: text | ||
boost: !!float 8 | ||
dependencies: | ||
module: | ||
- node | ||
uid: | ||
label: uid | ||
datasource_id: 'entity:node' | ||
property_path: uid | ||
type: integer | ||
indexed_locked: true | ||
type_locked: true | ||
dependencies: | ||
module: | ||
- node | ||
datasource_settings: | ||
'entity:apidoc': | ||
languages: | ||
default: true | ||
selected: { } | ||
'entity:node': | ||
bundles: | ||
default: true | ||
selected: { } | ||
languages: | ||
default: true | ||
selected: { } | ||
processor_settings: | ||
add_url: { } | ||
aggregated_field: { } | ||
content_access: | ||
weights: | ||
preprocess_query: -30 | ||
entity_status: { } | ||
highlight: | ||
highlight: always | ||
highlight_partial: true | ||
excerpt: true | ||
excerpt_length: 256 | ||
exclude_fields: { } | ||
prefix: '<mark>' | ||
suffix: '</mark>' | ||
weights: | ||
postprocess_query: 0 | ||
html_filter: | ||
all_fields: true | ||
fields: | ||
- body | ||
- description | ||
- field_answer | ||
- field_content | ||
- name | ||
- title | ||
title: true | ||
alt: true | ||
tags: | ||
b: 2 | ||
h1: 5 | ||
h2: 3 | ||
h3: 2 | ||
strong: 2 | ||
weights: | ||
preprocess_index: -15 | ||
preprocess_query: -15 | ||
ignorecase: | ||
all_fields: true | ||
fields: | ||
- body | ||
- description | ||
- field_answer | ||
- field_content | ||
- name | ||
- title | ||
weights: | ||
preprocess_index: -20 | ||
preprocess_query: -20 | ||
language_with_fallback: { } | ||
rendered_item: { } | ||
stopwords: | ||
all_fields: true | ||
fields: | ||
- body | ||
- description | ||
- field_answer | ||
- field_content | ||
- name | ||
- title | ||
stopwords: | ||
- a | ||
- an | ||
- and | ||
- are | ||
- as | ||
- at | ||
- be | ||
- but | ||
- by | ||
- for | ||
- if | ||
- in | ||
- into | ||
- is | ||
- it | ||
- 'no' | ||
- not | ||
- of | ||
- 'on' | ||
- or | ||
- s | ||
- such | ||
- t | ||
- that | ||
- the | ||
- their | ||
- then | ||
- there | ||
- these | ||
- they | ||
- this | ||
- to | ||
- was | ||
- will | ||
- with | ||
weights: | ||
preprocess_index: -5 | ||
preprocess_query: -2 | ||
tokenizer: | ||
all_fields: true | ||
fields: | ||
- body | ||
- description | ||
- field_answer | ||
- field_content | ||
- name | ||
- title | ||
spaces: '' | ||
overlap_cjk: 1 | ||
minimum_word_size: '3' | ||
weights: | ||
preprocess_index: -6 | ||
preprocess_query: -6 | ||
transliteration: | ||
all_fields: true | ||
fields: | ||
- body | ||
- description | ||
- field_answer | ||
- field_content | ||
- name | ||
- title | ||
weights: | ||
preprocess_index: -20 | ||
preprocess_query: -20 | ||
tracker_settings: | ||
default: | ||
indexing_order: fifo | ||
options: | ||
index_directly: true | ||
cron_limit: 50 | ||
server: default |
16 changes: 16 additions & 0 deletions
16
modules/custom/apigee_kickstart_search/config/optional/search_api.server.default.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
langcode: en | ||
status: true | ||
dependencies: | ||
module: | ||
- search_api_db | ||
id: default | ||
name: Default | ||
description: 'The default server for Apigee Kickstart.' | ||
backend: search_api_db | ||
backend_config: | ||
database: 'default:default' | ||
min_chars: 1 | ||
matching: words | ||
autocomplete: | ||
suggest_suffix: true | ||
suggest_words: true |
Oops, something went wrong.