cancel
Showing results for 
Search instead for 
Did you mean: 

IndexBased Search with sorting

Former Member
0 Kudos

Hi,

In Indexbased search how can we get the search result in sorting order?

I would like to get latest 10 documents from the index in sorting order.

Please let me know if any body have an idea.

Thanks

Accepted Solutions (0)

Answers (1)

Answers (1)

0 Kudos

Hi,

Check these:

/thread/366706 [original link is broken]

/thread/260085 [original link is broken]

Also this may be interesting:

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/45bcc1c0-0d01-0010-1094-fe799341...

Regards,

Praveen Gudapati

Former Member
0 Kudos

public class Sort extends Object implements Serializable

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 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.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 natural order. Note that using this type of term value has higher memory requirements than the other two types.

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.

Edited by: Muhammed Fahid on May 27, 2008 11:13 AM

Former Member
0 Kudos

Thanks Praveen,

I could solve this sorting problem by passing SortPropertyName object to searchWithSession() method of IFederatedSearch.