How to Configure the Advanced Search Module

About Advanced Search

The Advanced Search component allows users to combine search terms by setting specific parameters for results.

  • Typically, search results are smaller and more relevant than results from a basic search. 

Limitations

Some SmartHub Features are unsupported by some backends.

For information about limitations to your backend The search engine your SmartHub instance uses to perform queries. SmartHub can be configured to use more than one search engine., see the "Limitations" topic for your backend.

How to Access Advanced Search

  1. To get to Advanced Search click displayed on the right side of the search box, then click on "Advanced Search" link.



  2. This opens the Advanced Search modal window as shown below.

  3. Type search terms into the search boxes, and use the options shown to further refine your search.

How to Configure Your Advanced Search

  • To configure the Advanced Search feature, copy some or all of the Advanced Search module configuration settings into your page’s custom settings file and modify them as you see fit.
  • Advanced search settings from the file DefaultModuleSettings.js are shown in the screenshot below.
  • The settings for the Advanced Search module can be found in the the section SH.AdvancedSearch.DefaultSettings (around line 783) in the file DefaultModuleSettings.js, located in the directory <SmartHub_root>\modules\SmartHubResourceLoader\DefaultModuleSettings.js
  • Section SH.AdvancedSearch.DefaultSettings (around line 783) in the file DefaultModuleSettings.js is shown below.
  • Modify the settings as described below.

DefaultModuleSettings.js: Advanced Search setings

 

Do NOT modify the DefaultModuleSettings.js configuration file as it is overwritten at upgrade time.

All the changes to the settings should be done using the page's custom settings file.

To see an example of a custom settings file see the provided custom settings for the custom Index.html page: <SmartHub-root>\CustomerCustomization\settings\IndexCopyCustomSettings.js

Example: Advanced Search in an Existing Page

In this topic we insert Advanced Search settings into a custom index page- IndexCopy.html - located at <SmartHub-root>\CustomerCustomization\pages\IndexCopy.html.

  1. Open the DefaultModuleSettings.js (<SmartHub_root>\modules\SmartHubResourceLoader\DefaultModuleSettings.js).

  2. Open the IndexCopyCustomSettings.js file (<SmartHub_root>\CustomerCustomization\settings).

  3. For simplicity we copy a single setting - the EnableAdvancedSearch parameter from DefaultModuleSettings.js into IndexCopyCustomSettings.js:
    1. Copy the parameter inside the brackets of the parameter SH.AdvancedSearch.CustomSettings.
    2. Save the file IndexCopyCustomSettings.js.
    3. Close all files.

 

Sample IndexCopyCustomSettings.js
Copy
SH.AdvancedSearch.CustomSettings = {
    EnableAdvancedSearch: "true"};
 
SH.AdvancedSearch.PathsToExclude =[];

Advanced Search Parameters

Setting Name Default Value Description
EnableAdvancedSearch true

true - Advanced Search is enabled.

false - Advanced Search is disabled.

EnableSearchPreview true

true - Search Preview is enabled. On the right side of the module window you can see some sample documents that maches your conditions. 

false - Search Preview is disabled.

AdvancedSearchQueryTemplate '{searchboxquery} FederatorBackends:"*"' The query template used when performing the search.
ResultSourceId "b29924a9-ec32-4c10-8892-a544b69ee121" The result source id used when performing the search.
PreviewTemplatePath "/modules/AdvancedSearch/templates/previewTemplate.html"

Search Preview template path.

You can customize the template and provide the path to the custom template using this parameter.

PreviewTemplateSelectProperties

"clickUri,title,Rank,ContentSource,DocumentSummaryExtraction, DocumentLanguageExtraction,DocumentEntitiesO365,RefinableString15, RefinableString147,Role,Office,Department,sfcustomers,RefinableString121, author"

The selected properties used when performing the search.
TemplatePath "/modules/AdvancedSearch/templates/template.html"

Advanced Search template path.

You can customize the template and provide the path to the custom template using this parameter.

Title "Advanced Search" The name of the link and the title of the modal window.
Prefix "advSearch-" The prefix of the ids of the advanced search html elements.
Description "Find documents that have..." The text displayed under the title.
PreviewDescriptionLabel "Search preview" The text displayed in the search preview section.
PreviewNoResultsLabel "Sorry, no results found" The message displayed when there are no results for the performed search.
PreviewErrorLabel "There was a problem running the search" The error displayed when something goes wrong with the search.
SearchButtonLabel "Search" The label of the "Search" button.

AllWords

Enable true

true - The section is displayed.

false - The section is hidden.

Label "All of these words:" The label of the section.
ExactPhrase Enable true

true - The section is displayed.

false - The section is hidden.

Label "The exact phrase:" The label of the section.
AnyWords Enable true

true - The section is displayed.

false - The section is hidden.

Label "Any of these words:" The label of the section.
NoneWords Enable true

true - The section is displayed.

false - The section is hidden.

Label "None of these words:" The label of the section.
AdditionalProperties Property name In the oob SmartHub, the additional properties are Language, ContentSource and ResultType.

The property name is not important, you can name it however you like.

For each of this properties a new section will be created.


Label "Result type:" The label of the section.
ManagedProperty "filetype" The managed property used to filter the search results.
IsDynamic false

true - Get the refiner values dynamically. The displayed values of the property will be composed of the values specified in the ValueMappings setting and the returned values.

false - Use the predefined values specified in the ValueMappings setting.

If this property is not specified at all, the default value will be used.

RenderMode "dropdown"

The display mode of the property.

The RenderMode can have one of the following values: "checkbox" or "dropdown".

ValueMappings

{
"All Results": "",
"Word Documents": "doc,docx,dot,docm,odt",
"Excel Documents": "xls,xlsx,xlsm,xlsb,ods",
"PowerPoint Presentations": "ppt,pptx,pptm,odp"
}

The list of possibile values for this managed property.

The format is "label_of_the_value": "actual_value".

AddPropertyRestrictions Enable true

true - The section is displayed.

false - The section is hidden.

TemplatePath "/modules/AdvancedSearch/templates/AddPropertyRestrictionsTemplate.html"

Property Restriction template path.

You can customize the template and provide the path to the custom template here.

MaxNumberOfPropertiesRestrictions 5 Maximum number of properties restrictions that can be added.
Labels Description "Where the Property..." The description of the section.
PropertyPlaceholder "Pick or enter property" The placeholder for the property input.
OperatorPlaceholder "Pick operator" The placeholder for the operator input.
ContainLabel "Contains" The label of the "Contains" operator.
NotContainLabel "Does not contain" The label of the "Does not contain" operator.
EqualLabel "Equals" The label of the "Equals" operator.
NotEqualLabel "Does not equal" The label of the "Does not equal" operator.
GreaterLabel "Greater than" The label of the "Greater than" operator.
LessLabel "Less than" The label of the "Less than" operator.
OnOrBefore "On or before" The label of the "On or before" operator.
OnOrAfter "On or after" The label of the "On or after" operator.
StartsWithLabel "Starts with" The label of the "Starts with" operator.
AndLabel "And" The label of the "And" operator.
OrLabel "Or" The label of the "Or" operator.
InvalidOperatorError "Invalid operator: ${operator}. Please choose one from the list!"

The error displayed when the entered operator doesn't exist.

Replace ${operator} with the value that causes this error.

MaximumReachedError "You have reached the maximum number of allowed properties." The error displayed when the maximum is reached.
BlankFieldsError "Please complete all fields of a property restriction!"

The error displayed when not all fields of a property restriction are completed but a search is tried.

PropertyTooltip "After you choose a property, in order to select another one you have to detele the selected one" This message will appear when hovering over the properties drop-down list.
OperatorTooltip "After you choose an operator, in order to select another one you have to detele the selected one" This message will appear when hovering over the operators drop-down list.
ListOfProperties

Property1: {
    Label: "Author",
    ManagedProperty: "author",
    Type: "string"
},
Property2: {
    Label: "Size (bytes)",
    ManagedProperty: "Size",
    Type: "number"
},
Property3: {
    Label: "Last Modified Date",
    ManagedProperty: "date",
    Type: "date"
}

The list of properties the user can choose from.

Property1 - The property name is not important, you can name it however you like.

Label "Author" The label of the property.
ManagedProperty "author" The managed property used to filter the search results.
Type "string"

The type of the property.

Possibile values are: string, number and date

Adding Advanced Search to a New Custom Page

In order to add the Advanced Search button on a custom page follow these steps:

  1.  Edit your HTML page by adding the following code block:

    <div class="customAdvancedSearch" onclick="SH.AdvancedSearch.Show()">	
    <span> Advanced Search </span></div>
  2. Style your button using the customAdvancedSearch class.

Example

For example, by default, the SharepointModern theme doesn't contain the Advanced Search button.

  1. To add it, edit the Results.html page.

  2. Add the code in step 1, above.