Indexing the content
If you have already visited answers.coveo.com, you may have noticed that it is powered by OSQA. Before replacing the search on that platform, we needed to index its content. OSQA does not have an API that we could use to extract content. However, everything is stored in a database so we went with our very flexible Database Connector to retrieve all the questions and answers. Here is the mapping file that we are using:
We wanted to display the answers with the questions in the search results. An answer without the context of the question is only a part of the information you are looking for. We also wanted to pull the question into the result list if the searched term was only found in the answer and vice versa. In the Coveo jargon, this type of result interaction is called Folding. To fold questions and answers, we created several custom fields.
We then used the Folding Component to group questions and answers together. Here is the HTML that we are using:
We set the data-field property to the common value shared by both the question and its answer(s). We then set the properties to specify the field to use for the parent and for the children. Those fields are either on the question or on the answer but not on both. Finally, we set the data-rearrange property to "date ascending". This way, the results are displayed in the same order as they were created (question, answer 1, answer 2, …).
Rendering the results using templates.
We are only displaying questions and answers in this result list. The default result template is used to display the question, here it is: