On Thu, Jan 12, 2006 at 01:25:42PM +0000, John Wards
wrote:> But for the life of me I can not figure out how to get Omega to do the
> sorting by price asc/desc.
In the scriptindex index description change this line:
> price: field
to this:
price: field value=0
This puts the price in value slot #0 of each document. A "value" is
a small piece of data you want fast access to during the match - e.g.
for sorting or collapsing similar documents into a single M-set entry.
It doesn't have to be 0, and you can use any number of slots to allow
sorting on different criteria.
And then tell Omega to sort on value 0 by passing CGI parameters:
SORT=0
But beware that the sort is a STRING sort, not numeric. The simple fix
is to left pad the price to a suitable width with spaces or zeros.
In 0.9.2, Omega doesn't allow reverse sorting. The next release
(hopefully out in a few days) will (just pass SORTREVERSE=1 as well
as SORT=0).
The standard workaround for 0.9.2 and earlier is to store a second value
carefully constructed to sort the opposite way (say in value 1). For
example if property prices are always less than X, you could use X - price.
> I would love to be able to use the PHP bindings but I can't get my head
> around the examples...if someone could give me an basic example on how
> to do the following in PHP it would help a heap!
>
> The search would be something like this:
>
> (AND on by default rather than OR)
>
> address: "fir tree"
> countyid: XL19
> sold: XSOLD0
> sold: XUNDER0
Most of it is going to be identical to the simplesearch.php example,
except you want to build a different query. Something like:
$qp = new_QueryParser();
$query = $qp->parse_query('"fir tree"');
$query = new_Query_from_query_pair(Query_OP_FILTER, $query,
new_Query("XL19"));
$query = new_Query_from_query_pair(Query_OP_FILTER, $query,
new_Query("XSOLD0"));
$query = new_Query_from_query_pair(Query_OP_FILTER, $query,
new_Query("XUNDER0"));
That's assuming you want XSOLD0 AND XUNDER0 - which I guess makes sense
if that means "(not sold) and (not under-offer)".
If using the next release, you'd just write new_Query instead of
new_Query_from_query_pair (the latter was needed to distinguish
the different Query constructors because SWIG didn't support overloading
in PHP bindings, but it does now).
Cheers,
Olly