How to Refine Search Results by Term Proximity

 

About

The Proximity Search Slider component contains the following basic features and attributes:

  • Component Module Location
    • <SmartHub_install_dir>\modules\ProximitySearch
  • Primary Functions
    • Enables the user to change the distance between the matched search terms when they are found in documents.
      • The distance can be calculated using different methods. See "Proximity Search Slider Settings" below for details.
    • Enables documents to be matched only if the search terms are in the same sentence or paragraph (AutoClassifier is required for this functionality).
  • Component Settings
    • The screenshot below contains the component settings.
    • In order to mofiy them, you must use the SmartHub UI Builder tool.
    • The component is disabled by default.

  • Do Not modify any native HTML page
  • Native files are overwritten during upgrade.
  • You must leave native HTML pages as templates
  • You should create a custom version of native pages before modifying them. For more information, see How to create custom pages

Requirements and Restrictions

  • The slider is disabled when the query is too complex, or if it does not have at least 2 terms
  • The slider must be added to a page container that is visible on the page even if no results are returned (so that the user can slide to a value which would return results)
  • Moving the slider changes the underlying query without modifying the initial user query in the search box
  • If you do not have the SentenceMatch or ParagraphMatch property, then leave both properties empty.
    • The match is done based on term proximity in this case.
Important! SentenceMatch and ParagraphMatch work only for the SharePoint Online and SharePoint 2019 search engines.

To disable SentencePatch and ParagraphMatch, the values for SameSentencePosition and SameParagraphPosition must be set to -1

How to Enable the Proximity Search Slider

  • Proximity Search settings are stored in the SmartHub modules directory at <SmartHub_root>/modules/ProximitySearch
  • To configure the Proximity Search feature, copy some or all of the Proximity 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

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 255 (this may vary), which contains the text "SH.ProximitySearch.CustomSettings"


  7. To access the available ProximitySearch 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 "ProximitySearch" on the page to quickly navigate to the Proximity Search default settings, shown below:

Copy
    SH.ProximitySearch = SH.ProximitySearch || {};
    SH.ProximitySearch.DefaultSettings = {
        Enabled: false,
        Labels: {
            TermProximity: "Term proximity".toLocaleString(),
            Description: "Drag the slider to modify the maximum distance between matched terms in documents".toLocaleString(),
            InactiveSliderReason: "The slider can be used when the query has at least 2 terms and is not an advanced expression.".toLocaleString(),
            SideBySide: "Side by side".toLocaleString(),
            SameSentence: "In the same sentence".toLocaleString(),
            SameParagraph: "In the same paragraph".toLocaleString(),
            Anywhere: "Anywhere in the document".toLocaleString(),
            SideBySide_short: "side by side".toLocaleString(),
            SameSentence_short: "same sentence".toLocaleString(),
            SameParagraph_short: "same paragraph".toLocaleString(),
            Anywhere_short: "anywhere".toLocaleString(),
            OneWordApart: "Max 1 word apart".toLocaleString(),
            MultipleWordsApart: "Max {0} words apart".toLocaleString()
        },
        SameSentencePosition: -1, // -1 makes the option invisible. Other good value would be 8
        SameParagraphPosition: -1, // -1 makes the option invisible. Other good value would be 20
        SentenceMatchProperty: "AC_Sentence",
        ParagraphMatchProperty: "AC_Paragraph",
        DefaultNearOperatorValue: 100,
        ParentSelector: "#ProximitySearch",
        MaxWordDistance: 30,
        TemplatePath: SH.RootLevelURL + "/modules/ProximitySearch/ProximitySearchTemplate.html"
    }
  1. Copy the ProximitySearch settings section from SH.ProximitySearch.DefaultSettings.
  2. Go back to your Advanced settings edit tab.

  3. Paste the copied settings inside section SH.ProximitySearch.CustomSettings.
  4. Change the Enabled value to "true."
  5. Modify additional settings as desired. See "Proximity Search Slider Settings" below.
  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.

Proximity Search Slider Settings

The Proximity Slider module provides the following settings:

  • Enabled
    • Controls if the module is active on the page or not
  • Labels
    • The labels used by the component.
    • Customizable
  • SameSentencePosition
    • Position on the slider where the "same sentence" option is to appear
  • SameParagraphPosition
    • Position on the slider where the "same paragraph" option is to appear
  • SentenceMatchProperty
    • Supported in SharePoint Online and SharePoint O365 only 
    • The name of the multi-valued managed property that contains the document sentences.
    • This is used when the user selects "same sentence" matching. Generate this property using BA Insight AutoClassifier.
  • ParagraphMatchProperty
    • Supported in SharePoint Online and SharePoint O365 only 
    • The name of the multi-valued managed property that contains the document paragraphs.
    • This is used when the user selects "same paragraph" matching. Generate this property using BA Insight AutoClassifier.
  • DefaultNearOperatorValue
    • The maximum distance between words when using the "same sentence" or "same paragraph" options.
    • The value must be higher than the longest paragraph.
  • ParentSelector
    • The jQuery selector for the HTML element where the slider is to be rendered on the page
  • MaxWordDistance
    • The maximum distance between terms that can be chosen 
  • TemplatePath
    • Path to the HTML template that is being used by the view