Stephane Bailliez wrote:
Hi all,
"starting from document that has field f1 = a, give me the first n
documents sorted by field 'z' ordered by asc/desc"
To be more specific, that's something like:
[...]
// get the document field 'dt' from a search
...
// search must occur starting from the dt we just found
Term upperTerm = new Term(FIELD_DT, descending ? MIN_DT:MAX_DT);
Term lowerTerm = new Term(FIELD_DT, dt);
RangeQuery rangeQuery = new RangeQuery(lowerTerm, upperTerm, false);
// we will search in the content
Query contentQuery = QueryParser.parse(queryString, FIELD_DATACONTENT,
analyzer);
// a document must have both query required
BooleanQuery query = new BooleanQuery();
query.add(rangeQuery, true, false);
query.add(contentQuery, true, false);
// sort according to dt
Sort sort = new Sort( new SortField(FIELD_DT, SortField.STRING,
descending) );
// return only a given number of docs
TopFieldDocs topFieldDocs = searcher.search(query, null, maxlength, sort);
...
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]