lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Miranda <david.b.mira...@gmail.com>
Subject Re: Lucene Concurrent Search
Date Thu, 05 Sep 2013 15:46:37 GMT
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;
> SearcherManager sm = new SearcherManager(dir, new SearcherFactory());
>
> to get default behaviour.  The javadocs for SearcherFactory explain
> that you can write your own implementation if you want custom
> behaviour such as warming.
>
>
> --
> Ian.
>
>
> On Thu, Sep 5, 2013 at 3:53 PM, David Miranda <david.b.miranda@gmail.com>
> wrote:
> > Hi,
> >
> > I'm trying to implement my code with SearchManager to make  my app
> > thread-safe. I'm follow this post:
> >
> http://blog.mikemccandless.com/2011/09/lucenes-searchermanager-simplifies.html
> >
> > There is a class that implements "SearchWarmer". I can't find this class
> in
> > the Lucene library, what class is that?
> >
> > Thanks.
> >
> >
> > 2013/9/5 Aditya <findbestopensource@gmail.com>
> >
> >> Hi
> >>
> >> You want to use REST service for your search, then my advice would be to
> >> use Solr. As it has buitl-in functionality of REST API.
> >>
> >> If you want to use Lucene then below are my comments:
> >> 1. In do search function, you are creating reader object. If this call
> is
> >> invoked for every query then it would be very expensive. You need to
> create
> >> it once globally and re opon it, if the index is modified. Its better
> use
> >> SearchManager.
> >>
> >> Regards
> >> Aditya
> >> www.findbestopensource.com - Search from 1 Million open source
> projects.
> >>
> >>
> >>
> >> On Thu, Sep 5, 2013 at 6:46 AM, David Miranda <
> david.b.miranda@gmail.com
> >> >wrote:
> >>
> >> > Hi,
> >> >
> >> > I'm developing a web application, that contains a REST service in the
> >> > Tomcat, that receives several requests per second.
> >> > The REST requests do research in a Lucene index, to do this i use the
> >> > IndexSearch.
> >> >
> >> > My questions are:
> >> > - There are concurrency problems in multiple research?
> >> > - What the best design pattern to do this?
> >> >
> >> > public class IndexResearch(){
> >> > >   private static int MAX_HITS = 500;
> >> > >   private static String DIRECTORY = "indexdir";
> >> > >   private IndexSearcher searcher;
> >> > >   private StandardAnalyzer analyzer;
> >> > >
> >> >
> >> >
> >> >
> >> > >   public IndexResearch(){
> >> > >   }
> >> > >   public String doSearch(String text){
> >> > >      analyzer = new StandardAnalyzer(Version.LUCENE_43);
> >> > >      topic = QueryParser.escape(topic);
> >> > >      Query q = new QueryParser(Version.LUCENE_43, "field", analyzer
> >> > > ).parse(text);
> >> > >      File indexDirectory = new File(DIRECTORY);
> >> > >      IndexReader reader;
> >> > >      reader =
> DirectoryReader.open(FSDirectory.open(indexDirectory));
> >> > >      searcher = new IndexSearcher(reader);
> >> > >
> >> >         /*more code*/
> >> >
> >> > >    }
> >> > > }
> >> >
> >> >
> >> > Can I create, in the servlet, one object of this class per client
> request
> >> > (Is that the best design pattern)?
> >> >
> >> > Thanks in advance.
> >> >
> >>
> >
> >
> >
> > --
> > Cumprimentos,
> > David Miranda
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>


-- 
Cumprimentos,
David Miranda

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