Class WFDieselSearch

Description

Implements interfaces:

This class provides a PHP-front end to the basic Dieselpoint search capabilities.

The unit of work of WFDieselSearch is a single search. Once a search has been performed, the search cannot be re-used.

Submit a query in DQL and get back paginated, sorted results. Also can generate "FacetGenerator" objects for the current search.

DP Questions:

  • Ranges; can you suggest ranges for facets? The default algo of "make equal chunks" is not that useful. Fixed ranges? Open-ended? (IE Bedrooms as 1+,2+,3+ instead of "auto") CURRENTLY not possible directly, but can pre-process items to group them like this and then display differently. Coming in 4.0 Ranges: ZOOMABLE ranges; ie click on 700-800 and that unveils 700-750 and 750-800. How would this work with the planned new capabilities?
  • Geospatial stuff? Items withing N miles? Not really.
  • Case-sensitivity. How does this work? To turn off case-sensitivity for a field, can you still use parametric? NO. Parametric is case-sensitive; normalize data on the way in.
  • SimpleQuery: golf and tennis => "golf or and or tennis", golf AND tennis => "golf and tennis"
USING WFDieselSearch

Setup:

  1. In your webapp.conf, you should configure DIESELPOINT_JAR_FILES to include paths to all of the DP jars that you need, typically diesel-3.5.1.jar and javax.servlet.jar and mfg.jar (a special FacetGenerator that can generate child counts for children so we know if it's a leaf node or not).
  2. Instantiate a WFDieselSearch object in your module. The only required properties are index and resultObjectLoaderCallback().
WFDieselSearch provides a WFPagedData interface as well, for pagination. WFDieselSearch is meant to be used only as the ID lookup for objects; the loading of the actualy objects is done via a callback function:

array loadObjectsCallback($objectIDArray)

You set the callback with setResultObjectLoaderCallback or setResultObjectLoaderCallbackWithPropelPeer.

The ids passed to the callback are retrieved from the Dieselpoint index. The ID is configured in Dieselpoint by setting up one of the attributes as the item id:

prop_id, type=Item_id, datatype=I # configure "prop_id" as the item_id for the index items.

IMPORTANT! This implementation of WFDieselSearch requires mfg.jar ("MouserFacetGenerator" code). This also requires a special diesel-x-x-x.jar from DP that has the "postings" class.

Located in /framework/WFDieselpoint.php (line 48)

WFObject
   |
   --WFDieselSearch
Class Constant Summary
 SORT_BY_RELEVANCE = '-relevance'
Variable Summary
Method Summary
WFDieselSearch __construct ()
void execute ()
object A getGeneratorObject ([ $treeGenerator = false])
integer getIndexItemCount ()
string getQueryState ()
string getQueryString ()
integer getTotalItems ()
boolean hasRunQuery ()
object Index index ()
boolean isRelevanceSort ()
void itemCount ()
void itemsAtIndex ( $startIndex,  $numItems,  $sortKeys)
void itemsIDsOnPage ()
boolean logPerformanceInfo ()
string queryDescription ()
string replacementQuery ()
object Index searcher ()
void setIndex (string $indexPath)
void setLoadTheseColumnsFromIndex (array $colsArray)
void setLogPerformanceInfo (boolean $bool)
void setPaginator (object WFPaginator $paginator)
void setQueryState (string $state)
void setQueryString (string $string)
void setResultObjectLoaderCallback (mixed $callbackF)
void setResultObjectLoaderCallbackWithPropelPeer (string $peerName, [string $peerMethod = NULL])
void setResultObjectLoaderCallbackWithPropelPeerMethod ([string $peerMethod = NULL])
void setSimpleQuery (string $string, [string $mode = "any"])
void setSort ( $attrID, [ $sortDir = NULL])
void stopTrackingTime (string $msg)
Variables
mixed $dpQueryStateParameterID (line 58)
  • access: protected
mixed $hasRunQuery (line 57)
  • access: protected
mixed $index (line 52)
  • access: protected
mixed $loadTheseColumnsFromIndex (line 56)
  • access: protected
mixed $logPerformanceInfo (line 55)
  • access: protected
mixed $paginator (line 54)
  • access: protected
mixed $resultObjectLoaderCallback (line 61)
  • access: protected
mixed $resultObjectLoaderCallbackPropelMode (line 64)
  • access: protected
mixed $resultObjectLoaderCallbackPropelPeerMethod (line 66)
  • access: protected
mixed $resultObjectLoaderCallbackPropelPeerName (line 65)
  • access: protected
mixed $searcher (line 53)
  • access: protected
Methods
Constructor __construct (line 68)
WFDieselSearch __construct ()

Redefinition of:
WFObject::__construct()
enableRelevanceSorting (line 465)

Add the Relevance sort option to the paginator.

If there is no paginator, this function does nothing.

void enableRelevanceSorting ()
execute (line 366)

Execute the search.

  • throws: object WFException If the search has already been executed. object WFDieselSearch_ParseException If the failure is a parse error of the query.
void execute ()
getGeneratorObject (line 479)

Get a FacetGenerator object.

If no search has been run, then the FacetGenerator works off of the entire index. If a search has run, it works off the results.

  • return: FacetGenerator object [Java].
object A getGeneratorObject ([ $treeGenerator = false])
  • $treeGenerator
getIndexItemCount (line 504)

Get the total number of items in the index.

  • return: The number of items in the index.
integer getIndexItemCount ()
getQueryState (line 403)

Don't know if this works yet... will need to test by using a non-WFDieselNav search interface.

  • return: The current DQL query.
string getQueryState ()
getQueryString (line 434)

Get the query string set by setQueryString.

  • return: The DQL query string.
string getQueryString ()
getTotalItems (line 515)

Get the number of items in the search result.

  • return: The number of "hits" in the result.
  • throws: WFException if the search has not yet been exectued.
integer getTotalItems ()
hasRunQuery (line 355)

Has the search been executed yet?

boolean hasRunQuery ()
index (line 334)

Get the index used for the search.

  • return: The Dieselpoint Index java object.
  • throws: WFException if no index has been set up.
object Index index ()
isRelevanceSort (line 538)

Are the results sorted by relevance?

boolean isRelevanceSort ()
itemCount (line 548)
void itemCount ()

Implementation of:
WFPagedData::itemCount()
Get the total number of items in the paged data.
itemsAtIndex (line 568)
  • todo: Factor out propel loading into self-contained custom callback function.
void itemsAtIndex ( $startIndex,  $numItems,  $sortKeys)
  • $startIndex
  • $numItems
  • $sortKeys

Implementation of:
WFPagedData::itemsAtIndex()
Get a page of the managed items.
itemsIDsOnPage (line 527)

Get an array of the item_id's on the current page of results.

  • throws: WFException if the search has not yet been exectued.
void itemsIDsOnPage ()
logPerformanceInfo (line 109)

Has logPerformanceInfo been turned on?

boolean logPerformanceInfo ()
paginator (line 168)

Get the paginator used by the DieselSearch.

object WFPaginator paginator ()
queryDescription (line 304)

Get a human-readable description of the current query.

string queryDescription ()
queryStateParameterId (line 89)

Get the "parameter ID" used for persisting the queryState of the dieselsearch for pagination and UI state management.

  • return: The parameterID.
string queryStateParameterId ()
replacementQuery (line 322)

Get the replacement query suggested by DP. Spelling corrections, etc.

This seems only to work with full-text searches, not with attribute searches.

  • return: The replacement query string to use.
  • throws: WFException if the search has not yet been exectued.
string replacementQuery ()
searcher (line 345)

Get the searcher used for the search.

  • return: The Dieselpoint Searcher java object. NULL if no searcher is available yet.
object Index searcher ()
setIndex (line 271)

Choose the Dieselpoint index to use for this query.

void setIndex (string $indexPath)
  • string $indexPath: Filesystem path to the dieselpoint index to open.
setLoadTheseColumnsFromIndex (line 141)

Set the columns of data to load from the index in the results.

Note that "item_id" will be added automatically to the columns of the result set as it is used internally.

  • throws: object Exception If the parameter is invalid.
void setLoadTheseColumnsFromIndex (array $colsArray)
  • array $colsArray: An array of column names. The column names must exist in the index.
setLogPerformanceInfo (line 99)

Should WFDieselSearch log the performance info to the PHOCOA log dir file: "diesel.log"?

void setLogPerformanceInfo (boolean $bool)
  • boolean $bool: TRUE to log performance info.
setPaginator (line 156)

Set the paginator associated with this WFDieselSearch.

NOTE: This function automatically sets the WFDieselSearch instance as the data delegate for the paginator, so you don't need to do that yourself.

  • throws: Exception if the passed paginator is not valid.
void setPaginator (object WFPaginator $paginator)
setQueryState (line 413)

Set the queryState of the dieselsearch to the passed state string.

void setQueryState (string $state)
setQueryString (line 424)

Set the DQL query string.

void setQueryString (string $string)
  • string $string: A DQL query string.
setResultObjectLoaderCallback (line 182)

Callback function for loading the items found by DP.

void myFunction( array(WFDieselHit), $sortKeys)

The callback should load the objects via setObject() on each WFDieselHit.

void setResultObjectLoaderCallback (mixed $callbackF)
  • mixed $callbackF: The PHP-style callback function: either function name or array(className, methodName).
setResultObjectLoaderCallbackWithPropelPeer (line 198)

Use a PropelPeer to load the items.

This method will use the "doSelect" method of the peer to load the items with the same sort criteria passed into the DP object. Therefore, it's important that your "attribute" names in DP match the column names.

void setResultObjectLoaderCallbackWithPropelPeer (string $peerName, [string $peerMethod = NULL])
  • string $peerName: Peer name.
  • string $peerMethod: Peer Method name to use.
setResultObjectLoaderCallbackWithPropelPeerMethod (line 223)

Set the PropelPeer method name to use to load the objects.

Default is 'doSelect', but you can set your own method for instance if you want a custom function that loads joined data.

void setResultObjectLoaderCallbackWithPropelPeerMethod ([string $peerMethod = NULL])
  • string $peerMethod: A method name on the propel peer to call to load the propel objects.
setSimpleQuery (line 450)

A higher-level function for calling setQueryString.

Useful when you want to use a text-field "query" input to search. This function strips all "DQL control characters" and calls setQueryString with the result.

Calling this function automatically switches the result sorting to "Relevance" mode.

void setSimpleQuery (string $string, [string $mode = "any"])
  • string $string: The query string input by an end-user.
  • string $mode: "any", "all", or "exact".
setSort (line 553)
void setSort ( $attrID, [ $sortDir = NULL])
  • $attrID
  • $sortDir
startTrackingTime (line 117)

Utility function for debugging to start time tracking.

void startTrackingTime ()
stopTrackingTime (line 127)

Stop tracking time; dump time to 'dieselsearch.log' file with given message.

void stopTrackingTime (string $msg)
  • string $msg: The message to log along with the elapsed time since startTrackingTime() was called.

Inherited Methods

Inherited From WFObject

WFObject::__construct()
WFObject::exposedProperties()
WFObject::getClass()
WFObject::keyPathToTargetAndKey()
WFObject::setValueForKey()
WFObject::setValueForKeyPath()
WFObject::setValuesForKeys()
WFObject::validatedSetValueForKey()
WFObject::validatedSetValueForKeyPath()
WFObject::validateObject()
WFObject::validateValueForKey()
WFObject::validateValueForKeyPath()
WFObject::valueForKey()
WFObject::valueForKeyPath()
WFObject::valueForStaticKey()
WFObject::valueForStaticKeyPath()
WFObject::valueForTargetAndKeyPath()
WFObject::valueForUndefinedKey()
WFObject::valueForUndefinedStaticKey()
WFObject::valuesForKeyPaths()
WFObject::valuesForKeys()
WFObject::_valueForStaticKey()
WFObject::__toString()
Class Constants
SORT_BY_RELEVANCE = '-relevance' (line 50)

Documentation generated on Thu, 14 May 2009 16:19:55 -0400 by phpDocumentor 1.4.2