Doc-To-Help’s NetHelp and Mobile Targets include powerful JavaScript search. If you’d like even more power, you can have it by implementing Server Side search, which will improve the search speed of NetHelp 2.0 and Mobile Help Targets installed on a web server.

By default, JavaScript Client search is used in NetHelp 2.0 and Mobile Help Targets and requires no server setup. For Server Side search, you need to switch to JavaScript Server search — which requires a little bit of setup. You have the option of setting up your server for a single Target, or multiple Targets.

Setup instructions are below for switching to JavaScript Server search and setting up your server — follow the recipe and the power of Server Side search will be yours.

Setting up Server Side Search for NetHelp 2.0 and Mobile Help Targets

General information:

  • The Search server is JavaScript-based and runs inside the Node.js server.
  • The Search server uses HTTP protocol to handle search queries, so it requires a free port number on the server. For example, if the NetHelp 2.0 Target on the server is handled by a web server (IIS, Apache, etc.) and by default uses port 80, the search server will use 8256 by default. You must verify that the 8256 port for the search server is free and not blocked by a firewall.
  • The Search server can be used for either a single Target or for multiple Targets. Using a separate search server for each target can improve search performance, while using the single search server for multiple targets makes the setup and support processes easier. If you run several search servers, each of them requires a separate port number.

Setting up the Search Type

  1. In Doc-To-Help, open the Help Targets dialog box (Home tab > click the dialog box launcher on the Target ribbon group).
  2. In the Search Type field, choose JavaScript Server search.
  3. Build the Target.

After the target is built, click the View button to view the Target. This will start the search server automatically and will open the NetHelp 2.0 or Mobile Help target in a browser where you can test the search server. (This starts the server locally and is only for testing.)

When you close the Target, the search server will be automatically shut down. When you build/rebuild this or another target and click on the View button again, the search server is restarted automatically.

Please note: You can test only one Target at a time. If you have two Doc-To-Help instances running and build targets with the JavaScript Server search type, only one of them can be tested with the View button at a time. If you have one Target open already, and try to open another, you will receive an error message that says “you must shutdown the search server.” To do so, close the open Target and try again. A similar problem can occur if you run the server manually (as described below) and haven’t stopped it. In that case you will need to stop the search server manually (instructions below).

Setting up a server for a single target

Prerequisite: Node.js must be installed on the server. It can be downloaded here: http://nodejs.org

  1. Copy your built target to the web server, for example, to “c:\d2h\targets\Pittsburgh250XMLSource”.
  2. Depending on the web server that you use (IIS, Apache, etc.), set up your server to serve the target files (for example, in IIS, set up a virtual directory). For example, http://localhost/d2h/Pittsburgh250XMLSource can point to “c:\d2h\targets\Pittsburgh250XMLSource”.
  3. Run the search server in node.js. For Windows:
  • Open the command line (Start > All Programs > Accessories > Command Prompt).
  • Verify that the current directory is “C:\”, if it is not, type “c:” and press Enter, this will change current directory to “C:\”
  • Change the current directory and set it to the “js\nodejs” subfolder in the built Target folder, e.g., cd “c:\d2h\targets\Pittsburgh250XMLSource\js\nodejs”, and press Enter
  • Type “node index.js” and press Enter.

You should see the message “The server has started” in the command line window. You will also see log and error messages in this window when the search server is used.

To close the search server, you can press Ctrl+C in the command line window or just close it.

Viewing and testing server side search

  1. Open the built Target in a browser (don’t open it from the local file system) i.e., the URL in the browser must start with the “http://” prefix, for example, http://localhost/d2h/Pittsburgh250XMLSource.
  2. Try searching for a word.

Note: When you perform a search, you can see requests and responses from the server in the open command line window.

Setting up a single search server for multiple targets (for Windows)

  1. Repeat steps 1-2 from Setting up a server for a single target for all targets.
  2. Copy the search server files to a separate folder, for example, “c:\d2h\nodejs”.
  3. Go to the folder containing the search server files, “c:\d2h\nodejs” and open the “settings.json” file. This is a configuration file for the server, in JSON format. By default it has two settings:
    • port” is the port number that the search server will use. The default value is 8256. Make sure that this port isn’t used by another application and isn’t blocked by firewalls, otherwise you must change this value to any available port number.
    • host” is the IP address on which the search server will wait for requests. The default value is “null” and will work in most cases. You need to change this setting only if the system has several network interfaces and you want the search server to use a specific network interface.
  4. To handle multiple targets by a single search server, you need to add the “targets” option to this file with information about your targets. After modifying the “settings.json” file, it could look like this:
    {
    “port”: 8256,
    “host”: null,
    “targets”: [
    {
    "path": "/d2h/Pittsburgh250XMLSource/",
    "index": "c:\\d2h\\targets\\Pittsburgh250XMLSource\\searchindex.js"
    },
    {
    "path": "/d2h/Pittsburgh250WordSource/",
    "index": "c:\\d2h\\targets\\Pittsburgh250WordSource\\searchindex.js"
    }
    ]
    }
    Each target is described by two values:

    • path” is the virtual path you set up on the web server (IIS, Apache, etc.)
    • index” is a physical path to the search data of the target, the “searchinddex.js” file in the Target folder. Note that the character ‘\’ must be expressed as ‘\\’ in these strings.
  5. Make sure you save all changes made to the “settings.json” file.
  6. Repeat step 3 from Setting up a server for a single target to start the search server.
    Note: The folder structure described in these steps is only an example; you can use any folder structure you wish.

Updating target configurations

If you change the port number setting in the server configuration, you must update this setting in Target(s).

  1. Open the command line window and go to the folder containing the search server files, for example, “c:\d2h\nodejs” or “c:\d2h\targets\Pittsburgh250XMLSource\js\nodejs” (See step 3 of Setting up a server for a single target).
  2. Execute “node searchserverconfig.js”; this will update port number in the configuration files in Target(s) folder.

The utility “searchserverconfig.js” uses the “settings.json” file to update target configurations.

That’s it!

If you’d like to do further Search configuration, you can create a Search Stop List, and/or a Search Synonym List. See NetHelp Targets  for more information, and for the location of these fields in the Help Targets dialog box.

Note: This functionality is available in Doc-To-Help 2012 V2, which you can download here.

Tags: ,