Search Options for NetHelp
Doc-To-Help’s NetHelp target includes powerful search features that you can customize for your needs, such as server-side search.
By default, JavaScript Client search is used in NetHelp targets and requires no server setup. JavaScript Server search requires setup, but will improve the search speed of NetHelp targets installed on a web server. See Setting Up Server-Side Search for NetHelp Targets.
JavaScript search supports exact phrase, Boolean, and fuzzy searches.
-
Exact phrase search means that if you enclose a phrase in double quotes, the search will be limited to that exact phrase in the online output.
Example
"sports teams"
-
Boolean search means that you can use "AND" or "OR" (no quotes) between words or exact phrases when searching. You can also use "AND NOT" or "NOT" before a word or exact phrase to exclude topics containing that phrase from the results. By default, if there is no "AND" or "OR" between words, "AND" is assumed.
Example
football or hockey, sports and not baseball
-
Fuzzy search will display alternative search options (and results) if the user enters a search term that is close to the term entered.
Example
Let's say you search for sorts. The search will return "No topics found. Did you mean: sports."
The following explains how to set up server-side search for NetHelp targets.
- 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 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 is 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.
- In Word, select the Target ribbon, and click Target Properties. The Help Targets dialog opens.
- On the left side of the dialog, select the NetHelp target.
- In the Advanced section, in the Search type field, choose JavaScript Server.
- Build the target.
After the target is built, click the View button, or view it when Doc-To-Help asks if you would like to view the target. This will start the search server automatically and will open the NetHelp 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.
Note You can test only one target at a time. If you have two Doc-To-Help instances running and build a target 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 and haven't stopped it. In that case, you will need to stop the search server manually.
As a prerequisite to the following steps, Node.js must be installed on the server. It can be downloaded here: http://nodejs.or.
-
Copy your built target to the web server.
Example
c:\d2h\targets\MyOutput
-
Depending on the web server that you use (IIS, Apache, etc.), set up your server to serve the target files (e.g., in IIS, set up a virtual directory).
Example
http://localhost/d2h/MyOutput can point to c:\d2h\targets\MyOutput
- 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\MyOutput\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.
-
Open the built target in a browser, not from the local file system (i.e., the URL in the browser must start with the "http://" prefix).
Example
http://localhost/d2h/MyOutput
-
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.
- Repeat steps 1-2 from Setting Up a Server for a Single Target.
- Copy the search server files to a separate folder (e.g., 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.
Copy{
"port": 8256,
"host": null,
"targets": [
{
"path": "/d2h/MyOutput/",
"index": "c:\\d2h\\targets\\MyOutput\\searchindex.js"
},
{
"path": "/d2h/MyOutput/",
"index": "c:\\d2h\\targets\\MyOutput\\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.
- Make sure you save all changes made to the "settings.json" file.
- Repeat step 3 from Setting Up a Server for a Single Target.
Note The folder structure described in these steps is only an example; you can use any folder structure you wish.
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
Example
"c:\d2h\nodejs" or "c:\d2h\targets\MyOutput\js\nodejs"
See step 3 of Setting Up a Server for a Single Target.
- Execute node searchserverconfig.js. This updates the port number in the configuration files in Target(s) folder.
The utility "searchserverconfig.js" uses the "settings.json" file to update target configurations.