Technical Details

Advance Search is a featured template which enables us to create a search engine based on various filters.

Advanced Search Template

There is a page template named Advanced Search. Applying this template to any Page will enable the feature on the page.

Template file page-advanced-search.php and SearchPageAdv.php File

This is the main file template page which calls SearchPageAdv.php file and the SearchPageAdv.php file contains all the functions that actually perform all search operations.

Location of SearchPageAdv:

/www/wp-content/themes/{THEME-FOLDER}/src/ViewModels/SearchPageAdv.php

Facets

Facets are the Indexfields mentioned in OC Admin dashboard. It is a variable name and meta data of articles. Each article contains some values for these facets, e.g. An article has a facet field named Section and its value is Sports. So once one will search articles of Sports the article may appear in search result.

Config JSON file

The config JSON file contains all the key values that one wanted to include in facets. Like, if you need to add 3 facets/filters on Search page then you need to mention all three Indexfields in this JSON file.

In this JSON file you can mention what values of facets (filters) you need to show on screen.

{ "facet": { "facetItems": { "Section": { "Name":"Section", "fieldName":"lvsection", "IncludedFieldsStatus":"FALSE", "IncludedFields":[ "Sport", "News", "Entertainment", "Business", "Finance" ] }, "ConceptCategoryUuids": { "Name":"Category", "fieldName":"lvcat", "IncludedFieldsStatus":"FALSE", "IncludedFields":[ "b0184795-0887-4620-9d11-f3a66e72ac42", "bad9a923-f480-4c99-83f6-61049558ad5e", "086b5ea1-9527-4907-869a-b04285f9cd00", "2c24dca5-3f7a-4983-b070-ee403f37fbc3", "7703b196-5d51-4c05-9c7d-6dac2af02559" ] }, "Channels": { "Name":"Channels", "fieldName":"lvchannels", "IncludedFieldsStatus":"FALSE", "IncludedFields":[ "Lavender", "Nigella", "Zinnia", "The Insurer", "Detroit Free Press", "Lancashire Post" ] } } } }
  1. "Section" and "Channels" are the field names displayed in the Advanced Search Page as facets.

  2. "Name":"Section" is the label used as the heading for each facet.

  3. "fieldName":"lvsection" defines the attribute name for input fields in the URL of the Advanced Search Page.

  4. "IncludedFieldsStatus":"TRUE"

    1. When "IncludedFieldsStatus" is set to TRUE: The values listed in "IncludedFields" will be displayed in the facets.

    2. When "IncludedFieldsStatus" is set to FALSE: The values specified in "IncludedFields" will be ignored. All values will be shown in the facets, regardless of what is specified in "IncludedFields.

  5. "IncludedFields" is used to add facet values for each index field. You can provide these values using either UUID or Name.

*The above points mentions "fieldName":"lvsection" where the example is taken for lavendar project, in other cases this will change based on the project.

In future if one more facet needs to be added then just adding details in JSON file will create front-end interface along with the back-end query for the new facet. JSON structure can be changed from customer to customer and accordingly codes need to change. NGINX Settings: (To set the max-age = 0 for caching) Note:here location ~ ^/(advanced-search/) will be based on title of the advanced-search template page(Example: for "Page AdvSearch" title it will be location ~ ^/(page-advsearch/)

location ~ ^/(advanced-search/) {
  # This disables the monitoring.
  fastcgi_param PHP_VALUE "newrelic.browser_monitoring.auto_instrument=0";
  # This disables the caching.
  header_filter_by_lua_block {
    ngx.header["Cache-Control"] = "max-age=" .. 0
    ngx.header["expires"] = -1
        ngx.header["disablecaching"] = 1
  }
  # The rest is to be consistent with the server vars etc are the same as for the usual PHP location.
  include common/fastcgi_params;

  fastcgi_param SCRIPT_NAME           "/index.php";
  fastcgi_param DOCUMENT_URI          "/index.php";

  fastcgi_param SCRIPT_FILENAME       $document_root/index.php;
  fastcgi_index index.php;
  fastcgi_pass php-fpm;
}

Customer/Deployed Environments List: WBM Stage

Last updated