lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stephen Green <eelstretch...@gmail.com>
Subject Re: Lucene Concurrent Search
Date Sat, 07 Sep 2013 01:08:54 GMT
Mostly because it already handles all of the I sexing and querying that I
expect you'll want to be doing and now with Solr Cloud you can ven scale
search beyond one machine.

If you're just looking to learn about this stuff, though, it is fun to roll
your own!

On Friday, September 6, 2013, David Miranda wrote:

> Why use Solr instead of Lucene for this kind of application?
>
>
> 2013/9/6 Stephen Green <eelstretching@gmail.com>
>
> > Something like:
> >
> > public class SearchListener implements ServletContextListener {
> >
> >     @Override
> >     public void contextInitialized(ServletContextEvent sce) {
> >
> >         ServletContext sc = sce.getServletContext();
> >         String indexDir = sc.getInitParameter("indexDir");
> >         SearcherManager searcherManager = new
> > SearcherManager(FSDirectory.open(new File(indexDir)), null);
> >         sc.setAttribute("searcherManager", searcherManager);
> >    }
> >
> >    public void contextDestroyed(ServletContextEvent sce) {
> >         ServletContext sc = sce.getServletContext();
> >
> >         SearcherManager searcherManager = (SearcherManager)
> > sc.getAttribute("searcherManager");
> >         if(searcherManager != null) {
> >             try {
> >                 searcherManager.close();
> >             } catch(IOException ex) {
> >                 logger.log(Level.SEVERE, String.format(
> >                         "Error shutting down search engine"), ex);
> >             }
> >         }
> >     }
> > }
> >
> > Usually does the trick.  You need to put some parameters ("indexDir")
> into
> > your web.xml and make sure that it knows that SearchListener is a
> > ServletListener for your Web app.
> >
> > But, to re-iterate what someone else said: if you really just want
> RESTful
> > search, you might be better off with Solr.
> >
> >
> >
> > On Thu, Sep 5, 2013 at 6:21 PM, David Miranda <david.b.miranda@gmail.com
> > >wrote:
> >
> > > Did you have a practical example of the use of SearchManager
> (initialize,
> > > use to do research)?
> > >
> > > Thanks in advance.
> > >
> > >
> > > 2013/9/5 Stephen Green <eelstretching@gmail.com>
> > >
> > > > You can implement a ServletListener for your app and open the index
> > there
> > > > (in the contextInitialized method). You can then create the
> > > SearcherManager
> > > > from the IndexReader/Searcher and store it in the ServletContext,
> where
> > > it
> > > > can be fetched out by your REST servlets.
> > > >
> > > > This is a typical pattern that we use for lots of Web apps that use
> > > > resources like Lucene.
> > > >
> > > >
> > > > On Thu, Sep 5, 2013 at 12:05 PM, Ian Lea <ian.lea@gmail.com> wrote:
> > > >
> > > > > I use a singleton class but there are other ways in tomcat.  Can't
> > > > > remember what - maybe application scope.
> > > > >
> > > > >
> > > > > --
> > > > > Ian.
> > > > >
> > > > >
> > > > > On Thu, Sep 5, 2013 at 4:46 PM, David Miranda <
> > > david.b.miranda@gmail.com
> > > > >
> > > > > wrote:
> > > > > > Where I can initialize the SearchManager variable to after use
it
> > in
> > > > the
> > > > > > REST servlet to do research in the index?
> > > > > >
> > > > > >
> > > > > > 2013/9/5 Ian Lea <ian.lea@gmail.com>
> > > > > >
> > > > > >> I think that blog post was bleeding edge and the API changed
a
> bit
> > > > > >> subsequently.
> > > > > >>
> > > > > >> I use
> > > > > >>
> > > > > >> Directory dir = whatever;
> > > > > >--
> Cumprimentos,
> David Miranda
>


-- 
Stephen Green
http://thesearchguy.wordpress.com

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message