Integration with existing systems

From DBSight Full-Text Search Engine/Platform Wiki

Table of contents

iFrame based integration

The problem

  1. Many sites already have quite some page with a consistent UI Look and Feel. It's kind of hard to mimic existing UI in DBSight templates.
  2. Many sites are not coded in Java, and dealing with XML/JSON seems easy, but can get complicated.

The Super Easy Solution

Use javascript to search on DBSight, and render results in a popup window. Here let's use FancyBox as an example.

Step 1 Add a Search Input Box on existing page

In your existing page, add an input box

<input type="text" id="search">

You can put it anywhere.

Step 2 Add javascripts

For this FancyBox library, need to use jquery 1.3.2 or later, and FancyBox ] 1.3 or later http://fancybox.net . Since I am taking an early release of FancyBox, you can download it from here before the official release. http://www.dbsight.net/download/fancybox.zip

<script src="/javascripts/jquery.js" type="text/javascript"></script>
<script src="/javascripts/jquery/fancybox.js" type="text/javascript"></script>
<link href="/javascripts/jquery/fancybox.css" rel="stylesheet" type="text/css" />

<script>
$(function(){
 $('#search').keydown(function(event){
   if (event.keyCode == 13) {
     event.preventDefault();
     $.fancybox( {
       'href'  : 'http://localhost:8080/dbsight/search.do?indexName=<index name>&templateName=<template name>&q='+encodeURIComponent(this.value),
     }, {
       frameWidth    : '100%',
       frameHeight   : '100%',
       type        : 'iframe'
     });
   }
 });
});
</script>

Remember to replace <dbsight url>, <index name>, <template name> with your own values.

The <dbsight url> should be similar to this format:

http://search.yoursite.com:8080/dbsight/search.do

Step 3 Add Result Template on DBSight

You just need to create one normal search engine template.

After it's working, you can remove parts that you don't need.

That's it. Simple enough?

Proxy Based Solution

The question from a user

Is there an easy and fast way to integrate Search Results and related Templates on my own application context?

Because I would like to use you app way to show results and related templates (with freemarker and velocity) but If I do and integration like sending requests with your API, then it seems like I have to rewrite all code refering of processing view on my own app.

The possible solution

I think it'll be easier to write a proxy controller.

All the default DBSight templates generates relative URL like:

?q=...

without search.do

So you can write a controller in your own context, like dbsightProxy.do and send all the parameters to dbsight search.do, get the html results, and put it on the screen or mix it with your own html.

There is a special case, suggest-as-you-type feature, which is hard coded in javascript to suggest.do. But it should not be that difficult to adjust it.