Mar 4, 2016, 9:27 AM
24 Posts

Type Ahead Search any word from 2 databases

  • Category: Server Side JavaScript
  • Platform: All
  • Release: All
  • Role: Developer
  • Tags:
  • Replies: 0

Hi

 

Last couple of weeks ago, I was working on a type ahead to get the full search in editbox if enter some part of the word

Like we have testing Lotus notes and administrating lotus notes, and in my type ahead if I write notes it will show be the keywords Lotus notes and administrating lotus notes.

For this I wrote or copied from the forum

var searchView:NotesView = session.getCurrentDatabase().getView("client")
var query = "(FIELD client CONTAINS *" + lupkey +"*)";
var searchOutput:Array = ["å","åå"];
var hits = searchView.FTSearch(query);
var entries = searchView.getAllEntries();
 var entry = entries.getFirstEntry();
 for (i=0; i<hits; i++) {
 searchOutput.push(entry.getColumnValues()[0]);
 entry = entries.getNextEntry();
var limitedSearchOutput = searchOutput.slice(0,Math.min(hits,20));

limitedSearchOutput = limitedSearchOutput.join("</li><li>").replace(eval("/"+@LowerCase(lupkey)+"/g"),"<b>"+@LowerCase(lupkey)+"</b>").replace(eval("/"+@ProperCase(lupkey)+"/g"),"<b>"+@ProperCase(lupkey)+"</b>");

return "<ul><li><span class='informal'>Suggestions:</span></li><li>" + limitedSearchOutput + "</li></ul>";
var limit = Math.min(hits,20);
 for (j=0; j<limit; j++) {
 var name = searchOutput[j].toString();
 var start = name.indexOfIgnoreCase(lupkey)
 var stop = start + lupkey.length;
name = name.insert("</b>",stop).insert("<b>",start);
 result += "<li>" + name + "</li>";
 }

 result += "</ul>";
 return result;

Now I want to use this type ahead from 2 databases, yes field name are same, they are the archive databases, Is it possible.This might be very interesting and use full  stuff for all of us.

Thanks and Regards