Reputation: 709
In documents specified that with SPH_SORT_TIME_SEGMENTS i can sort my timestamp DESCENDED, but how i can sort my timestamp ASCENDED? i trying using SPH_SORT_ATTR_ASC but the it shows null results. i tried it using "modified_date" (using sql_attr_timestamp) and "integered_modified_date" (using sql_attr_bigint) and both of it still showing no results
here's my configuration
source member_private_messages {
type = mysql
sql_host = 192.168.7.101
sql_user = root
sql_pass =
sql_db = proto_db
sql_query = SELECT \
b.message_id as primary_message_id, \
b.message_id as message_id, \
CONCAT(a.first_name, ' ',a.last_name) AS `from` , \
CONCAT(c.first_name, ' ',c.last_name) AS `to` , \
message_from_id, \
deliver_object_id, \
message_title, \
message_content, \
UNIX_TIMESTAMP(modified_date) AS modified_date, \
UNIX_TIMESTAMP(modified_date) AS integered_modified_date \
FROM tbl_member a JOIN \
tbl_messages b JOIN \
tbl_member c ON a.register_id = b.message_from_id AND b.deliver_object_id = c.register_id
# FOR SORT BY or FILTER
sql_attr_bigint = message_id
sql_attr_bigint = message_from_id
sql_attr_bigint = deliver_object_id
sql_attr_string = message_title
sql_attr_string = message_content
sql_attr_timestamp = modified_date
sql_attr_bigint = integered_modified_date
}
here is my php
<?php
require_once "sphinxapi.php";
$client = new SphinxClient();
$client->SetServer('localhost', 9312);
$client->SetConnectTimeout(30);
$client->SetArrayResult(true);
// Sort the index
$client->SetMatchMode(SPH_SORT_ATTR_ASC ,'modified_date'); //RETURNS NULL
// Query the index
$results = $client->Query('','member_private_messages_index');
// Output the matched results in raw format
var_dump($results['matches']);
here is my database structure (it haves 2 simple data)
CREATE TABLE `tbl_member` (
`member_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`register_id` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`register_type` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`first_name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`last_name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`registration_date` datetime DEFAULT NULL,
`verification_date` datetime DEFAULT NULL,
`update_date` datetime DEFAULT NULL,
PRIMARY KEY (`member_id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=DYNAMIC;
CREATE TABLE `tbl_messages` (
`message_id` int(255) unsigned NOT NULL AUTO_INCREMENT,
`message_from_id` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`message_from_type` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`is_public` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL,
`message_type` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`deliver_object_id` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`deliver_object_type` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`message_title` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`message_content` blob,
`created_date` datetime DEFAULT NULL,
`modified_date` datetime DEFAULT NULL,
PRIMARY KEY (`message_id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=DYNAMIC;
Upvotes: 0
Views: 838
Reputation: 21091
$client->SetMatchMode(SPH_SORT_ATTR_ASC ,'modified_date'); //RETURNS NULL
Why are you trying to define a sorting mode via setMatchMode? surely should be using setSortMode
btw it shouldnt return anyting. Its just setting a value for use by the later Query.
Upvotes: 2