What’s knowledge base or knowledge management (KM)? The portlet Knowledge Base allows authoring articles and organize them in a hierarchy of navigable categories. It leverages Web Content articles, structures, and templates; allows rating on articles; allows commenting on articles; allows adding hierarchy of categories; allows adding tags on articles; exports articles to PDF and other formats; supports workflow; allows adding custom attributes (called custom fields); supports indexing and advanced search; allows using rule engine; search by keyword – look-ahead typing, etc.
In general, the portlet Knowledge Base provides two pieces inside: Articles – managing knowledge base articles - and Article Aggregator - publishing knowledge base articles.
Abstracted from the book: Liferay Portal 6 Enterprise Intranets (coming out soon)
We have discussed two main features of Knowledge base articles in both Liferay portal 5.2 EE SP1 (or SP2 or SP3) and 6.0 like
Taxonomies and Folksonomies - Increasing search and retrieve capabilities in Knowledge Base Articles
Sharing Content - Knowledge base - across Organizations and Communities
This article will share one more features: search by keyword - Look-ahead typing – based on Knowledge Base articles in Liferay portal 6 and 5.2 EE SP1 (or SP2 or SP3).
What’s Look-ahead typing?
Look-ahead is a tool in algorithms for looking ahead a few more input items before making a cost effective decision at one stage of the algorithm. In artificial intelligence, look-ahead is an important component of combinatorial search which specifies, roughly, how deeply the graph representing the problem is explored. Look-ahead is also an important concept in parsers in compilers which establishes the maximum number of incoming input tokens the parser can look at to decide which rule it should use.
In Knowledge base portlets, it is very useful to search articles by keywords. And moreover, it is very nice that the system should remember the keywords that users input for search. When users typing, suggested keywords should be available.
For example, suppose that users input a set of keywords to search Knowledge base article, like “liferay”, “life”, “live”, “look”, “like” and now they want to use these keywords in their keyword search. When a user types “l”, the system should list suggested keywords, like “liferay”, “life”, “live”, “look”, “like”; when a user types “li”, the system should list suggested keywords, like “liferay”, “life”, “live”, “like”; when a user types “lif”, the system should list suggested keywords, like “liferay”, “life”; and so on.
This is a good feature to search knowledge base articles. And moreover, it would be nice feature for Liferay portal core portlets like Search and Web Content Search.
How to achieve this?
You would have different models on look-ahead type. Here we share our solution. The following is main idea.
- First create a database table "kb_kbsearchkeyword."
<entity name="KBSearchKeyword" local-service="true" remote-service="true">
<!-- PK fields -->
<column name="keyword" type="String" primary="true"></column>
<!-- Audit fields -->
<column name="createDate" type="Date"></column>
<!-- Order -->
<order by="desc">
<order-column name="createDate"></order-column>
</order>
</entity>
- When a user enters a new keyword for search, if the search result is not empty, that keyword will be saved into this table.
KBSearchUtil.typingLookAhead(entries.size(), keywords);
- The suggested keywords will be retrieved from this table ordered by creation date descending. The first 500 keywords will be retrieved.
KBSearchKeywordLocalServiceUtil.getKBSearchKeywords(0,500);
Prototype
Type “l”

Type “li”

Summary
As you can see, search by keyword - Look-ahead typing – based on Knowledge Base articles is useful. By the way, this solution would be helpful in Liferay portal core portlets like Search and Web Content Search, etc.
Last but not least, I'd like to send special thanks to Robert Chen and Frank Yu who did an amazing job to make search by keyword - Look-ahead typing – based on Knowledge base articles a reality.


