Java Doc for Sort.java in  » Net » lucene-connector » org » apache » lucene » search » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Net » lucene connector » org.apache.lucene.search 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.apache.lucene.search.Sort

Sort
public class Sort implements Serializable(Code)
Encapsulates sort criteria for returned hits.

The fields used to determine sort order must be carefully chosen. Documents must contain a single term in such a field, and the value of the term should indicate the document's relative position in a given sort order. The field must be indexed, but should not be tokenized, and does not need to be stored (unless you happen to want it back with the rest of your document data). In other words:

document.add (new Field ("byNumber", Integer.toString(x), Field.Store.NO, Field.Index.UN_TOKENIZED));

Valid Types of Values

There are four possible kinds of term values which may be put into sorting fields: Integers, Longs, Floats, or Strings. Unless SortField SortField objects are specified, the type of value in the field is determined by parsing the first term in the field.

Integer term values should contain only digits and an optional preceding negative sign. Values must be base 10 and in the range Integer.MIN_VALUE and Integer.MAX_VALUE inclusive. Documents which should appear first in the sort should have low value integers, later documents high values (i.e. the documents should be numbered 1..n where 1 is the first and n the last).

Long term values should contain only digits and an optional preceding negative sign. Values must be base 10 and in the range Long.MIN_VALUE and Long.MAX_VALUE inclusive. Documents which should appear first in the sort should have low value integers, later documents high values.

Float term values should conform to values accepted by Float Float.valueOf(String) (except that NaN and Infinity are not supported). Documents which should appear first in the sort should have low values, later documents high values.

String term values can contain any valid String, but should not be tokenized. The values are sorted according to their Comparable natural order . Note that using this type of term value has higher memory requirements than the other two types.

Object Reuse

One of these objects can be used multiple times and the sort order changed between usages.

This class is thread safe.

Memory Usage

Sorting uses of caches of term values maintained by the internal HitQueue(s). The cache is static and contains an integer or float array of length IndexReader.maxDoc() for each field name for which a sort is performed. In other words, the size of the cache in bytes is:

4 * IndexReader.maxDoc() * (# of different fields actually used to sort)

For String fields, the cache is larger: in addition to the above array, the value of every term in the field is kept in memory. If there are many unique terms in the field, this could be quite large.

Note that the size of the cache is not affected by how many fields are in the index and might be used to sort - only by the ones actually used to sort a result set.

Created: Feb 12, 2004 10:53:57 AM
author:
   Tim Jones (Nacimiento Software)
since:
   lucene 1.4
version:
   $Id: Sort.java 598376 2007-11-26 18:45:39Z dnaber $



Field Summary
final public static  SortINDEXORDER
     Represents sorting by index order.
final public static  SortRELEVANCE
     Represents sorting by computed relevance.
 SortField[]fields
    

Constructor Summary
public  Sort()
     Sorts by computed relevance.
public  Sort(String field)
     Sorts by the terms in field then by index order (document number).
public  Sort(String field, boolean reverse)
     Sorts possibly in reverse by the terms in field then by index order (document number).
public  Sort(String[] fields)
     Sorts in succession by the terms in each field.
public  Sort(SortField field)
     Sorts by the criteria in the given SortField.
public  Sort(SortField[] fields)
     Sorts in succession by the criteria in each SortField.

Method Summary
public  SortField[]getSort()
     Representation of the sort criteria.
final public  voidsetSort(String field)
     Sets the sort to the terms in field then by index order (document number).
public  voidsetSort(String field, boolean reverse)
     Sets the sort to the terms in field possibly in reverse, then by index order (document number).
public  voidsetSort(String[] fieldnames)
     Sets the sort to the terms in each field in succession.
public  voidsetSort(SortField field)
     Sets the sort to the given criteria.
public  voidsetSort(SortField[] fields)
     Sets the sort to the given criteria in succession.
public  StringtoString()
    

Field Detail
INDEXORDER
final public static Sort INDEXORDER(Code)
Represents sorting by index order.



RELEVANCE
final public static Sort RELEVANCE(Code)
Represents sorting by computed relevance. Using this sort criteria returns the same results as calling Searcher.search(Query) Searcher#search() without a sort criteria, only with slightly more overhead.



fields
SortField[] fields(Code)




Constructor Detail
Sort
public Sort()(Code)
Sorts by computed relevance. This is the same sort criteria as calling Searcher.search(Query) Searcher#search() without a sort criteria, only with slightly more overhead.



Sort
public Sort(String field)(Code)
Sorts by the terms in field then by index order (document number). The type of value in field is determined automatically.
See Also:   SortField.AUTO



Sort
public Sort(String field, boolean reverse)(Code)
Sorts possibly in reverse by the terms in field then by index order (document number). The type of value in field is determined automatically.
See Also:   SortField.AUTO



Sort
public Sort(String[] fields)(Code)
Sorts in succession by the terms in each field. The type of value in field is determined automatically.
See Also:   SortField.AUTO



Sort
public Sort(SortField field)(Code)
Sorts by the criteria in the given SortField.



Sort
public Sort(SortField[] fields)(Code)
Sorts in succession by the criteria in each SortField.




Method Detail
getSort
public SortField[] getSort()(Code)
Representation of the sort criteria. Array of SortField objects used in this sort criteria



setSort
final public void setSort(String field)(Code)
Sets the sort to the terms in field then by index order (document number).



setSort
public void setSort(String field, boolean reverse)(Code)
Sets the sort to the terms in field possibly in reverse, then by index order (document number).



setSort
public void setSort(String[] fieldnames)(Code)
Sets the sort to the terms in each field in succession.



setSort
public void setSort(SortField field)(Code)
Sets the sort to the given criteria.



setSort
public void setSort(SortField[] fields)(Code)
Sets the sort to the given criteria in succession.



toString
public String toString()(Code)



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.