Lucene search result sorting (an alternative solution in reverse chronological order)

Source: Internet
Author: User

For indexes with a large amount of data (index files larger than 50 MB), do not sort the index fields by index ID (indexorder). The efficiency of the two indexes is nearly 10 times different, the following compares the memory usage with the CPU processing time:

Memory usage comparison:
Figure 1: Sort data by unique ID fields of an integer type

Figure 2: sort by index ID (indexorder)

Compare the objects that occupy the most memory: we can see that figure 1 shows 2,900,766 bytes more than figure 2 (index file size: 61 m)

Processing time comparison:
The processing time for sorting a field with the unique identifier of an integer is 3016 ms, and the sorting time using the index ID (indexorder) is 303 Ms.

Solution:
In order to ensure that the reverse order of index IDS is equivalent to the reverse order of time: When an index is created, it must be created according to the time sequence of the data. Old data is first indexed, and new data is then indexed.
Reverse code:

// The following code is based on Incubating-Apache-Lucene.Net-2.0-004-11Mar07
Hits hits = searcher. Search (query, new sort (New sortfield (null, sortfield. Doc, true )));

Reference: http://markmail.org/message/noq4kohwipx5wzfo#query:Sort.INDEXORDER+page:1+mid:4ydkfgdj6kbvhq2x+state:results

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.