Search Query and results

973 views
Skip to first unread message

Chris Raheb

unread,
May 11, 2015, 10:36:03 PM5/11/15
to phr...@googlegroups.com
I am working PHRETS and am running into multiple issues with my search.  It may have something to do with using a sample data feed, but wanted to check here to be sure.

1. If i have a 'Class' other than 'Property', i get Uncaught exception 'PHRETS\Exceptions\RETSException' with message 'Invalid Query Syntax' I've tired "RESI", "A", "Office"
2. If i have a 'Query' other than (ID=*), i get Uncaught exception 'PHRETS\Exceptions\RETSException' with message 'Invalid Query Syntax' I've tried (LastUpdated=2012-01-01+) and (City=Toronto)
3. When i do run a query in ID=*, the select columns i get back are not what is expected.  Eg, i am selecting City and PostalCode, but i am always getting back ListingKey and ModificationTimestamp only.

Any help is appreciated.

[craheb@crahebmbp:~/Development/mph$ php index.php

[2015-05-11 16:10:20] PHRETS.DEBUG: Loading Monolog\Logger logger [] []

[2015-05-11 16:10:20] PHRETS.DEBUG: Sending HTTP Request for http://sample.data.crea.ca/Login.svc/Login (Login) {"headers":{"User-Agent":"PHRETS/2.0","RETS-Version":"RETS/1.8","Accept-Encoding":"gzip"},"cookies":[]} []

[2015-05-11 16:10:21] PHRETS.DEBUG: Response: HTTP 200 [] []

[2015-05-11 16:10:21] PHRETS.DEBUG: Sending HTTP Request for http://sample.data.crea.ca/Search.svc/Search (Search) {"query":{"SearchType":"Property","Class":"Property","Query":"(ID=*)","QueryType":"DMQL2","Count":1,"Format":"COMPACT-DECODED","Limit":3,"StandardNames":0,"Select":"ListingId,City,PostalCode,Sewer"},"headers":{"User-Agent":"PHRETS/2.0","RETS-Version":"RETS/1.8","Accept-Encoding":"gzip"},"cookies":["[object] (GuzzleHttp\\Cookie\\SetCookie: {})","[object] (GuzzleHttp\\Cookie\\SetCookie: {})"]} []

[2015-05-11 16:10:21] PHRETS.DEBUG: Response: HTTP 200 [] []

[2015-05-11 16:10:21] PHRETS.DEBUG: 2 column headers/fields given [] []

[2015-05-11 16:10:21] PHRETS.DEBUG: 961 total results found [] []

[2015-05-11 16:10:21] PHRETS.DEBUG: 3 results given [] []

[2015-05-11 16:10:21] PHRETS.DEBUG: Maximum rows returned in response [] []

[2015-05-11 16:10:21] PHRETS.INFO: Testing info: Array (     [ListingKey] => 11937441     [ModificationTimestamp] => 14/06/2012 12:09:54 PM )  [] []

[2015-05-11 16:10:21] PHRETS.INFO: Testing info: Array (     [ListingKey] => 11937440     [ModificationTimestamp] => 14/06/2012 12:09:53 PM )  [] []

[2015-05-11 16:10:21] PHRETS.INFO: Testing info: Array (     [ListingKey] => 11937439     [ModificationTimestamp] => 14/06/2012 12:09:53 PM )  [] []


Jason Graham

unread,
May 12, 2015, 9:52:58 AM5/12/15
to phr...@googlegroups.com
Hi Chris,

I manage the development team at CREA, so can help answer your DDF questions. The main difference between DDF and other RETS servers is that clients aren't expected to query data directly.  DDF has a dashboard where the agents who own the feed will configure their results, adding filters by city, property type, price range, etc.  The set of listings available to that data feed's credentials are restricted based on these filters, so clients are expected to pull all available records.

You can see a description of how this works here at the DDF tech documentation site.  Pay particular attention to section 6, describing suggested behaviour.  Most clients will pull their master list (ID=*) to get IDs and timestamps, then request any missing or updated records by ID - up to 100 IDs per batch (e.g. ID=123,456,789...).



1) Each Resource has only a single class available, with the same name as the Resource.  So Resource=Property and Class=Property is the only supported values when querying listing data.  This is because any property type restrictions have already been applied by the agent when creating/editting his feed.

2) The only queries possible are ID (either * or numbers) or LastUpdated (single timestamp, not range).  City = Toronto filter would already be applied by the agent.

3) ID=* is a treated as a special query we call Master List.  These results are not limited to 100 records, so if you have 150K records available, you can get all records in a single response.  Limit/Offset is still available if you want to page through this list, but most clients get it in a single call.  You can't select any additional columns when doing a master list query.

Hopefully that helps explain what you're seeing.

Jason Graham
Manager, Application Development
CREA

brett.j...@gmail.com

unread,
Feb 3, 2016, 12:18:49 AM2/3/16
to PHRETS
How do you retrieve data using STANDARD-XML rather than COMPACT? I can retrieve Property/Property when using COMPACT but I can't retrieve Office/Office, Agent/Agent, Destination/Destination and Property/Property when querying via STANDARD-XML.

require_once('../vendor/autoload.php');

$config
= new \PHRETS\Configuration;

$config
->setLoginUrl('http://sample.data.crea.ca/Login.svc/Login')
 
->setUsername('CXLHfDVrziCfvwgCuL8nUahC')
 
->setPassword('mFqMsCSPdnb5WO1gpEEtDCHH')
 
->setRetsVersion('1.7.2');

$rets
= new \PHRETS\Session($config);

$connect
= $rets->Login();

$DBML
= '(ID=*)';
$params
= ['Limit' => 1, 'Format' => 'STANDARD-XML'];
$recursive
= false;

$searchCREAResults
= $rets->Search('Office', 'Office', $DBML, $params, $recursive);
$searchCREAResultsArray
= $searchCREAResults->toArray();

PHRETS seems to know there is 51 total results found but says 0 results are given.
[2016-02-02 20:53:22] PHRETS.DEBUG: Response: HTTP 200 [] []
[2016-02-02 20:53:22] PHRETS.DEBUG: 1 column headers/fields given [] []
[2016-02-02 20:53:22] PHRETS.DEBUG: 51 total results found [] []
[2016-02-02 20:53:22] PHRETS.DEBUG: 0 results given [] []
Reply all
Reply to author
Forward
0 new messages