Setting up Server Side Search for NetHelp 2.0 and Mobile Help Targets
- 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
- In Doc-To-Help, open the Help Targets dialog box (Home tab > click the dialog box launcher on the Target ribbon group).
- 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.
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
- Copy your built target to the web server, for example, to “c:\d2h\targets\Pittsburgh250XMLSource”.
- 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”.
- 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
- 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.
- 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)
- Repeat steps 1-2 from Setting up a server for a single target for all targets.
- Copy the search server files to a separate folder, for example, “c:\d2h\nodejs”.
- 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.
- 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:
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.
- Make sure you save all changes made to the “settings.json” file.
- 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).
- 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).
- 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.
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.