Closed Bug 533674 Opened 10 years ago Closed 10 years ago

for my custom search plugin search suggestions are not work

Categories

(Firefox :: Search, defect, major)

x86
Windows XP
defect
Not set
major

Tracking

()

RESOLVED INVALID

People

(Reporter: venkateshi, Unassigned)

References

Details

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.15) Gecko/2009101601 Firefox/3.0.15 (.NET CLR 3.5.30729)
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.15) Gecko/2009101601 Firefox/3.0.15 (.NET CLR 3.5.30729)

I have created the plugin using the following xml and found that the search box is not showing the suggestions. Though the same xml works fine on IE 8.0 , where I could see the suggestions returned by the server. So the question of issue with server side code is ruled out. The response for the suggestion is in this format '["fir",["firefox","first choice","mozilla firefox"]]' as described in https://developer.mozilla.org/en/Supporting_search_suggestions_in_search_plugins . 
One thing I have observed is that if I "hard code"  the response in my server side code then the suggestions are shown , but in my actual implementation my server side code invokes a REST based web service API to get the suggestions and then it formats it to required format. One more thing I have observed is even before returning the "hard coded" response if I put a sleep for 1-2 seconds the suggestions are not shown.


<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"
                       xmlns:moz="http://www.mozilla.org/2006/browser/search/">  
  <ShortName>My Plugin</ShortName>
  <Description>My Search Plugin</Description>
  <Url type="text/html" method="get" template="http://www.myserver.com/find?query={searchTerms}"/>
  <Url type="application/x-suggestions+json" method="get" template="http://www.myserver.com/suggestions?prefix={searchTerms}"/>
  <Image width="16" height="16">http://www.myserver.com/favicon.ico</Image>  
  <InputEncoding>UTF-8</InputEncoding>  
</OpenSearchDescription>

Reproducible: Always

Steps to Reproduce:
1.Create a plugin using 
<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"
                       xmlns:moz="http://www.mozilla.org/2006/browser/search/">  
  <ShortName>My Plugin</ShortName>
  <Description>My Search Plugin</Description>
  <Url type="text/html" method="get" template="http://www.myserver.com/find?query={searchTerms}"/>
  <Url type="application/x-suggestions+json" method="get" template="http://www.myserver.com/suggestions?prefix={searchTerms}"/>
  <Image width="16" height="16">http://www.myserver.com/favicon.ico</Image>  
  <InputEncoding>UTF-8</InputEncoding>  
</OpenSearchDescription>
2.Add some processing to server side code which returns suggestion
3.Install the plugin
4. Try using suggestions
Actual Results:  
Suggestions are not shown

Expected Results:  
Suggestions should be shown
We timeout suggestion requests after 500ms to avoid waiting too long before displaying results. Could it be that your requests just aren't returning fast enough unless they are "hard-coded"? You could try increasing the timeout by adjusting the "_suggestionTimeout: 500" line in components\nsSearchSuggestions.js in your application directory (requires a restart to take effect, keep a backup to make sure you don't mess up your install).
Thanks Gavin, changing the timeout worked. 
I will look into the server side piece to see if I can improve the response time, apart from increasing the timeout can you suggest any other way of avoiding the issue because this can happen because of network latency also. 
Can I change the timeout for my plugin only?
No, there's no way to adjust the timeout for your plugin specifically, unfortunately (and no real way to increase apart from manually making the change to Firefox as mentioned).
One more issue that I discovered in suggestions is that it ignores any custom comments that we send for the suggestions. For the querystring "rahul" I send this JSON response as per https://developer.mozilla.org/en/Supporting_search_suggestions_in_search_plugins 
["rahul",["Rahul Gandhi","Rahul Dravid","Rahul Bose"],["Politician","Cricketer","Actor"],["http:\/\/www.myserver.com\/content\/rahul-gandhi-0x388aa","http:\/\/www.myserver.com\/content\/rahul-dravid-0xb8383","http:\/\/www.myserver.com\/content\/rahul-bose-0x2c968"]]

but I dont see any comments against suggestions , I expect "Politician" in front of "Rahul Gandhi" .. which is not happening.

After seeing this piece of code in components\nsSearchSuggestions.js "  (FF 3.0.15)onReadyStateChange" function, I could understanding why the comments are not shown. Can we expect any fix for this issue in future FF releases? (BTW this is an issue in FF 3.5 also)     
for (var i = 0; i < results.length; ++i)
  comments.push("");
I could see this bug logged https://bugzilla.mozilla.org/show_bug.cgi?id=481423
Going to mark this invalid, since it's not a bug per se. Will make sure there's a bug on file of addressing this problem (see e.g. bug 535527 comment 5).
Status: UNCONFIRMED → RESOLVED
Closed: 10 years ago
Resolution: --- → INVALID
Oh sorry about that. Thanks Henrik for clarifying that.

Wouldn't it be a better default to have no timeout and cancel in progress calls if:
1) the search string is changed or
2) if the searchbox loses focus

because i made this opensearch plugin for a community of users and i cant have them all change their firefox manually, they arent tech savvy.
You need to log in before you can comment on or make changes to this bug.