Take a look at org.apache.lucene.search.SearcherManager.

>From the javadocs "Utility class to safely share IndexSearcher
instances across multiple threads, while periodically reopening.".


--
Ian.


On Thu, Sep 5, 2013 at 2:16 AM, David Miranda <david.b.mira...@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.

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-user-h...@lucene.apache.org

Reply via email to