diff -urN /semitmp/xapian/svn/xapian/xapian-applications/omega/omega.cc ./omega.cc
|
old
|
new
|
|
| 68 | 68 | // percentage cut-off |
| 69 | 69 | int threshold = 0; |
| 70 | 70 | |
| 71 | | bool sort_numeric = false; |
| 72 | | Xapian::valueno sort_key = Xapian::BAD_VALUENO; // Don't sort. |
| 73 | | bool sort_ascending = true; |
| 74 | | bool sort_after = false; |
| 75 | 71 | Xapian::Enquire::docid_order docid_order = Xapian::Enquire::ASCENDING; |
| 76 | 72 | |
| 77 | 73 | Xapian::valueno collapse_key = 0; |
| … |
… |
|
| 94 | 90 | // set default thousands and decimal separators: e.g. "16,729 hits" "1.4K" |
| 95 | 91 | option["decimal"] = "."; |
| 96 | 92 | option["thousand"] = ","; |
| 97 | | |
| | 93 | option["sort_numeric"] = "false"; |
| | 94 | option["sort_ascending"] = "true"; |
| | 95 | option["sort_after"] = "false"; |
| | 96 | option["sort_key"] = ""; // don't sort |
| | 97 | |
| 98 | 98 | // set the default stemming language |
| 99 | 99 | option["stemmer"] = DEFAULT_STEM_LANGUAGE; |
| 100 | 100 | |
| … |
… |
|
| 317 | 317 | const string & v = val->second; |
| 318 | 318 | if (v[0] == '#') { |
| 319 | 319 | // FIXME not supported currently! |
| 320 | | sort_numeric = true; |
| 321 | | sort_key = atoi(v.c_str() + 1); |
| | 320 | option["sort_numeric"] = "true"; |
| | 321 | option["sort_key"] = v.substr(1); |
| 322 | 322 | } else { |
| 323 | | sort_key = atoi(v.c_str()); |
| | 323 | option["sort_key"] = v; |
| 324 | 324 | } |
| 325 | 325 | val = cgi_params.find("SORTREVERSE"); |
| 326 | 326 | if (val != cgi_params.end()) { |
| 327 | | sort_ascending = (atoi(val->second.c_str()) == 0); |
| | 327 | if (atoi(val->second.c_str()) != 0) |
| | 328 | option["sort_ascending"] = "false"; |
| 328 | 329 | } |
| 329 | 330 | val = cgi_params.find("SORTAFTER"); |
| 330 | 331 | if (val != cgi_params.end()) { |
| 331 | | sort_after = (atoi(val->second.c_str()) != 0); |
| | 332 | if (atoi(val->second.c_str()) != 0) |
| | 333 | option["sort_after"] = "true"; |
| 332 | 334 | } |
| 333 | 335 | // Add the sorting related options to filters too. |
| 334 | | filters += int_to_string(sort_key); |
| 335 | | if (sort_after) { |
| 336 | | if (sort_ascending) { |
| | 336 | filters += option["sort_key"]; |
| | 337 | if (option["sort_after"] == "true") { |
| | 338 | if (option["sort_ascending"] == "true") { |
| 337 | 339 | filters += 'F'; |
| 338 | 340 | } else { |
| 339 | 341 | filters += 'R'; |
| 340 | 342 | } |
| 341 | 343 | } else { |
| 342 | | if (!sort_ascending) { |
| | 344 | if (option["sort_ascending"] == "false") { |
| 343 | 345 | filters += 'r'; |
| 344 | 346 | } |
| 345 | 347 | } |
diff -urN /semitmp/xapian/svn/xapian/xapian-applications/omega/omega.h ./omega.h
|
old
|
new
|
|
| 56 | 56 | |
| 57 | 57 | extern int threshold; |
| 58 | 58 | |
| 59 | | extern bool sort_numeric; |
| 60 | | extern Xapian::valueno sort_key; |
| 61 | | extern bool sort_ascending; |
| 62 | | extern bool sort_after; |
| 63 | 59 | extern Xapian::Enquire::docid_order docid_order; |
| 64 | 60 | |
| 65 | 61 | extern Xapian::valueno collapse_key; |
diff -urN /semitmp/xapian/svn/xapian/xapian-applications/omega/query.cc ./query.cc
|
old
|
new
|
|
| 375 | 375 | |
| 376 | 376 | enquire->set_cutoff(threshold); |
| 377 | 377 | |
| 378 | | if (sort_key != Xapian::BAD_VALUENO) { |
| 379 | | if (sort_after) { |
| 380 | | enquire->set_sort_by_relevance_then_value(sort_key, sort_ascending); |
| | 378 | if (! option["sort_key"].empty()) { |
| | 379 | if (option["sort_after"] == "true") { |
| | 380 | enquire->set_sort_by_relevance_then_value(string_to_int(option["sort_key"]), option["sort_ascending"]=="true"); |
| 381 | 381 | } else { |
| 382 | | enquire->set_sort_by_value_then_relevance(sort_key, sort_ascending); |
| | 382 | enquire->set_sort_by_value_then_relevance((string_to_int(option["sort_key"]), option["sort_ascending"]=="true"); |
| 383 | 383 | } |
| 384 | 384 | } |
| 385 | 385 | |