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 Olivier Austina <ol...@gmail.com> on 2015/01/26 23:11:32 UTC

How to implement Auto complete, suggestion client side

Hi All,

I would say I am new to web technology.

I would like to implement auto complete/suggestion in the user search box
as the user type in the search box (like Google for example). I am using
Solr as database. Basically I am  familiar with Solr and I can formulate
suggestion queries.

But now I don't know how to implement suggestion in the User Interface.
Which technologies should I need. The website is in PHP. Any suggestions,
examples, basic tutorial is welcome. Thank you.



Regards
Olivier

Re: How to implement Auto complete, suggestion client side

Posted by Olivier Austina <ol...@gmail.com>.
Hi,

Thank you Dan Davis and Alexandre Rafalovitch. This is very helpful for me.

Regards
Olivier


2015-01-27 0:51 GMT+01:00 Alexandre Rafalovitch <ar...@gmail.com>:

> You've got a lot of options depending on what you want. But since you
> seem to just want _an_ example, you can use mine from
> http://www.solr-start.com/javadoc/solr-lucene/index.html (gray search
> box there).
>
> You can see the source for the test screen (using Spring Boot and
> Spring Data Solr as a middle-layer) and Select2 for the UI at:
> https://github.com/arafalov/Solr-Javadoc/tree/master/SearchServer.
> The Solr definition is at:
>
> https://github.com/arafalov/Solr-Javadoc/tree/master/JavadocIndex/JavadocCollection/conf
>
> Other implementation pieces are in that (and another) public
> repository as well, but it's all in Java. You'll probably want to do
> something similar in PHP.
>
> Regards,
>    Alex.
> ----
> Sign up for my Solr resources newsletter at http://www.solr-start.com/
>
>
> On 26 January 2015 at 17:11, Olivier Austina <ol...@gmail.com>
> wrote:
> > Hi All,
> >
> > I would say I am new to web technology.
> >
> > I would like to implement auto complete/suggestion in the user search box
> > as the user type in the search box (like Google for example). I am using
> > Solr as database. Basically I am  familiar with Solr and I can formulate
> > suggestion queries.
> >
> > But now I don't know how to implement suggestion in the User Interface.
> > Which technologies should I need. The website is in PHP. Any suggestions,
> > examples, basic tutorial is welcome. Thank you.
> >
> >
> >
> > Regards
> > Olivier
>

Re: How to implement Auto complete, suggestion client side

Posted by Alexandre Rafalovitch <ar...@gmail.com>.
You've got a lot of options depending on what you want. But since you
seem to just want _an_ example, you can use mine from
http://www.solr-start.com/javadoc/solr-lucene/index.html (gray search
box there).

You can see the source for the test screen (using Spring Boot and
Spring Data Solr as a middle-layer) and Select2 for the UI at:
https://github.com/arafalov/Solr-Javadoc/tree/master/SearchServer.
The Solr definition is at:
https://github.com/arafalov/Solr-Javadoc/tree/master/JavadocIndex/JavadocCollection/conf

Other implementation pieces are in that (and another) public
repository as well, but it's all in Java. You'll probably want to do
something similar in PHP.

Regards,
   Alex.
----
Sign up for my Solr resources newsletter at http://www.solr-start.com/


On 26 January 2015 at 17:11, Olivier Austina <ol...@gmail.com> wrote:
> Hi All,
>
> I would say I am new to web technology.
>
> I would like to implement auto complete/suggestion in the user search box
> as the user type in the search box (like Google for example). I am using
> Solr as database. Basically I am  familiar with Solr and I can formulate
> suggestion queries.
>
> But now I don't know how to implement suggestion in the User Interface.
> Which technologies should I need. The website is in PHP. Any suggestions,
> examples, basic tutorial is welcome. Thank you.
>
>
>
> Regards
> Olivier

Re: Solr admin Url issues

Posted by Summer Shire <sh...@gmail.com>.
jetty is not running on port 80
it is running on ports that I defined for my instances in sequence.
and no I do not have apache2 reverse proxy in front :(



> On Jan 26, 2015, at 8:18 PM, Dan Davis <da...@gmail.com> wrote:
> 
> Is Jetty actually running on port 80?    Do you have Apache2 reverse proxy
> in front?
> 
> On Mon, Jan 26, 2015 at 11:02 PM, Summer Shire <sh...@gmail.com>
> wrote:
> 
>> Hi All,
>> 
>> Running solr (4.7.2) locally and hitting the admin page like this works
>> just fine http://localhost:8983/solr/ <http://localhost:8983/solr/#># <
>> http://localhost:8983/solr/#>
>> 
>> But on my deployment server my path is
>> http://example.org/jetty/MyApp/1/solr/# <
>> http://example.org/jetty/MyApp/1/solr/#>
>> Or http://example.org/jetty/MyApp/1/solr/admin/cores <
>> http://example.org/jetty/MyApp/1/solr/admin/cores> or
>> http://example.org/jetty/MyApp/1/solr/main/admin/ <
>> http://example.org/jetty/MyApp/1/solr/main/admin/>
>> 
>> the above request in a browser loads the admin page half way and then
>> spawns another request at
>> http://example.org/solr/admin/cores <http://example.org/solr/admin/cores
>>> ….
>> 
>> how can I maintain my other params such as jetty/MyApp/1/
>> 
>> btw http://example.org/jetty/MyApp/1/solr/main/select?q=*:* <
>> http://example.org/jetty/MyApp/1/solr/main/select?q=*:*> or any other
>> requesthandlers work just fine.
>> 
>> What is going on here ? any idea ?
>> 
>> thanks,
>> Summer


Re: Solr admin Url issues

Posted by Dan Davis <da...@gmail.com>.
Is Jetty actually running on port 80?    Do you have Apache2 reverse proxy
in front?

On Mon, Jan 26, 2015 at 11:02 PM, Summer Shire <sh...@gmail.com>
wrote:

> Hi All,
>
> Running solr (4.7.2) locally and hitting the admin page like this works
> just fine http://localhost:8983/solr/ <http://localhost:8983/solr/#># <
> http://localhost:8983/solr/#>
>
> But on my deployment server my path is
> http://example.org/jetty/MyApp/1/solr/# <
> http://example.org/jetty/MyApp/1/solr/#>
> Or http://example.org/jetty/MyApp/1/solr/admin/cores <
> http://example.org/jetty/MyApp/1/solr/admin/cores> or
> http://example.org/jetty/MyApp/1/solr/main/admin/ <
> http://example.org/jetty/MyApp/1/solr/main/admin/>
>
> the above request in a browser loads the admin page half way and then
> spawns another request at
> http://example.org/solr/admin/cores <http://example.org/solr/admin/cores
> >….
>
> how can I maintain my other params such as jetty/MyApp/1/
>
> btw http://example.org/jetty/MyApp/1/solr/main/select?q=*:* <
> http://example.org/jetty/MyApp/1/solr/main/select?q=*:*> or any other
> requesthandlers work just fine.
>
> What is going on here ? any idea ?
>
> thanks,
> Summer

Re: Solr admin Url issues

Posted by Shawn Heisey <ap...@elyograg.org>.
On 1/26/2015 9:02 PM, Summer Shire wrote:
> Running solr (4.7.2) locally and hitting the admin page like this works just fine http://localhost:8983/solr/ <http://localhost:8983/solr/#># <http://localhost:8983/solr/#> 
> 
> But on my deployment server my path is http://example.org/jetty/MyApp/1/solr/# <http://example.org/jetty/MyApp/1/solr/#>
> Or http://example.org/jetty/MyApp/1/solr/admin/cores <http://example.org/jetty/MyApp/1/solr/admin/cores> or  http://example.org/jetty/MyApp/1/solr/main/admin/ <http://example.org/jetty/MyApp/1/solr/main/admin/>
> 
> the above request in a browser loads the admin page half way and then spawns another request at
> http://example.org/solr/admin/cores <http://example.org/solr/admin/cores>….
> 
> how can I maintain my other params such as jetty/MyApp/1/
> 
> btw http://example.org/jetty/MyApp/1/solr/main/select?q=*:* <http://example.org/jetty/MyApp/1/solr/main/select?q=*:*> or any other requesthandlers work just fine.

Is this the scenario that got mentioned on the IRC channel?  That was
indicated to be behind a proxy.

If Solr is behind a proxy that changes the URL path (which is the only
way I can imagine this is working on port 80), the proxy must also
rewrite the URLs that the Solr admin UI sends to the user's browser.
Those URLs are embedded in the data (definitely javascript, and possibly
html) that the admin UI sends to the user's browser, and are created by
information available to Solr.  Solr will have no idea what the path on
the proxy is.

Thanks,
Shawn


Solr admin Url issues

Posted by Summer Shire <sh...@gmail.com>.
Hi All,

Running solr (4.7.2) locally and hitting the admin page like this works just fine http://localhost:8983/solr/ <http://localhost:8983/solr/#># <http://localhost:8983/solr/#> 

But on my deployment server my path is http://example.org/jetty/MyApp/1/solr/# <http://example.org/jetty/MyApp/1/solr/#>
Or http://example.org/jetty/MyApp/1/solr/admin/cores <http://example.org/jetty/MyApp/1/solr/admin/cores> or  http://example.org/jetty/MyApp/1/solr/main/admin/ <http://example.org/jetty/MyApp/1/solr/main/admin/>

the above request in a browser loads the admin page half way and then spawns another request at
http://example.org/solr/admin/cores <http://example.org/solr/admin/cores>….

how can I maintain my other params such as jetty/MyApp/1/

btw http://example.org/jetty/MyApp/1/solr/main/select?q=*:* <http://example.org/jetty/MyApp/1/solr/main/select?q=*:*> or any other requesthandlers work just fine.
 
What is going on here ? any idea ?

thanks,
Summer

Re: How to implement Auto complete, suggestion client side

Posted by Dan Davis <da...@gmail.com>.
Cannot get any easier than jquery-ui's autocomplete widget -
http://jqueryui.com/autocomplete/

Basically, you set some classes and implement a javascript that calls the
server to get the autocomplete data.   I never would expose Solr to
browsers, so I would have the AJAX call go to a php script (or
function/method if you are using a web framework such as CakePHP or
Symfony).

Then, on the server, you make a request to Solr /suggest or /spell with
wt=json, and then you reformulate this into a simple JSON response that is
a simple array of options.

You can do this in stages:

   - Constant suggestions - you change your html and implement Javascript
   that shows constant suggestions after for instance 2 seconds.
   - Constant suggestions from the server - you change your JavaScript to
   call the server, and have the server return a constant list.
   - Dynamic suggestions from the server - you implement the server-side to
   query Solr and turn the return from /suggest or /spell into a JSON array.
   - Tuning, tuning, tuning - you work hard on tuning it so that you get
   high quality suggestions for a wide variety of inputs.

Note that the autocomplete I've described for you is basically the simplest
thing possible, as you suggest you are new to it.   It is not based on data
mining of query and click-through logs, which is a very common pattern
these days.   There is no bolding of the portion of the words that are new.
  It is just a basic autocomplete widget with a delay.

On Mon, Jan 26, 2015 at 5:11 PM, Olivier Austina <ol...@gmail.com>
wrote:

> Hi All,
>
> I would say I am new to web technology.
>
> I would like to implement auto complete/suggestion in the user search box
> as the user type in the search box (like Google for example). I am using
> Solr as database. Basically I am  familiar with Solr and I can formulate
> suggestion queries.
>
> But now I don't know how to implement suggestion in the User Interface.
> Which technologies should I need. The website is in PHP. Any suggestions,
> examples, basic tutorial is welcome. Thank you.
>
>
>
> Regards
> Olivier
>