Create a search query
Simple search query
A search query is created using an HTML element.
This is an example of a simple search query form:
- Form header where you specify the location of the content item containing the search element used to display the search result.
<form action='<PathCmpnt type="servlet" />/library/site/sitearea/content' method="post">This is usually the same content item that this HTML element is stored in.
- Body of the search form. Like any standard HTML form it contains an input field and a submit button.
<table> <tr><td> <input type="text" name="search_query"/> </td></tr> <tr><td align="right"> <input type="submit" value="Search"/> </td></tr> </table>In this example, a table has been used to format the search query form.
- Close the form.
</form>
Searching metadata
In this example, two more fields have been added allowing users to search both content title and author name:
<form action='<PathCmpnt type="servlet" />/library/site/ sitearea/content' method="post"> Form header where you specify the location of the content item containing the search element used to display the search result. This is usually the same content item that this HTML element is stored in.
<table> <tr> <td>Content Title</td> <td><input type="text" name="search_title"/></td> </tr> <tr> <td>Author's Name</td> <td><input type="text" name="search_authors"/></td> </tr> <tr> <td>Content Body</td> <td> <input type="text" name="search_query"/> </td></tr> <tr><td align="right"> <input type="submit" value="Search"/> </td></tr> </table>Body of the search form. Like any standard HTML form it contains input fields and a submit button. See below for a list of search parameter names.
</form> Close the form.
Including hidden data
In this example, a hidden field has been added to restrict the search to content that use the authoring template called "Press Release":
<form action='<PathCmpnt type="servlet" />/library/site/ sitearea/content' method="post"> Form header where you specify the location of the content item containing the search element used to display the search result. This is usually the same content item that this HTML element is stored in.
<input type="hidden" name="search_authoringtemplate" value="Press Release"/>Here a hidden input field has been added that searches for content that use the authoring template called "Press Release". <table> <tr> <td>Content Title</td> <td><input type="text" name="search_title"/></td> </tr> <tr> <td>Author's Name</td> <td><input type="text" name="search_authors"/></td> </tr> <tr> <td>Content Body</td> <td> <input type="text" name="search_query"/> </td></tr> <tr><td align="right"> <input type="submit" value="Search"/> </td></tr> </table>Body of the search form. Like any standard HTML form it contains input fields and a submit button. </form> This closes the form.
Search parameters
The following parameters can be used in a search query in this format:
<input name="search_parameter" />
search_query Used to search the content of any elements stored in a content item. search_authoringtemplate Used to search the authoring template, if available that was used to create the content item. search_authors Used to search the name or names of the authors for the content item, if any are defined. Searching for LDAP users
When searching for LDAP users, the full distinguished name must be submitted. Users will be unaware of what the actual distinguished name of a user will be. It is recommended that if planning to allow users to search for authors, you should create a predefined list or dropdown to allow users to select a known author. That way the user names can be displayed in a user-friendly manner, but the input submitted by the form can be the distinguished name for the selected user.
search_categories Used to search the categories of the content item if any are defined. search_contentpath Used to search for text in the path of a content item such as the library name, site name or site area name. search_description Used to search the description of the content item. search_effectivedate Used to search the effective date of the content item. Search by date only works with the format MMM dd yyyy HH:mm:ss z. For example, Sep 20 2006. To change the format, edit the SearchService.DateFormatString parameter in the SearchService.properties file.
search_expirationdate Used to search the expiration date of the content item. Search by date only works with the format MMM dd yyyy HH:mm:ss z. For example, Sep 20 2006. To change the format, edit the SearchService.DateFormatString parameter in the SearchService.properties file.
search_keywords Used to search the keywords of the content item if any are defined. search_lastmodifieddate Used to search the last modified date of the content item. Search by date only works with the format MMM dd yyyy HH:mm:ss z. For example, Sep 20 2006. To change the format, edit the SearchService.DateFormatString parameter in the SearchService.properties file.
search_modifier Used to search the name of the last person to modify the content item. search_name Used to search the name of the content item. search_owners Used to search the name or names of the owners of the content item, if any are defined. Searching for LDAP users
When searching for LDAP users, the full distinguished name must be submitted. Users will be unaware of what the actual distinguished name of a user will be. It is recommended that if planning to allow users to search for authors, you should create a predefined list or dropdown to allow users to select a known author. That way the user names can be displayed in a user-friendly manner, but the input submitted by the form can be the distinguished name for the selected user.
search_title Used to search the title of the content item.
Use a search query form
The Portal Search Engine allows the use of the following search syntaxes:
These can only be used when searching the "search_query" parameter.
- Plus (+ ) and minus (- ) signs
- Plus and minus signs do not join terms, but only operate on the term that follows them.
- Quotation marks (" )
- Use quotes to combine words into search phrases, for example "IBM software".
When you search for strings with special query characters, such as a blank or a colon (: ), enclose your search string in quotes.
- Trailing wild cards
- Use an asterisk (* ) as a trailing wild card in your search string, for example softw* .
Use the plus and minus signs For your query, type any words that describe what you are looking for. Use the plus and minus signs as follows:
- Put a plus sign (+ ) in front of the words that you want to be present in the returned documents.
- Put a minus sign (- ) in front of the words that must not be present in the returned documents.
- When using signs, do not leave any space between the sign and the following word qualified by the sign.
Plus sign examples
Minus sign examples
- +thinkpad
- All documents retrieved must contain the word thinkpad. A single unsigned word, thinkpad, is also read this way, and is treated by the search engine as +thinkpad.
- +thinkpad +drivers
- All documents retrieved must contain the word thinkpad and the word drivers.
- +thinkpad drivers
- All documents retrieved must contain the word thinkpad, but only optionally the word drivers.
- +thinkpad -drivers
- All documents retrieved must contain the word thinkpad but must not contain the word drivers.
- Do not use only minus signed terms for your search; they will not produce a result list. The reason is that in this case the search terms are too vague to allow for a meaningful scoring of the found documents.
- Use spaces between signed terms in order to distinguish them from terms that contain a minus sign, such as e-business. Note that e-business is treated as "e-business" whereas e -business is treated as optionally e , and the word business should not be contained in the resulting documents.
Parent topic
Creating a search form
Related tasks
Configure WCM search options