Domino searches with Japanese text

Hi,

I have an application on a Domino server with a search feature that works perfectly well in English. However, we are trying to introduce Japanese users to the app, and we are unable to get our search feature to work with Japanese characters.

Here’s the relevant Search function we’re using (JavaScript):

===============

function Search()

{

var newQry;

var SearchKwd = trim(document.forms[0].SearchKwd.value);



if (lastSrchQry == '')

{

	var str = replaceStrings(SearchKwd, ',', '');



	for(strarray = 0; strarray < _excludedChars.length; strarray++) {

		str = replaceStrings(str, _excludedChars[strarray], '');

	}



	str = replaceStrings(str, '"', '');

	

	if(str.length > 2 & !contains(_excludedTerms, str.toUpperCase())) {			

		var loc = str.indexOf(' ');

		if (loc != -1 )

			newQry = '"' + escape(str) + '"Or"' + trim(Left(str, loc)) + ',%20' + trim(Right(str, loc)) + '"';

		else

			newQry = escape(str);					

			

		newQry = newQry.toUpperCase();

		str = str.toUpperCase();

		

		var qstr = '&Query=[Entity] CONTAINS *' + newQry + '*&SearchMax=-1&SearchOrder=4&SrchKey=' + escape(str);

		

		var tabURL = _webDbName  + "/vDataDocsBasic?SearchView" + qstr; 

		CreateSearchResults(tabURL, str);	



		if (loc != -1 ) 

		{				

			var str2 = str.split(' ');			

			for(strarray = 0; strarray < str2.length; strarray++) {

				var tmpstr = replaceStrings(str2[strarray], ',', '');			

				if (tmpstr != '') {					

					if(tmpstr.length > 2 & !contains(_excludedTerms, tmpstr.toUpperCase())) {				

						qstr = '&Query=[Entity] CONTAINS *' + escape(tmpstr) + '*&SearchMax=-1&SearchOrder=4&SrchKey=' + escape(tmpstr);

						tabURL = _webDbName  + "/vDataDocsBasic?SearchView" + qstr;  	

						CreateSearchResults(tabURL, tmpstr);	

					}					

				}

			}

				

			qstr = '&Query=[Entity] CONTAINS *' + newQry + '*&SearchMax=-1&SearchOrder=4&SrchKey=' + escape(str);

			tabURL = _webDbName  + "/vDataDocsBasic?SearchView" + qstr;  			

				

			var tabMatch = tabs.findById(escape(tabURL));

			if (tabMatch) {

				tabs.activate(tabMatch);

			} 			

		}

		

		lastSrchQry = SearchKwd;

	}

	else {

		if (contains(_excludedTerms, str.toUpperCase())) {

			alert(_srchExclTrm);

			return;			

		}

		else {

			alert(_srchMinLen);

			return;

		}

	}		

}

else

{

	if (lastSrchQry.toUpperCase() != SearchKwd.toUpperCase())

	{	

		ClearSearchResults();

		lastSrchQry = '';

		Search();

	}	

}

}

===============

I can see that a string like “株式会社三井住友銀行” gets encoded to “%U682A%U5F0F%U4F1A%U793E%U4E09%U4E95%U4F4F%U53CB%U9280%U884C” when the escape function is called. But regardless of whether I encode the string or not, it fails to pick up the matching document. I’ve even tried putting the encoded string directly into the document itself, and no dice. Note that searching for the Japanese string in the Notes client works perfectly fine - it only breaks over the web.

Anyone have any thoughts on what I might be doing wrong? Thanks in advance!

Subject: encodeURI or encodeURIComponent

I think you should use encodeURI() or encodeURIComponent(), instead of escape(), to encode Japanese chars in URL

Subject: WebAgent

I’ve had good success with escape() and using a webagent doc.QUERY_STRING_DECODED(0) to do the search and return the results.

Also note that it is best to not bother with the wildcard ‘*’ FTsearches for japanese as they don’t work - just using the word plain will act like word.

Subject: thanks!

I combined your advice with Norimasa’s and modified my code to use encodeURI() and remove the wildcard characters, and now it works perfectly. Thanks again!