Commit 22213ac7 authored by Bas de Nooijer's avatar Bas de Nooijer

Merge pull request #39 from Gasol/mlt_support

Lots of style, comment and copyright modification
parents b96e9212 20cbe625
...@@ -71,6 +71,10 @@ class Solarium_Client extends Solarium_Configurable ...@@ -71,6 +71,10 @@ class Solarium_Client extends Solarium_Configurable
* Querytype ping * Querytype ping
*/ */
const QUERYTYPE_PING = 'ping'; const QUERYTYPE_PING = 'ping';
/**
* Querytype morelikethis
*/
const QUERYTYPE_MORELIKETHIS = 'mlt'; const QUERYTYPE_MORELIKETHIS = 'mlt';
/** /**
...@@ -104,7 +108,7 @@ class Solarium_Client extends Solarium_Configurable ...@@ -104,7 +108,7 @@ class Solarium_Client extends Solarium_Configurable
'responseparser' => 'Solarium_Client_ResponseParser_Ping' 'responseparser' => 'Solarium_Client_ResponseParser_Ping'
), ),
self::QUERYTYPE_MORELIKETHIS => array( self::QUERYTYPE_MORELIKETHIS => array(
'query' => 'Solarium_Query_MoreLikeThis', 'query' => 'Solarium_Query_MoreLikeThis',
'requestbuilder' => 'Solarium_Client_RequestBuilder_MoreLikeThis', 'requestbuilder' => 'Solarium_Client_RequestBuilder_MoreLikeThis',
'responseparser' => 'Solarium_Client_ResponseParser_MoreLikeThis' 'responseparser' => 'Solarium_Client_ResponseParser_MoreLikeThis'
), ),
......
<?php <?php
/** /**
* Copyright 2011 Bas de Nooijer. All rights reserved. * Copyright 2011 Gasol Wu. PIXNET Digital Media Corporation.
* All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
...@@ -28,9 +29,12 @@ ...@@ -28,9 +29,12 @@
* those of the authors and should not be interpreted as representing official * those of the authors and should not be interpreted as representing official
* policies, either expressed or implied, of the copyright holder. * policies, either expressed or implied, of the copyright holder.
* *
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl> * @copyright Copyright 2011 Gasol Wu <gasol.wu@gmail.com>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING * @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/ * @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Client
*/ */
/** /**
...@@ -71,7 +75,8 @@ class Solarium_Client_Adapter_PeclHttp extends Solarium_Client_Adapter ...@@ -71,7 +75,8 @@ class Solarium_Client_Adapter_PeclHttp extends Solarium_Client_Adapter
if (!isset($options['headers']['Content-Type'])) { if (!isset($options['headers']['Content-Type'])) {
$options['headers']['Content-Type'] = 'text/xml; charset=utf-8'; $options['headers']['Content-Type'] = 'text/xml; charset=utf-8';
} }
$httpResponse = http_post_data($uri, $request->getRawData(), $options); $httpResponse = http_post_data($uri, $request->getRawData(),
$options);
} else if ($method == Solarium_Client_Request::METHOD_GET) { } else if ($method == Solarium_Client_Request::METHOD_GET) {
$httpResponse = http_get($uri, $options); $httpResponse = http_get($uri, $options);
} else if ($method == Solarium_Client_Request::METHOD_HEAD) { } else if ($method == Solarium_Client_Request::METHOD_HEAD) {
...@@ -85,7 +90,8 @@ class Solarium_Client_Adapter_PeclHttp extends Solarium_Client_Adapter ...@@ -85,7 +90,8 @@ class Solarium_Client_Adapter_PeclHttp extends Solarium_Client_Adapter
if ($message = http_parse_message($httpResponse)) { if ($message = http_parse_message($httpResponse)) {
$data = $message->body; $data = $message->body;
if ($firstPositionOfCRLF = strpos($httpResponse, "\r\n\r\n")) { if ($firstPositionOfCRLF = strpos($httpResponse, "\r\n\r\n")) {
$headersAsString = substr($httpResponse, 0, $firstPositionOfCRLF); $headersAsString = substr($httpResponse, 0,
$firstPositionOfCRLF);
$headers = explode("\n", $headersAsString); $headers = explode("\n", $headersAsString);
} }
} }
......
<?php <?php
/** /**
* Copyright 2011 Bas de Nooijer. All rights reserved. * Copyright 2011 Bas de Nooijer.
* Copyright 2011 Gasol Wu. PIXNET Digital Media Corporation.
* All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
...@@ -29,6 +31,7 @@ ...@@ -29,6 +31,7 @@
* policies, either expressed or implied, of the copyright holder. * policies, either expressed or implied, of the copyright holder.
* *
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl> * @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @copyright Copyright 2011 Gasol Wu <gasol.wu@gmail.com>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING * @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/ * @link http://www.solarium-project.org/
* *
...@@ -42,7 +45,8 @@ ...@@ -42,7 +45,8 @@
* @package Solarium * @package Solarium
* @subpackage Client * @subpackage Client
*/ */
class Solarium_Client_RequestBuilder_MoreLikeThis extends Solarium_Client_RequestBuilder class Solarium_Client_RequestBuilder_MoreLikeThis
extends Solarium_Client_RequestBuilder
{ {
/** /**
......
<?php <?php
/** /**
* Copyright 2011 Bas de Nooijer. All rights reserved. * Copyright 2011 Gasol Wu. PIXNET Digital Media Corporation.
* All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
...@@ -28,7 +29,7 @@ ...@@ -28,7 +29,7 @@
* those of the authors and should not be interpreted as representing official * those of the authors and should not be interpreted as representing official
* policies, either expressed or implied, of the copyright holder. * policies, either expressed or implied, of the copyright holder.
* *
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl> * @copyright Copyright 2011 Gasol Wu <gasol.wu@gmail.com>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING * @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/ * @link http://www.solarium-project.org/
* *
...@@ -42,7 +43,8 @@ ...@@ -42,7 +43,8 @@
* @package Solarium * @package Solarium
* @subpackage Client * @subpackage Client
*/ */
class Solarium_Client_ResponseParser_MoreLikeThis extends Solarium_Client_ResponseParser_Select class Solarium_Client_ResponseParser_MoreLikeThis
extends Solarium_Client_ResponseParser_Select
{ {
/** /**
...@@ -57,7 +59,9 @@ class Solarium_Client_ResponseParser_MoreLikeThis extends Solarium_Client_Respon ...@@ -57,7 +59,9 @@ class Solarium_Client_ResponseParser_MoreLikeThis extends Solarium_Client_Respon
$query = $result->getQuery(); $query = $result->getQuery();
$postResult = parent::parse($result); $postResult = parent::parse($result);
if (isset($data['interestingTerms']) and 'none' != $query->getInterestingTerms()) { if (isset($data['interestingTerms'])
and 'none' != $query->getInterestingTerms()
) {
$terms = $data['interestingTerms']; $terms = $data['interestingTerms'];
if ('details' == $query->getInterestingTerms()) { if ('details' == $query->getInterestingTerms()) {
$tempTerms = array(); $tempTerms = array();
......
<?php <?php
/** /**
* Copyright 2011 Bas de Nooijer. All rights reserved. * Copyright 2011 Bas de Nooijer.
* Copyright 2011 Gasol Wu. PIXNET Digital Media Corporation.
* All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
...@@ -29,6 +31,7 @@ ...@@ -29,6 +31,7 @@
* policies, either expressed or implied, of the copyright holder. * policies, either expressed or implied, of the copyright holder.
* *
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl> * @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @copyright Copyright 2011 Gasol Wu <gasol.wu@gmail.com>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING * @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/ * @link http://www.solarium-project.org/
* *
...@@ -53,7 +56,15 @@ class Solarium_Query_MoreLikeThis extends Solarium_Query ...@@ -53,7 +56,15 @@ class Solarium_Query_MoreLikeThis extends Solarium_Query
* Query components * Query components
*/ */
const COMPONENT_DISMAX = 'dismax'; const COMPONENT_DISMAX = 'dismax';
/**
* Query component morelikethis
*/
const COMPONENT_MORELIKETHIS = 'morelikethis'; const COMPONENT_MORELIKETHIS = 'morelikethis';
/**
* Query component highlighting
*/
const COMPONENT_HIGHLIGHTING = 'highlighting'; const COMPONENT_HIGHLIGHTING = 'highlighting';
/** /**
......
<?php <?php
/** /**
* Copyright 2011 Bas de Nooijer. All rights reserved. * Copyright 2011 Gasol Wu. PIXNET Digital Media Corporation.
* All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
...@@ -28,7 +29,7 @@ ...@@ -28,7 +29,7 @@
* those of the authors and should not be interpreted as representing official * those of the authors and should not be interpreted as representing official
* policies, either expressed or implied, of the copyright holder. * policies, either expressed or implied, of the copyright holder.
* *
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl> * @copyright Copyright 2011 Gasol Wu <gasol.wu@gmail.com>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING * @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/ * @link http://www.solarium-project.org/
* *
...@@ -39,7 +40,7 @@ ...@@ -39,7 +40,7 @@
/** /**
* MoreLikeThis query result * MoreLikeThis query result
* *
* This is the standard resulttype for a select query. Example usage: * This is the standard resulttype for a moreLikeThis query. Example usage:
* <code> * <code>
* // total solr results * // total solr results
* $result->getNumFound(); * $result->getNumFound();
...@@ -58,6 +59,11 @@ ...@@ -58,6 +59,11 @@
*/ */
class Solarium_Result_MoreLikeThis extends Solarium_Result_Select class Solarium_Result_MoreLikeThis extends Solarium_Result_Select
{ {
/**
* interesting terms
*/
protected $_interestingTerms;
/** /**
* this will show what "interesting" terms are used for the MoreLikeThis * this will show what "interesting" terms are used for the MoreLikeThis
* query. These are the top tf/idf terms. NOTE: if you select 'details', * query. These are the top tf/idf terms. NOTE: if you select 'details',
...@@ -68,8 +74,6 @@ class Solarium_Result_MoreLikeThis extends Solarium_Result_Select ...@@ -68,8 +74,6 @@ class Solarium_Result_MoreLikeThis extends Solarium_Result_Select
* *
* @var array * @var array
*/ */
protected $_interestingTerms;
public function getInterestingTerms() public function getInterestingTerms()
{ {
$query = $this->getQuery(); $query = $this->getQuery();
......
...@@ -42,7 +42,8 @@ ...@@ -42,7 +42,8 @@
* @package Solarium * @package Solarium
* @subpackage Result * @subpackage Result
*/ */
class Solarium_Result_Select_MoreLikeThis implements IteratorAggregate, Countable class Solarium_Result_Select_MoreLikeThis
implements IteratorAggregate, Countable
{ {
/** /**
...@@ -107,4 +108,4 @@ class Solarium_Result_Select_MoreLikeThis implements IteratorAggregate, Countabl ...@@ -107,4 +108,4 @@ class Solarium_Result_Select_MoreLikeThis implements IteratorAggregate, Countabl
{ {
return count($this->_results); return count($this->_results);
} }
} }
\ No newline at end of file
...@@ -42,7 +42,8 @@ ...@@ -42,7 +42,8 @@
* @package Solarium * @package Solarium
* @subpackage Result * @subpackage Result
*/ */
class Solarium_Result_Select_MoreLikeThis_Result implements IteratorAggregate, Countable class Solarium_Result_Select_MoreLikeThis_Result
implements IteratorAggregate, Countable
{ {
/** /**
...@@ -136,4 +137,4 @@ class Solarium_Result_Select_MoreLikeThis_Result implements IteratorAggregate, C ...@@ -136,4 +137,4 @@ class Solarium_Result_Select_MoreLikeThis_Result implements IteratorAggregate, C
{ {
return count($this->_documents); return count($this->_documents);
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment