Re: DrillSideways accepting FacetCollector parameter
Ahh I see, for this use case you should just subclass DrillSideways and override the buildFacetResult method? That method gets the drill down and all sideways collectors... Mike McCandless http://blog.mikemccandless.com On Wed, Jul 9, 2014 at 1:40 AM, Jigar Shah wrote: > Usecase: > > With below code i perform search. > > DrillSideways drillSideWays = new DrillSideways(searcher, config, > engine.getTaxoReader()); > DrillSidewaysResult result = drillSideWays.search(filterQuery, null, null, > first + limit, sort, true, true); > > In above code i don't have reference to FacetCollector fc, which is used. > Consider i want to get LongRangeFacetCounts, which is based on > NumericDocValuesField. > > facets = new LongRangeFacetCounts(facetField.getQueryName(), fc, > longRanges.toArray(new LongRange[longRanges > .size()])); > > if i use below, i get access to current fc. > > FacetsCollector fc = new FacetsCollector(); > TopDocs topDocs = FacetsCollector.search(searcher, query, null, first + > limit, sort, true, true, fc); > > Difference is if i use ' FacetsCollector.search(searcher, query, null, > first + limit, sort, true, true, fc);' i can get FacetCollector. This is > not true in case of DrillSideways. > > Let me know if, there is already some other way provided. > > Thanks, > Jigar Shah. > > > > > > > On Tue, Jul 8, 2014 at 8:15 PM, Michael McCandless < > luc...@mikemccandless.com> wrote: > >> We could do this, but what's the use case? >> >> E.g. DrillSideways also "hardwires" the drill-sideways collectors it >> creates ... do you control over those as well? Maybe we could make >> methods in the DrillSideways class that you could override? >> >> Mike McCandless >> >> http://blog.mikemccandless.com >> >> >> On Tue, Jul 8, 2014 at 7:14 AM, Jigar Shah wrote: >> > Currently Drillsideways provides following method: >> > >> > public DrillSidewaysResult search(DrillDownQuery query, Collector >> > hitCollector); >> > >> > Can same class provide following method ? >> > >> > public DrillSidewaysResult search(DrillDownQuery query, Collector >> > hitCollector, FacetsCollector facetCollector); >> > >> > Currently, >> > >> > FacetsCollector drillDownCollector = new FacetsCollector(); >> > >> > is created from API method >> > >> > public DrillSidewaysResult search(DrillDownQuery query, Collector >> > hitCollector) throws IOException >> > >> > which can be parametrised ? >> > >> > It will help application to use same FacetsCollector to fetch other >> facets, >> > i.e. non sideways facets. >> > >> > Thanks, >> > Jigar Shah. >> >> - >> To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org >> For additional commands, e-mail: java-user-h...@lucene.apache.org >> >> - To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org For additional commands, e-mail: java-user-h...@lucene.apache.org
PostingsHighlighter in Lucene SearchFiles always returns nulls
Hello, Can anyone help me with an example of using PostingsHighlighter in Lucene 4.7. I am trying to modify SearchFiles.java (which can be found in the demo directory) so that it would display not only which documents contains the terms I was searching for, but also the entire sentences where it found those terms. For example, if I am looking for "brown dog" and document 1 contains a sentence "I have a brown dog", I'd like to see something like this: doc = 1, score = , matching sentence = "I have a brown dog" so I have: IndexReader reader = DirectoryReader.open(FSDirectory.open(new File(index))); IndexSearcher searcher = new IndexSearcher(reader); Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_47,emptyset); AnalyzingQueryParser parser = new AnalyzingQueryParser(Version.LUCENE_47, field, analyzer); Query query = parser.parse("brown dog"); PostingsHighlighter highlighter = new PostingsHighlighter(); TopDocs results = searcher.search(query, 5 * hitsPerPage); String highlights[] = highlighter.highlight("contents", query, searcher, results); for (int k = 0; k< highlights.length; k++) { System.out.println("highlights[ " + k + "] is " + highlights[k]); } I get the documents and the scores but the highlights[#] elements are always null.What am I doing wrong? Thanks! Natalia
Re: IndexSearcher.doc thread safe problem
It's more likely to be a demonstration that concurrent programming is hard, results often hard to predict and debugging very hard. Or perhaps you simply need to add acceptsDocsOutOfOrder() to your collector, returning false. Either way, hard to see any evidence of a thread-safety problem in lucene. If adding acceptsDocsOutOfOrder() doesn't fix it, I suggest you verify that your queue is getting the values you expect, in the order you expect, consistently. Then worry about the display part, first checking everything without any lucene calls. -- Ian. On Wed, Jul 9, 2014 at 5:59 AM, 김선무 wrote: > Hi all, > > I know IndexSearcher is thread safe. > But IndexSearcher.doc is not thread safe maybe... > > I try to below > > First, I extract docID at index directory. And that docID add on > queue(ConcurrentLinkedQueue) > > Second, extract field value using docID poll at this queue after extract > process end. This process is work to multi-threads. > > For this I used the following summation code below: > searcher.search( query, filter, new Collector() { public void collect( int > doc ) { queue.add( docBase + doc ) } ); > Thread thread1 = new Thread( () -> { while( !queue.isEmpty() ) { > System.out.println( searcher.doc(queue.poll()).get("content") ); } } ); > Thread thread2 = new Thread( thread1 ); > thread1.start(); > thread2.start(); > --- > > Result was different in every execution. > > My method is wrong? or IndexSearcher bug? > > Please help me - To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org For additional commands, e-mail: java-user-h...@lucene.apache.org
Re: IndexSearcher.doc thread safe problem
Thanks answer Ian I more check this problem..(Lucene 4.8.1) 1. acceptsDocsOutOfOrder() return false ==> ineffective 2. acceptsDocsOutOfOrder() return true ==> ineffective 3. ConncurrentLinkedQueue add() and poll() methods check value in multi-thread ==> the queue is no problem. 4. Syncronized searcher.doc method call in multi-thread(like this: public synchronized Document getValue( IndexSearcher searcher, int docId ) { return searcher.doc( docId ); }) ==> every execution is same. but If I use this method, It is no difference with single thread performance. What do you think about it? Thanks 2014-07-10 2:04 GMT+09:00 Ian Lea : > It's more likely to be a demonstration that concurrent programming is > hard, results often hard to predict and debugging very hard. > > Or perhaps you simply need to add acceptsDocsOutOfOrder() to your > collector, returning false. > > Either way, hard to see any evidence of a thread-safety problem in lucene. > > If adding acceptsDocsOutOfOrder() doesn't fix it, I suggest you verify > that your queue is getting the values you expect, in the order you > expect, consistently. Then worry about the display part, first > checking everything without any lucene calls. > > > -- > Ian. > > On Wed, Jul 9, 2014 at 5:59 AM, 김선무 wrote: > > Hi all, > > > > I know IndexSearcher is thread safe. > > But IndexSearcher.doc is not thread safe maybe... > > > > I try to below > > > > First, I extract docID at index directory. And that docID add on > > queue(ConcurrentLinkedQueue) > > > > Second, extract field value using docID poll at this queue after extract > > process end. This process is work to multi-threads. > > > > For this I used the following summation code below: > > searcher.search( query, filter, new Collector() { public void collect( > int > > doc ) { queue.add( docBase + doc ) } ); > > Thread thread1 = new Thread( () -> { while( !queue.isEmpty() ) { > > System.out.println( searcher.doc(queue.poll()).get("content") ); } } ); > > Thread thread2 = new Thread( thread1 ); > > thread1.start(); > > thread2.start(); > > --- > > > > Result was different in every execution. > > > > My method is wrong? or IndexSearcher bug? > > > > Please help me > > - > To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org > For additional commands, e-mail: java-user-h...@lucene.apache.org > >
Re: IndexSearcher.doc thread safe problem
: 4. Syncronized searcher.doc method call in multi-thread(like this: public : synchronized Document getValue( IndexSearcher searcher, int docId ) { : return searcher.doc( docId ); }) : ==> every execution is same. :but If I use this method, It is no difference with single thread : performance. : : What do you think about it? You're asking us about the behavior of IndexSearcher.doc from multi-threaded code, but you haven't shown us enough code to even guess as to what your problem might be -- let alone reproduce it. can you please submit a cully self contained program -- that builds an index and then searches it -- and which demonstrates the problem you are having? That way folks trying to help you will have actual code they can run on their machine to understand the problem you are describing. -Hoss http://www.lucidworks.com/ - To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org For additional commands, e-mail: java-user-h...@lucene.apache.org