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 search engines. For information about limitations to your search engine, see the "Limitations" topic for your search engine.

How to Access Advanced Search in the UI

  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 Advanced Search

  • Advanced Search settings are stored in the SmartHub modules directory at <SmartHub_root>/modules/AdvancedSearch
  • To configure the Advanced Search feature, copy some or all of the Advanced Search module configuration settings into your HTML page’s custom settings file and modify them as you see fit.
  • This is done using the UI Builder tool

UI Builder

  • The easiest and fastest way to insert and customize the Advanced Search feature is via the SmartHub UI Builder.

  • For more information, see How to Use the UI Builder.

Procedure:

  1. SmartHub administrators can simply click the UI Editor link from the SmartHub ADMINISTRATION page.

  2. Click the Select a page link from the top menu.

  3. Select (double-click) an HTML page such as Results.html page.

    1. Below, the Results.html page is shown for sample purposes.

    2. BA Insight recommends you use a custom folder/page for modifications. Leave the default files as templates.

      1. Example: CustomPages/CustomResults.html. Default Results.html is under the top most SmartHub directory.

  4. Select the Advanced mode from the top right of the page.

  5. Select Advanced settings edit.

  6. Scroll down to line 222 (this may vary), which contains the text "SH.AdvancedSearch.CustomSettings"


  7. To access the available AdvancedSearch settings, click the See Default Settings link in the top right corner.

  8. A new browser tab opens with all available SmartHub module settings.

  9. Search for the word "AdvancedSearch" on the page to quickly navigate to the Advanced Search default settings, shown below:
  10. Copy
     SH.AdvancedSearch = SH.AdvancedSearch || {};
        SH.AdvancedSearch.DefaultSettings = {
            EnableAdvancedSearch: true,
            EnableSearchPreview: true,
            AdvancedSearchQueryTemplate: '{searchboxquery} FederatorBackends:"*"',
            ResultSourceId: "b29924a9-ec32-4c10-8892-a544b69ee121",
            PreviewTemplatePath: SH.RootLevelURL + "/modules/AdvancedSearch/templates/previewTemplate.html",
            PreviewTemplateSelectProperties: "clickUri,title,Rank,ContentSource,DocumentSummaryExtraction,DocumentLanguageExtraction,DocumentEntitiesO365,RefinableString15,RefinableString147,Role,Office,Department,sfcustomers,RefinableString121,author",
            TemplatePath: SH.RootLevelURL + "/modules/AdvancedSearch/templates/template.html",
            Title: "Advanced Search",
            Prefix: "advSearch-",
            Description: "Find documents that have...",
            PreviewDescriptionLabel: "Search preview",
            PreviewNoResultsLabel: "Sorry, no results found",
            PreviewErrorLabel: "There was a problem running the search",
            SearchButtonLabel: "Search",
            AllWords: {
                Enable: true,
                Label: "All of these words:"
            },
            ExactPhrase: {
                Enable: true,
                Label: "The exact phrase:"
            },
            AnyWords: {
                Enable: true,
                Label: "Any of these words:"
            },
            NoneWords: {
                Enable: true,
                Label: "None of these words:"
            },
            AdditionalProperties: {
                Language: {
                    Label: "Only the language(s):",
                    ManagedProperty: "DetectedLanguage",
                    RenderMode: "checkbox",
                    ValueMappings: {
                        "English": "en",
                        "French": "fr",
                        "German": "de",
                        "Japanese": "ja",
                        "Simplified Chinese": "zh-cn",
                        "Spanish": "es",
                        "Traditional Chinese": "zh-tw"
                    }
                },
                ContentSource: {
                    Label: "Content source:",
                    ManagedProperty: "ContentSource",
                    IsDynamic: true,
                    RenderMode: "dropdown",
                    ValueMappings: {
                        "All Results": ""
                    }
                },
                ResultType: {
                    Label: "Result type:",
                    ManagedProperty: "filetype",
                    RenderMode: "dropdown",
                    ValueMappings: {
                        "All Results": "",
                        "Word Documents": "doc,docx,dot,docm,odt",
                        "Excel Documents": "xls,xlsx,xlsm,xlsb,ods",
                        "PowerPoint Presentations": "ppt,pptx,pptm,odp"
                    }
                }
            },
            AddPropertyRestrictions: {
                Enable: true,
                TemplatePath: SH.RootLevelURL + "/modules/AdvancedSearch/templates/AddPropertyRestrictionsTemplate.html",
                MaxNumberOfPropertiesRestrictions: 5,
                Labels: {
                    Description: "Where the Property...",
                    PropertyPlaceholder: "Pick or enter property",
                    OperatorPlaceholder: "Pick operator",
                    ContainLabel: "Contains",
                    NotContainLabel: "Does not contain",
                    EqualLabel: "Equals",
                    NotEqualLabel: "Does not equal",
                    GreaterLabel: "Greater than",
                    LessLabel: "Less than",
                    OnOrBefore: "On or before",
                    OnOrAfter: "On or after",
                    StartsWithLabel: "Starts with",
                    AndLabel: "And",
                    OrLabel: "Or",
                    InvalidOperatorError: "Invalid operator: ${operator}. Please choose one from the list!",
                    MaximumReachedError: "You have reached the maximum number of allowed properties.",
                    BlankFieldsError: "Please complete all fields of a property restriction!",
                    PropertyTooltip: "After you choose a property, in order to select another one you have to detele the selected one",
                    OperatorTooltip: "After you choose an operator, in order to select another one you have to detele the selected one"
                },
                ListOfProperties: {
                    Property1: {
                        Label: "Author",
                        ManagedProperty: "author",
                        Type: "string"
                    },
                    Property2: {
                        Label: "Title",
                        ManagedProperty: "title",
                        Type: "string"
                    },
                    Property3: {
                        Label: "Size (bytes)",
                        ManagedProperty: "Size",
                        Type: "number"
                    },
                    Property4: {
                        Label: "URL",
                        ManagedProperty: "path",
                        Type: "string"
                    },
                    Property5: {
                        Label: "Last Modified Date",
                        ManagedProperty: "date",
                        Type: "date"
                    }
                }
            }
        }
  1. Copy the AdvancedSearch settings section from SH.AdvancedSearch.DefaultSettings.
  2. Go back to your Advanced settings edit tab.

  3. Paste the copied settings inside section SH.AdvancedSearch.CustomSettings.
  4. Change the Enabled value to "true."

  5. Modify additional settings as desired.
  6. Click Save changes.
  7. Click the link Preview <html> file.html at the top of the code editor.

  8. Review your HTML page in the new tab that opens.

  9. Make any necessary changes back in the code editor. Repeat steps 14-18 as necessary.

  10. Click Save changes.

 

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} Federatorsearch engines:"*"' 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 out-of-the-box 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
Copy
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:

    Copy
    <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.