Searching within a Search Result

2013-08-06 Thread David Miranda
Hi,

I have a Lucene index that has the fields label and abstract.

I want to do is first do a search by label field, for this i use:

TopScoreDocCollector collector = TopScoreDocCollector.create(MAX_HITS, true
> );
> searcher.search(q, collector);
> ScoreDoc[] hits = collector.topDocs().scoreDocs;


After the results of the first survey, I want to do a search in the
abstract field only in results obtained from the first survey.

How i do this?
Thanks in advance.

David


Re: Searching within a Search Result

2013-08-06 Thread David Miranda
Do this with the BooleanQuery:

> Query q1 = new QueryParser(Version.LUCENE_43, "label", analyzer
> ).parse(label);
> Query q2 = new QueryParser(Version.LUCENE_43, "abstract", analyzer
> ).parse(abstract);
> BooleanQuery bq = new BooleanQuery();
> booleanQuery.add(q1,BooleanClause.Occur.MUST);
> booleanQuery.add(q2,BooleanClause.Occur.MUST);
> Hits hits = indexSearcher.search(booleanQuery);


This is right for what I want to do?

Thanks.

2013/8/6 Ian Lea 

The standard way is to combine the searches by label and abstract into
> one query.  If using QueryParser a simple example would look something
> like label:aaa abstract:bbb abstract:ccc.  You can get the same
> effect, with more flexibility, by building a BooleanQuery in code.
>
> Also consider using a Filter e.g. QueryWrapperFilter on a query for
> label:aaa with the query generated by QueryParser or direct
> construction of a TermQuery.  See also CachingWrapperFilter if the
> index isn't constantly changing.
>
>
> --
> Ian.
>
>
> On Tue, Aug 6, 2013 at 3:19 PM, David Miranda 
> wrote:
> > Hi,
> >
> > I have a Lucene index that has the fields label and abstract.
> >
> > I want to do is first do a search by label field, for this i use:
> >
> > TopScoreDocCollector collector = TopScoreDocCollector.create(MAX_HITS,
> true
> >> );
> >> searcher.search(q, collector);
> >> ScoreDoc[] hits = collector.topDocs().scoreDocs;
> >
> >
> > After the results of the first survey, I want to do a search in the
> > abstract field only in results obtained from the first survey.
> >
> > How i do this?
> > Thanks in advance.
> >
> > David
>
> -----
> To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
> For additional commands, e-mail: java-user-h...@lucene.apache.org
>
>


-- 
Cumprimentos,
David Miranda


Re: Searching within a Search Result

2013-08-06 Thread David Miranda
I experimented with the previous code, but no results are returned from the
index. Someone can give me an example? I have been for some time trying to
implement this functionality.

Thanks.

2013/8/6 David Miranda 

> Do this with the BooleanQuery:
>
>> Query q1 = new QueryParser(Version.LUCENE_43, "label", analyzer
>> ).parse(label);
>> Query q2 = new QueryParser(Version.LUCENE_43, "abstract", analyzer
>> ).parse(abstract);
>> BooleanQuery bq = new BooleanQuery();
>> booleanQuery.add(q1,BooleanClause.Occur.MUST);
>> booleanQuery.add(q2,BooleanClause.Occur.MUST);
>> Hits hits = indexSearcher.search(booleanQuery);
>
>
> This is right for what I want to do?
>
> Thanks.
>
> 2013/8/6 Ian Lea 
>
> The standard way is to combine the searches by label and abstract into
>> one query.  If using QueryParser a simple example would look something
>> like label:aaa abstract:bbb abstract:ccc.  You can get the same
>> effect, with more flexibility, by building a BooleanQuery in code.
>>
>> Also consider using a Filter e.g. QueryWrapperFilter on a query for
>> label:aaa with the query generated by QueryParser or direct
>> construction of a TermQuery.  See also CachingWrapperFilter if the
>> index isn't constantly changing.
>>
>>
>> --
>> Ian.
>>
>>
>> On Tue, Aug 6, 2013 at 3:19 PM, David Miranda 
>> wrote:
>> > Hi,
>> >
>> > I have a Lucene index that has the fields label and abstract.
>> >
>> > I want to do is first do a search by label field, for this i use:
>> >
>> > TopScoreDocCollector collector = TopScoreDocCollector.create(MAX_HITS,
>> true
>> >> );
>> >> searcher.search(q, collector);
>> >> ScoreDoc[] hits = collector.topDocs().scoreDocs;
>> >
>> >
>> > After the results of the first survey, I want to do a search in the
>> > abstract field only in results obtained from the first survey.
>> >
>> > How i do this?
>> > Thanks in advance.
>> >
>> > David
>>
>> -
>> To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
>> For additional commands, e-mail: java-user-h...@lucene.apache.org
>>
>>
>
>
> --
> Cumprimentos,
> David Miranda
>



-- 
Cumprimentos,
David Miranda


Re: Searching within a Search Result

2013-08-19 Thread David Miranda
Still can not implement this feature. Previously to perform a search in the
'label', I used the following code that worked:

Query q = new QueryParser(Version.LUCENE_43, "label", analyzer
> ).parse(label);
> searcher.search(q, collector);
> ScoreDoc[] hits = collector.topDocs().scoreDocs;

But with BooleanQuery does not work. What I want is the result of those
TopDocs, do the search but in the 'abstract' to filter. Has anyone
implemented something similar?


2013/8/7 Ian Lea 

> Your BooleanQuery code looks fine.  Do the label and abstract searches
> work independently?  Are there docs that match both searches? There
> are tips on non-working searches in the FAQ at
>
> http://wiki.apache.org/lucene-java/LuceneFAQ#Why_am_I_getting_no_hits_.2F_incorrect_hits.3F
>
> If that doesn't help I suggest you post the smallest possible
> self-contained example that shows the problem.
>
>
> --
> Ian.
>
>
> On Tue, Aug 6, 2013 at 9:55 PM, David Miranda 
> wrote:
> > I experimented with the previous code, but no results are returned from
> the
> > index. Someone can give me an example? I have been for some time trying
> to
> > implement this functionality.
> >
> > Thanks.
> >
> > 2013/8/6 David Miranda 
> >
> >> Do this with the BooleanQuery:
> >>
> >>> Query q1 = new QueryParser(Version.LUCENE_43, "label", analyzer
> >>> ).parse(label);
> >>> Query q2 = new QueryParser(Version.LUCENE_43, "abstract", analyzer
> >>> ).parse(abstract);
> >>> BooleanQuery bq = new BooleanQuery();
> >>> booleanQuery.add(q1,BooleanClause.Occur.MUST);
> >>> booleanQuery.add(q2,BooleanClause.Occur.MUST);
> >>> Hits hits = indexSearcher.search(booleanQuery);
> >>
> >>
> >> This is right for what I want to do?
> >>
> >> Thanks.
> >>
> >> 2013/8/6 Ian Lea 
> >>
> >> The standard way is to combine the searches by label and abstract into
> >>> one query.  If using QueryParser a simple example would look something
> >>> like label:aaa abstract:bbb abstract:ccc.  You can get the same
> >>> effect, with more flexibility, by building a BooleanQuery in code.
> >>>
> >>> Also consider using a Filter e.g. QueryWrapperFilter on a query for
> >>> label:aaa with the query generated by QueryParser or direct
> >>> construction of a TermQuery.  See also CachingWrapperFilter if the
> >>> index isn't constantly changing.
> >>>
> >>>
> >>> --
> >>> Ian.
> >>>
> >>>
> >>> On Tue, Aug 6, 2013 at 3:19 PM, David Miranda <
> david.b.mira...@gmail.com>
> >>> wrote:
> >>> > Hi,
> >>> >
> >>> > I have a Lucene index that has the fields label and abstract.
> >>> >
> >>> > I want to do is first do a search by label field, for this i use:
> >>> >
> >>> > TopScoreDocCollector collector =
> TopScoreDocCollector.create(MAX_HITS,
> >>> true
> >>> >> );
> >>> >> searcher.search(q, collector);
> >>> >> ScoreDoc[] hits = collector.topDocs().scoreDocs;
> >>> >
> >>> >
> >>> > After the results of the first survey, I want to do a search in the
> >>> > abstract field only in results obtained from the first survey.
> >>> >
> >>> > How i do this?
> >>> > Thanks in advance.
> >>> >
> >>> > David
> >>>
> >>> -
> >>> To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
> >>> For additional commands, e-mail: java-user-h...@lucene.apache.org
> >>>
> >>>
> >>
> >>
> >> --
> >> Cumprimentos,
> >> David Miranda
> >>
> >
> >
> >
> > --
> > Cumprimentos,
> > David Miranda
>
> -
> To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
> For additional commands, e-mail: java-user-h...@lucene.apache.org
>
>


-- 
Cumprimentos,
David Miranda


Lucene Text Similarity

2013-09-03 Thread David Miranda
Is there any way to check the similarity of texts with Lucene?

I have the DBpedia indexed and wanted to get the texts more similar
between the abstract and DBpedia another text. If I do a search in the
abstract field, with a particular text the result is not very
satisfactory. Eg

Abstract DBpedia: "SoundCloud is an online audio distribution platform
Which Allows collaboration, promotion and distribution of audio
recordings."

My Text: "Private Track From DJ Sneak. Download the track now in the
SoundCloud website."

If I do a search as follows:

Query q = new QueryParser (Version.LUCENE_43, "abstract", analyzer).
Parse (mytext);

Search field abstract the "mytext", not me no results are returned.

What can I do to implement this feature?

Thanks in advance,
David

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



Re: Lucene Text Similarity

2013-09-04 Thread David Miranda
Thanks to all, I will take into account your suggestions.

But I think that should have given the concrete use case. Therefore,
taking into account my first example given, I have the email received
by a user and that email I extract topics of interest to associate the
terms of DBpedia (basically DBpedia documents). The problem here is,
for example Apple, may be fruit or a company (Apple Computers). To
accomplish this disambiguation, I wanted to use the abstract vs. text
of the email to find out what the best term to choose.

Thanks.

2013/9/4 Allison, Timothy B. :
> I agree with Ivan and Koji.  You also might want to look into MoreLikeThis, 
> which should take care of finding the highest tf*idf terms for you to use in 
> your query -- 
> http://lucene.apache.org/core/4_4_0/queries/org/apache/lucene/queries/mlt/MoreLikeThis.html
>
> Best,
>
>Tim
>
> 
> From: Ivan Krišto [ivan.kri...@gmail.com]
> Sent: Wednesday, September 04, 2013 3:17 AM
> To: java-user@lucene.apache.org
> Subject: Re: Lucene Text Similarity
>
> On 09/03/2013 07:33 PM, David Miranda wrote:
>
> Is there any way to check the similarity of texts with Lucene? I have the
> DBpedia indexed and wanted to get the texts more similar between the
> abstract and DBpedia another text. If I do a search in the abstract field,
> with a particular text the result is not very satisfactory. Eg Abstract
> DBpedia: "SoundCloud is an online audio distribution platform Which Allows
> collaboration, promotion and distribution of audio recordings." My Text:
> "Private Track From DJ Sneak. Download the track now in the SoundCloud
> website."
>
>
> You are attacking extremly hard problem here -- searching short documents
> with a long query. This creates a lots of problems, as setting document
> frequency of a term to the same magnitude of its own frequency which
> instantly kills some similarity measures.
>
> All you can do is to experiment a lot with different similarity measures
> and preprocessing steps.
>
> Sim measures are simple, just try them all for each preprocessing
> combination.
>
> Suggestions of preprocessing steps:
> - remove all stop words
> - remove all functional words (you can find list of them at wikipedia)
> - boost all uppercase words or words containing at least one uppercase
> letter (add boost of 3 or 4; maybe skip first word of a sentence)
> - break search text into sentences then search index for each sentence
> (combine results using borda count or something similar)
> - do what Koji suggested
>
>   Regards,
> Ivan Krišto
> -----
> To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
> For additional commands, e-mail: java-user-h...@lucene.apache.org
>



-- 
Cumprimentos,
David Miranda

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



Lucene Concurrent Search

2013-09-04 Thread David Miranda
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.


Re: Lucene Concurrent Search

2013-09-05 Thread David Miranda
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 

> 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 
> 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 
> >
> >> 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.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.
> >> >
> >>
> >
> >
> >
> > --
> > Cumprimentos,
> > David Miranda
>
> -
> To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
> For additional commands, e-mail: java-user-h...@lucene.apache.org
>
>


-- 
Cumprimentos,
David Miranda


Re: Lucene Concurrent Search

2013-09-05 Thread David Miranda
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 

> 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  >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


Re: Lucene Concurrent Search

2013-09-05 Thread David Miranda
Did you have a practical example of the use of SearchManager (initialize,
use to do research)?

Thanks in advance.


2013/9/5 Stephen Green 

> 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  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  >
> > 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 
> > >
> > >> 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.mira...@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 
> > >> >
> > >> >> 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.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";
> > >>

Re: Lucene Concurrent Search

2013-09-06 Thread David Miranda
Why use Solr instead of Lucene for this kind of application?


2013/9/6 Stephen Green 

> 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  >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 
> >
> > > 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  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.mira...@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 
> > > > >
> > > > >> 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.mira...@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?
> > > > >> >
>

Search in a specific ScoreDoc result

2013-09-17 Thread David Miranda
Hi,

I want to do a kind of 'facet search', that initial research in a field of
all documents in the Lucene index, and second search in other field of the
documents returned to the first research.

Currently I'm do the first research :

Query q = new QueryParser(Version.LUCENE_43, "label", analyzer
> ).parse(label);
> TopScoreDocCollector collector = TopScoreDocCollector.create(MAX_HITS,
> true);
> searcher.search(q, collector);
> ScoreDoc[] hits = collector.topDocs().scoreDocs;


Now I want to the the next search only in ScoreDoc object and in other
field? How can I do this? I searched and found something related to the
lucene filters, but does not seem to do what I want.

Thanks.