In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "how to use lucene4.7 paging technology". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Before we introduce paging, let's take a look at the above requirement, which does not require paging.
In fact, in lucene, each index corresponds to a non-repeating docid, and this is the same as the pseudo-column rownum of Oralce database. It is precisely because of the existence of this docid that lucene has better performance in massive data retrieval. We all know that Oracle database uses pseudo-columns for paging, so my lucene is the same, since there is a docid. Then the above requirements are very simple.
Method 1: according to each docid in turn to get the document and then write to the txt, so as to avoid the shortcomings of insufficient memory, but such a single read, the speed may be a little slower, but can meet the needs is understandable. The pseudo code is as follows
Try {directory=FSDirectory.open (new File (indexReadPath)); / / Open the index folder IndexReader reader=DirectoryReader.open (directory); / / read the directory IndexSearcher search=new IndexSearcher (reader); / / initialize the query component for (int idoc.indethmur1) {/ / stop break when the number of pages is greater than the total number of pages } else {Document dosc=searcher.doc (docI] .doc); System.out.println (dosc.get ("name"));}}
Finally, let's take a look at the paging method using SearcherAfter. The code is as follows:
Try {directory=FSDirectory.open (new File (indexReadPath)); / / Open index folder IndexReader reader=DirectoryReader.open (directory); / / read directory IndexSearcher search=new IndexSearcher (reader); / / initialize query component int pageStart=0; ScoreDoc lastBottom=null;// is equivalent to pageSize while (pageStart)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.