You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by sophSophie <so...@beezik.com> on 2009/10/30 14:34:58 UTC

JQuery and autosuggest

Hello,

I'm trying to build a autocomplete text box. I think that everything is ok
in the schema.xml and the solrconfig.xml side as I have correct responses
through the solr admin page (I got something like that
:http://brainmaths.fr/IMG/response.txt ).

I don't know really javascript and I tried the code given in Solr 1.4 book
page 241. You can see what I did here :
http://brainmaths.fr/IMG/completion.html and have a look to the source code.

The query is correcty sent to solr (I checked the log) but nothing returns
and I have an error on this line :

return $.map(data.response.docs, function(doc) {

The error is : response.docs is null or isn't an object, I don't know how to
fix it. I guess that docs aren't correctly returned.

I need any help any ideas

Thanks in advance

-----
English is not my mother tongue :)
-- 
View this message in context: http://old.nabble.com/JQuery-and-autosuggest-tp26130209p26130209.html
Sent from the Solr - User mailing list archive at Nabble.com.


RE: Solr YUI autocomplete

Posted by Ankit Bhatnagar <ab...@vantage.com>.
Hey Eric,

That correct however it didn't work with YUI widget.

I changed my approach to use jQuery for now.
 


-Ankit

-----Original Message-----
From: Eric Pugh [mailto:epugh@opensourceconnections.com] 
Sent: Monday, November 02, 2009 10:20 AM
To: solr-user@lucene.apache.org
Subject: Re: Solr YUI autocomplete


It does, have you looked at
http://wiki.apache.org/solr/SolJSON?highlight=%28json%29#Using_Solr.27s_JSON_output_for_AJAX. 
Also, in my book on Solr, there is an example, but using the jquery
autocomplete, which I think was answered earlier on the thread!  Hope that
helps.



ANKITBHATNAGAR wrote:
> 
> 
> Does Solr supports JSONP (JSON with Padding) in the response?
> 
> -Ankit
>  
> 
> 
> -----Original Message-----
> From: Ankit Bhatnagar [mailto:abhatnagar@vantage.com] 
> Sent: Friday, October 30, 2009 10:27 AM
> To: 'solr-user@lucene.apache.org'
> Subject: Solr YUI autocomplete
> 
> Hi Guys,
> 
> I have question regarding - how to specify the 
> 
> I am using YUI autocomplete widget and it expects the JSONP response.
> 
> http://localhost:8983/solr/select/?q=monitor&version=2.2&start=0&rows=10&indent=on&wt=json&json.wrf=
> 
> I am not sure how should I specify the json.wrf=function
> 
> Thanks
> Ankit
> 
> 

-- 
View this message in context: http://old.nabble.com/JQuery-and-autosuggest-tp26130209p26157130.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: Solr YUI autocomplete

Posted by Eric Pugh <ep...@opensourceconnections.com>.
It does, have you looked at
http://wiki.apache.org/solr/SolJSON?highlight=%28json%29#Using_Solr.27s_JSON_output_for_AJAX. 
Also, in my book on Solr, there is an example, but using the jquery
autocomplete, which I think was answered earlier on the thread!  Hope that
helps.



ANKITBHATNAGAR wrote:
> 
> 
> Does Solr supports JSONP (JSON with Padding) in the response?
> 
> -Ankit
>  
> 
> 
> -----Original Message-----
> From: Ankit Bhatnagar [mailto:abhatnagar@vantage.com] 
> Sent: Friday, October 30, 2009 10:27 AM
> To: 'solr-user@lucene.apache.org'
> Subject: Solr YUI autocomplete
> 
> Hi Guys,
> 
> I have question regarding - how to specify the 
> 
> I am using YUI autocomplete widget and it expects the JSONP response.
> 
> http://localhost:8983/solr/select/?q=monitor&version=2.2&start=0&rows=10&indent=on&wt=json&json.wrf=
> 
> I am not sure how should I specify the json.wrf=function
> 
> Thanks
> Ankit
> 
> 

-- 
View this message in context: http://old.nabble.com/JQuery-and-autosuggest-tp26130209p26157130.html
Sent from the Solr - User mailing list archive at Nabble.com.


RE: Solr YUI autocomplete

Posted by Ankit Bhatnagar <ab...@vantage.com>.

Hey Amit,

My index(ie Solr) was on different domain, so I can't use XHR(as XHR doesnot work with cross domain proxyless data fetch).

I tried using YUI's  DS_ScriptNode but didn't work.

I completed my task by using jQuery and it worked well with solr.

-Ankit

-----Original Message-----
From: Amit Nithian [mailto:anithian@gmail.com] 
Sent: Monday, November 02, 2009 1:00 AM
To: solr-user@lucene.apache.org
Subject: Re: Solr YUI autocomplete

I've used the YUI auto complete (albeit not with Solr which shouldn't matter
here) and it should work with JSON. I did one that simply made XHR calls
over to a method on my server which returned pipe delimited text which
worked fine.

Are you using the XHR Data source and if so, what type are you telling it to
expect. One of the examples on the YUI site is text based and i'm sure you
can specify TYPE_JSON or JS_ARRAY too.

- Amit

On Fri, Oct 30, 2009 at 7:04 AM, Ankit Bhatnagar <ab...@vantage.com>wrote:

>
> Does Solr supports JSONP (JSON with Padding) in the response?
>
> -Ankit
>
>
>
> -----Original Message-----
> From: Ankit Bhatnagar [mailto:abhatnagar@vantage.com]
> Sent: Friday, October 30, 2009 10:27 AM
> To: 'solr-user@lucene.apache.org'
> Subject: Solr YUI autocomplete
>
> Hi Guys,
>
> I have question regarding - how to specify the
>
> I am using YUI autocomplete widget and it expects the JSONP response.
>
>
> http://localhost:8983/solr/select/?q=monitor&version=2.2&start=0&rows=10&indent=on&wt=json&json.wrf=
>
> I am not sure how should I specify the json.wrf=function
>
> Thanks
> Ankit
>

Re: Solr YUI autocomplete

Posted by Amit Nithian <an...@gmail.com>.
I've used the YUI auto complete (albeit not with Solr which shouldn't matter
here) and it should work with JSON. I did one that simply made XHR calls
over to a method on my server which returned pipe delimited text which
worked fine.

Are you using the XHR Data source and if so, what type are you telling it to
expect. One of the examples on the YUI site is text based and i'm sure you
can specify TYPE_JSON or JS_ARRAY too.

- Amit

On Fri, Oct 30, 2009 at 7:04 AM, Ankit Bhatnagar <ab...@vantage.com>wrote:

>
> Does Solr supports JSONP (JSON with Padding) in the response?
>
> -Ankit
>
>
>
> -----Original Message-----
> From: Ankit Bhatnagar [mailto:abhatnagar@vantage.com]
> Sent: Friday, October 30, 2009 10:27 AM
> To: 'solr-user@lucene.apache.org'
> Subject: Solr YUI autocomplete
>
> Hi Guys,
>
> I have question regarding - how to specify the
>
> I am using YUI autocomplete widget and it expects the JSONP response.
>
>
> http://localhost:8983/solr/select/?q=monitor&version=2.2&start=0&rows=10&indent=on&wt=json&json.wrf=
>
> I am not sure how should I specify the json.wrf=function
>
> Thanks
> Ankit
>

Solr YUI autocomplete

Posted by Ankit Bhatnagar <ab...@vantage.com>.
Does Solr supports JSONP (JSON with Padding) in the response?

-Ankit
 


-----Original Message-----
From: Ankit Bhatnagar [mailto:abhatnagar@vantage.com] 
Sent: Friday, October 30, 2009 10:27 AM
To: 'solr-user@lucene.apache.org'
Subject: Solr YUI autocomplete

Hi Guys,

I have question regarding - how to specify the 

I am using YUI autocomplete widget and it expects the JSONP response.

http://localhost:8983/solr/select/?q=monitor&version=2.2&start=0&rows=10&indent=on&wt=json&json.wrf=

I am not sure how should I specify the json.wrf=function

Thanks
Ankit

Solr YUI autocomplete

Posted by Ankit Bhatnagar <ab...@vantage.com>.
Hi Guys,

I have question regarding - how to specify the 

I am using YUI autocomplete widget and it expects the JSONP response.

http://localhost:8983/solr/select/?q=monitor&version=2.2&start=0&rows=10&indent=on&wt=json&json.wrf=

I am not sure how should I specify the json.wrf=function

Thanks
Ankit

AW: AW: JQuery and autosuggest

Posted by Ma...@rzf.fin-nrw.de.
as long as you are working on your own pc than this might be ok.
but when someone else is accessing the site via internet, than there is "no localhost",
at least not your. so at this point the real (internet-) server name is needed.
btw: ajax calls are only allowed from the origin server, so a page loaded from

	www.a-server.com

only will allow ajax-calls that also go to www.a-server.com, and not www.b-server.com
or any other

--
mit freundlichen Grüßen

Markus Rietzler - <rietzler_software/>
Rechenzentrum der Finanzverwaltung NRW
0211/4572-2130
 

> -----Ursprüngliche Nachricht-----
> Von: sophSophie [mailto:sophie@beezik.com] 
> Gesendet: Freitag, 30. Oktober 2009 14:57
> An: solr-user@lucene.apache.org
> Betreff: Re: AW: JQuery and autosuggest
> 
> 
> Hallo Markus !
> 
> I think that the servername is correct as I'm testing this 
> autocomplete box
> on my computer (my site is built in localhost, solr is in localhost).
> 
> Am I wrong ?
> 
> Thanks
> 
> 
> Markus.Rietzler wrote:
> > 
> > very simple, in the javascript you have
> > 
> > $("#artist").autocomplete(
> > 	'http://localhost:8983/solr/completion/select/?wt=json', {
> > 
> > you have to change localhost to the correct servername
> > 
> > 
> > --
> > mit freundlichen Grüßen
> > 
> > Markus Rietzler - <rietzler_software/>
> > Rechenzentrum der Finanzverwaltung NRW
> > 0211/4572-2130
> >  
> > 
> >> -----Ursprüngliche Nachricht-----
> >> Von: sophSophie [mailto:sophie@beezik.com] 
> >> Gesendet: Freitag, 30. Oktober 2009 14:35
> >> An: solr-user@lucene.apache.org
> >> Betreff: JQuery and autosuggest
> >> 
> >> 
> >> Hello,
> >> 
> >> I'm trying to build a autocomplete text box. I think that 
> >> everything is ok
> >> in the schema.xml and the solrconfig.xml side as I have 
> >> correct responses
> >> through the solr admin page (I got something like that
> >> :http://brainmaths.fr/IMG/response.txt ).
> >> 
> >> I don't know really javascript and I tried the code given in 
> >> Solr 1.4 book
> >> page 241. You can see what I did here :
> >> http://brainmaths.fr/IMG/completion.html and have a look to 
> >> the source code.
> >> 
> >> The query is correcty sent to solr (I checked the log) but 
> >> nothing returns
> >> and I have an error on this line :
> >> 
> >> return $.map(data.response.docs, function(doc) {
> >> 
> >> The error is : response.docs is null or isn't an object, I 
> >> don't know how to
> >> fix it. I guess that docs aren't correctly returned.
> >> 
> >> I need any help any ideas
> >> 
> >> Thanks in advance
> >> 
> >> -----
> >> English is not my mother tongue :)
> >> -- 
> >> View this message in context: 
> >> 
> http://old.nabble.com/JQuery-and-autosuggest-tp26130209p26130209.html
> >> Sent from the Solr - User mailing list archive at Nabble.com.
> >> 
> >> 
> > 
> > 
> 
> 
> -----
> English is not my mother tongue :)
> -- 
> View this message in context: 
> http://old.nabble.com/JQuery-and-autosuggest-tp26130209p26130511.html
> Sent from the Solr - User mailing list archive at Nabble.com.
> 
> 

Re: AW: JQuery and autosuggest

Posted by sophSophie <so...@beezik.com>.
Hallo Markus !

I think that the servername is correct as I'm testing this autocomplete box
on my computer (my site is built in localhost, solr is in localhost).

Am I wrong ?

Thanks


Markus.Rietzler wrote:
> 
> very simple, in the javascript you have
> 
> $("#artist").autocomplete(
> 	'http://localhost:8983/solr/completion/select/?wt=json', {
> 
> you have to change localhost to the correct servername
> 
> 
> --
> mit freundlichen Grüßen
> 
> Markus Rietzler - <rietzler_software/>
> Rechenzentrum der Finanzverwaltung NRW
> 0211/4572-2130
>  
> 
>> -----Ursprüngliche Nachricht-----
>> Von: sophSophie [mailto:sophie@beezik.com] 
>> Gesendet: Freitag, 30. Oktober 2009 14:35
>> An: solr-user@lucene.apache.org
>> Betreff: JQuery and autosuggest
>> 
>> 
>> Hello,
>> 
>> I'm trying to build a autocomplete text box. I think that 
>> everything is ok
>> in the schema.xml and the solrconfig.xml side as I have 
>> correct responses
>> through the solr admin page (I got something like that
>> :http://brainmaths.fr/IMG/response.txt ).
>> 
>> I don't know really javascript and I tried the code given in 
>> Solr 1.4 book
>> page 241. You can see what I did here :
>> http://brainmaths.fr/IMG/completion.html and have a look to 
>> the source code.
>> 
>> The query is correcty sent to solr (I checked the log) but 
>> nothing returns
>> and I have an error on this line :
>> 
>> return $.map(data.response.docs, function(doc) {
>> 
>> The error is : response.docs is null or isn't an object, I 
>> don't know how to
>> fix it. I guess that docs aren't correctly returned.
>> 
>> I need any help any ideas
>> 
>> Thanks in advance
>> 
>> -----
>> English is not my mother tongue :)
>> -- 
>> View this message in context: 
>> http://old.nabble.com/JQuery-and-autosuggest-tp26130209p26130209.html
>> Sent from the Solr - User mailing list archive at Nabble.com.
>> 
>> 
> 
> 


-----
English is not my mother tongue :)
-- 
View this message in context: http://old.nabble.com/JQuery-and-autosuggest-tp26130209p26130511.html
Sent from the Solr - User mailing list archive at Nabble.com.


RE: autocomplete

Posted by Ankit Bhatnagar <ab...@vantage.com>.

Hey Avlesh,
Thanks for your reply.


-Ankit

-----Original Message-----
From: Avlesh Singh [mailto:avlesh@gmail.com] 
Sent: Saturday, October 31, 2009 10:08 PM
To: solr-user@lucene.apache.org
Subject: Re: autocomplete

>
>
> "q=*:*&fq=ac:*all*&wt=json&rows=15&start=0&indent=on&omitHeader=true&json.wrf=?";
>
Why is the json.wrf not specified? Without the callback function, the string
that is return back is illegal javascript for the browser. You need to
specify this parameter which is a wrapper or a callback function. If you
specify json.wrf=foo, as soon as the browser gets a response, it would call
a function named foo (needs to already defined). Inside "foo" you can have
you own implementation to interpret and render this data.

Cheers
Avlesh

On Sat, Oct 31, 2009 at 12:13 AM, Ankit Bhatnagar <ab...@vantage.com>wrote:

>
> Hi guys,
>
> Enterprise 1.4 Solr Book (AutoComplete) says this works -
>
> My query looks like -
>
>
> "q=*:*&fq=ac:*all*&wt=json&rows=15&start=0&indent=on&omitHeader=true&json.wrf=?";
>
>
> And it returns three results
>
>
> {
>  "responseHeader":{
>  "status":0,
>  "QTime":38,
>  "params":{
>        "indent":"on",
>        "start":"0",
>        "q":"*:*",
>        "wt":"json",
>        "fq":"ac:*all*",
>        "rows":"15"}},
>  "response":{"numFound":3,"start":0,"docs":[
>        {
>         "id":"1",
>         "ac":"Can you show me all the results"},
>        {
>         "id":"2",
>         "ac":"Can you show all companies "},
>        {
>         "id":"3",
>         "ac":"Can you list all companies"}]
>  }}
>
>
>
> But browser says syntax error --
>
>
> Ankit
>
>
>
>
>
>
>
>
>
>
>
>
>
>

Re: autocomplete

Posted by Avlesh Singh <av...@gmail.com>.
>
>
> "q=*:*&fq=ac:*all*&wt=json&rows=15&start=0&indent=on&omitHeader=true&json.wrf=?";
>
Why is the json.wrf not specified? Without the callback function, the string
that is return back is illegal javascript for the browser. You need to
specify this parameter which is a wrapper or a callback function. If you
specify json.wrf=foo, as soon as the browser gets a response, it would call
a function named foo (needs to already defined). Inside "foo" you can have
you own implementation to interpret and render this data.

Cheers
Avlesh

On Sat, Oct 31, 2009 at 12:13 AM, Ankit Bhatnagar <ab...@vantage.com>wrote:

>
> Hi guys,
>
> Enterprise 1.4 Solr Book (AutoComplete) says this works -
>
> My query looks like -
>
>
> "q=*:*&fq=ac:*all*&wt=json&rows=15&start=0&indent=on&omitHeader=true&json.wrf=?";
>
>
> And it returns three results
>
>
> {
>  "responseHeader":{
>  "status":0,
>  "QTime":38,
>  "params":{
>        "indent":"on",
>        "start":"0",
>        "q":"*:*",
>        "wt":"json",
>        "fq":"ac:*all*",
>        "rows":"15"}},
>  "response":{"numFound":3,"start":0,"docs":[
>        {
>         "id":"1",
>         "ac":"Can you show me all the results"},
>        {
>         "id":"2",
>         "ac":"Can you show all companies "},
>        {
>         "id":"3",
>         "ac":"Can you list all companies"}]
>  }}
>
>
>
> But browser says syntax error --
>
>
> Ankit
>
>
>
>
>
>
>
>
>
>
>
>
>
>

autocomplete

Posted by Ankit Bhatnagar <ab...@vantage.com>.
Hi guys,

Enterprise 1.4 Solr Book (AutoComplete) says this works - 

My query looks like - 

"q=*:*&fq=ac:*all*&wt=json&rows=15&start=0&indent=on&omitHeader=true&json.wrf=?";


And it returns three results


{
 "responseHeader":{
  "status":0,
  "QTime":38,
  "params":{
	"indent":"on",
	"start":"0",
	"q":"*:*",
	"wt":"json",
	"fq":"ac:*all*",
	"rows":"15"}},
 "response":{"numFound":3,"start":0,"docs":[
	{
	 "id":"1",
	 "ac":"Can you show me all the results"},
	{
	 "id":"2",
	 "ac":"Can you show all companies "},
	{
	 "id":"3",
	 "ac":"Can you list all companies"}]
 }}



But browser says syntax error -- 


Ankit




 
  





 
 

AW: JQuery and autosuggest

Posted by Ma...@rzf.fin-nrw.de.
very simple, in the javascript you have

$("#artist").autocomplete(
	'http://localhost:8983/solr/completion/select/?wt=json', {

you have to change localhost to the correct servername


--
mit freundlichen Grüßen

Markus Rietzler - <rietzler_software/>
Rechenzentrum der Finanzverwaltung NRW
0211/4572-2130
 

> -----Ursprüngliche Nachricht-----
> Von: sophSophie [mailto:sophie@beezik.com] 
> Gesendet: Freitag, 30. Oktober 2009 14:35
> An: solr-user@lucene.apache.org
> Betreff: JQuery and autosuggest
> 
> 
> Hello,
> 
> I'm trying to build a autocomplete text box. I think that 
> everything is ok
> in the schema.xml and the solrconfig.xml side as I have 
> correct responses
> through the solr admin page (I got something like that
> :http://brainmaths.fr/IMG/response.txt ).
> 
> I don't know really javascript and I tried the code given in 
> Solr 1.4 book
> page 241. You can see what I did here :
> http://brainmaths.fr/IMG/completion.html and have a look to 
> the source code.
> 
> The query is correcty sent to solr (I checked the log) but 
> nothing returns
> and I have an error on this line :
> 
> return $.map(data.response.docs, function(doc) {
> 
> The error is : response.docs is null or isn't an object, I 
> don't know how to
> fix it. I guess that docs aren't correctly returned.
> 
> I need any help any ideas
> 
> Thanks in advance
> 
> -----
> English is not my mother tongue :)
> -- 
> View this message in context: 
> http://old.nabble.com/JQuery-and-autosuggest-tp26130209p26130209.html
> Sent from the Solr - User mailing list archive at Nabble.com.
> 
>