Apache Solr

目录

简介

Contains utility methods for retrieving the current extension version and preparing query phrases.

Also contains method for escaping query strings and parsing XML responses.

类摘要

SolrUtils

abstract class SolrUtils {

/* 方法 */

public static SolrObject digestXmlResponse ( string $xmlresponse [, int $parse_mode = 0 ] )

public static string escapeQueryChars ( string $str )

public static string getSolrVersion ( void )

public static string queryPhrase ( string $str )

}

SolrUtils::digestXmlResponse

Parses an response XML string into a SolrObject

说明

public static SolrObject SolrUtils::digestXmlResponse ( string $xmlresponse [, int $parse_mode = 0 ] )

This method parses an response XML string from the Apache Solr server into a SolrObject. It throws a SolrException if there was an error.

参数

xmlresponse
The XML response string from the Solr server.

parse_mode
Use SolrResponse::PARSE_SOLR_OBJ or SolrResponse::PARSE_SOLR_DOC

返回值

Returns the SolrObject representing the XML response.

If the parse_mode parameter is set to SolrResponse::PARSE_SOLR_OBJ Solr documents will be parses as SolrObject instances.

If it is set to SolrResponse::PARSE_SOLR_DOC, they will be parsed as SolrDocument instances.

SolrUtils::escapeQueryChars

Escapes a lucene query string

说明

public static string SolrUtils::escapeQueryChars ( string $str )

Lucene supports escaping special characters that are part of the query syntax.

The current list special characters are:

+ - && || ! ( ) { } [ ] ^ " ~ * ? : \ /

These characters are part of the query syntax and must be escaped

参数

str
This is the query string to be escaped.

返回值

Returns the escaped string 或者在失败时返回 FALSE.

SolrUtils::getSolrVersion

Returns the current version of the Solr extension

说明

public static string SolrUtils::getSolrVersion ( void )

Returns the current Solr version.

参数

此函数没有参数。

返回值

The current version of the Apache Solr extension.

SolrUtils::queryPhrase

Prepares a phrase from an unescaped lucene string

说明

public static string SolrUtils::queryPhrase ( string $str )

Prepares a phrase from an unescaped lucene string.

参数

str
The lucene phrase.

返回值

Returns the phrase contained in double quotes.

简介

This class represents a Solr document that is about to be submitted to the Solr index.

类摘要

SolrInputDocument

final class SolrInputDocument {

/* 常量 */

const integer SolrInputDocument::SORT_DEFAULT = 1 ;

const integer SolrInputDocument::SORT_ASC = 1 ;

const integer SolrInputDocument::SORT_DESC = 2 ;

const integer SolrInputDocument::SORT_FIELD_NAME = 1 ;

const integer SolrInputDocument::SORT_FIELD_VALUE_COUNT = 2 ;

const integer SolrInputDocument::SORT_FIELD_BOOST_VALUE = 4 ;

/* 方法 */

public void addChildDocument ( SolrInputDocument $child )

public void addChildDocuments ( array &$docs )

public bool addField ( string $fieldName , string $fieldValue [, float $fieldBoostValue = 0.0 ] )

public bool clear ( void )

public void __clone ( void )

public __construct ( void )

public bool deleteField ( string $fieldName )

public void __destruct ( void )

public bool fieldExists ( string $fieldName )

public float getBoost ( void )

public array getChildDocuments ( void )

public int getChildDocumentsCount ( void )

public SolrDocumentField getField ( string $fieldName )

public float getFieldBoost ( string $fieldName )

public int getFieldCount ( void )

public array getFieldNames ( void )

public bool hasChildDocuments ( void )

public bool merge ( SolrInputDocument $sourceDoc [, bool $overwrite = TRUE ] )

public bool reset ( void )

public bool setBoost ( float $documentBoostValue )

public bool setFieldBoost ( string $fieldName , float $fieldBoostValue )

public bool sort ( int $sortOrderBy [, int $sortDirection = SolrInputDocument::SORT_ASC ] )

public array toArray ( void )

}

预定义常量

SolrInputDocument Class Constants

SolrInputDocument::SORT_DEFAULT
Sorts the fields in ascending order.

SolrInputDocument::SORT_ASC
Sorts the fields in ascending order.

SolrInputDocument::SORT_DESC
Sorts the fields in descending order.

SolrInputDocument::SORT_FIELD_NAME
Sorts the fields by name

SolrInputDocument::SORT_FIELD_VALUE_COUNT
Sorts the fields by number of values.

SolrInputDocument::SORT_FIELD_BOOST_VALUE
Sorts the fields by boost value.

SolrInputDocument::addChildDocument

Adds a child document for block indexing

说明

public void SolrInputDocument::addChildDocument ( SolrInputDocument $child )

Adds a child document to construct a document block with nested documents.

参数

child
A SolrInputDocument object.

错误/异常

Throws SolrIllegalArgumentException on failure.

Throws SolrException on internal failure.

返回值

范例

示例 #1 SolrInputDocument::addChildDocument example

<?php

include "bootstrap.php";

$options = array
(
    'hostname' => SOLR_SERVER_HOSTNAME,
    'login'    => SOLR_SERVER_USERNAME,
    'password' => SOLR_SERVER_PASSWORD,
    'port'     => SOLR_SERVER_PORT,
    'path'     => SOLR_SERVER_STORE_PATH,
);

$client = new SolrClient($options);

$product = new SolrInputDocument();

$product->addField('id', 'P-BLACK');
$product->addField('cat', 'tshirt');
$product->addField('cat', 'polo');
$product->addField('content_type', 'product');

$small = new SolrInputDocument();
$small->addField('id', 'TS-BLK-S');
$small->addField('content_type', 'sku');
$small->addField('size', 'S');
$small->addField('inventory', 100);

$medium = new SolrInputDocument();
$medium->addField('id', 'TS-BLK-M');
$medium->addField('content_type', 'sku');
$medium->addField('size', 'M');
$medium->addField('inventory', 200);

$large = new SolrInputDocument();
$large->addField('id', 'TS-BLK-L');
$large->addField('content_type', 'sku');
$large->addField('size', 'L');
$large->addField('inventory', 300);

// add child documents 
$product->addChildDocument($small);
$product->addChildDocument($medium);
$product->addChildDocument($large);

// add product document block to the index
$updateResponse = $client->addDocument(
        $product,
        true, // overwrite if the document exists
        10000 // commit within 10 seconds
);

print_r($updateResponse->getResponse());

以上例程的输出类似于:

SolrObject Object
(
    [responseHeader] => SolrObject Object
        (
            [status] => 0
            [QTime] => 5
        )
)

参见

  • SolrInputDocument::addChildDocuments
  • SolrInputDocument::hasChildDocuments
  • SolrInputDocument::getChildDocuments
  • SolrInputDocument::getChildDocumentsCount

SolrInputDocument::addChildDocuments

Adds an array of child documents

说明

public void SolrInputDocument::addChildDocuments ( array &$docs )

Adds an array of child documents to the current input document.

参数

docs
An array of SolrInputDocument objects.

错误/异常

Throws SolrIllegalArgumentException on failure.

Throws SolrException on internal failure.

返回值

范例

示例 #1 SolrInputDocument::addChildDocuments example

<?php

include "bootstrap.php";

$options = array
(
    'hostname' => SOLR_SERVER_HOSTNAME,
    'login'    => SOLR_SERVER_USERNAME,
    'password' => SOLR_SERVER_PASSWORD,
    'port'     => SOLR_SERVER_PORT,
    'path'     => SOLR_SERVER_STORE_PATH,
);

$client = new SolrClient($options);

$product = new SolrInputDocument();

$product->addField('id', 'P-BLACK');
$product->addField('cat', 'tshirt');
$product->addField('cat', 'polo');
$product->addField('content_type', 'product');

$small = new SolrInputDocument();
$small->addField('id', 'TS-BLK-S');
$small->addField('content_type', 'sku');
$small->addField('size', 'S');
$small->addField('inventory', 100);

$medium = new SolrInputDocument();
$medium->addField('id', 'TS-BLK-M');
$medium->addField('content_type', 'sku');
$medium->addField('size', 'M');
$medium->addField('inventory', 200);

$large = new SolrInputDocument();
$large->addField('id', 'TS-BLK-L');
$large->addField('content_type', 'sku');
$large->addField('size', 'L');
$large->addField('inventory', 300);

// add child documents 
$skus = [$small, $medium, $large];
$product->addChildDocuments($skus);

// add the product document block to the index
$updateResponse = $client->addDocument(
        $product,
        true, // overwrite if the document exists
        10000 // commit within 10 seconds
);

print_r($updateResponse->getResponse());

以上例程的输出类似于:

SolrObject Object
(
    [responseHeader] => SolrObject Object
        (
            [status] => 0
            [QTime] => 5
        )
)

参见

  • SolrInputDocument::addChildDocument
  • SolrInputDocument::hasChildDocuments
  • SolrInputDocument::getChildDocuments
  • SolrInputDocument::getChildDocumentsCount

SolrInputDocument::addField

Adds a field to the document

说明

public bool SolrInputDocument::addField ( string $fieldName , string $fieldValue [, float $fieldBoostValue = 0.0 ] )

For multi-value fields, if a valid boost value is specified, the specified value will be multiplied by the current boost value for this field.

参数

fieldName
The name of the field

fieldValue
The value for the field.

fieldBoostValue
The index time boost for the field. Though this cannot be negative, you can still pass values less than 1.0 but they must be greater than zero.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

SolrInputDocument::clear

Resets the input document

说明

public bool SolrInputDocument::clear ( void )

Resets the document by dropping all the fields and resets the document boost to zero.

参数

此函数没有参数。

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

SolrInputDocument::__clone

Creates a copy of a SolrDocument

说明

public void SolrInputDocument::__clone ( void )

Should not be called directly. It is used to create a deep copy of a SolrInputDocument.

参数

此函数没有参数。

返回值

Creates a new SolrInputDocument instance.

SolrInputDocument::__construct

Constructor

说明

public SolrInputDocument::__construct ( void )

Constructor.

参数

此函数没有参数。

返回值

None.

SolrInputDocument::deleteField

Removes a field from the document

说明

public bool SolrInputDocument::deleteField ( string $fieldName )

Removes a field from the document.

参数

fieldName
The name of the field.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

SolrInputDocument::__destruct

Destructor

说明

public void SolrInputDocument::__destruct ( void )

Destructor

参数

此函数没有参数。

返回值

None.

SolrInputDocument::fieldExists

Checks if a field exists

说明

public bool SolrInputDocument::fieldExists ( string $fieldName )

Checks if a field exists

参数

fieldName
Name of the field.

返回值

Returns TRUE if the field was found and FALSE if it was not found.

SolrInputDocument::getBoost

Retrieves the current boost value for the document

说明

public float SolrInputDocument::getBoost ( void )

Retrieves the current boost value for the document.

参数

此函数没有参数。

返回值

Returns the boost value on success and FALSE on failure.

SolrInputDocument::getChildDocuments

Returns an array of child documents (SolrInputDocument)

说明

public array SolrInputDocument::getChildDocuments ( void )

Returns an array of child documents (SolrInputDocument)

参数

此函数没有参数。

返回值

参见

  • SolrInputDocument::addChildDocument
  • SolrInputDocument::addChildDocuments
  • SolrInputDocument::hasChildDocuments
  • SolrInputDocument::getChildDocumentsCount

SolrInputDocument::getChildDocumentsCount

Returns the number of child documents

说明

public int SolrInputDocument::getChildDocumentsCount ( void )

Returns the number of child documents

参数

此函数没有参数。

返回值

参见

  • SolrInputDocument::addChildDocument
  • SolrInputDocument::addChildDocuments
  • SolrInputDocument::hasChildDocuments
  • SolrInputDocument::getChildDocuments

SolrInputDocument::getField

Retrieves a field by name

说明

public SolrDocumentField SolrInputDocument::getField ( string $fieldName )

Retrieves a field in the document.

参数

fieldName
The name of the field.

返回值

Returns a SolrDocumentField object on success and FALSE on failure.

SolrInputDocument::getFieldBoost

Retrieves the boost value for a particular field

说明

public float SolrInputDocument::getFieldBoost ( string $fieldName )

Retrieves the boost value for a particular field.

参数

fieldName
The name of the field.

返回值

Returns the boost value for the field or FALSE if there was an error.

SolrInputDocument::getFieldCount

Returns the number of fields in the document

说明

public int SolrInputDocument::getFieldCount ( void )

Returns the number of fields in the document.

参数

此函数没有参数。

返回值

Returns an integer on success 或者在失败时返回 FALSE.

SolrInputDocument::getFieldNames

Returns an array containing all the fields in the document

说明

public array SolrInputDocument::getFieldNames ( void )

Returns an array containing all the fields in the document.

参数

此函数没有参数。

返回值

Returns an array on success and FALSE on failure.

SolrInputDocument::hasChildDocuments

Returns true if the document has any child documents

说明

public bool SolrInputDocument::hasChildDocuments ( void )

Checks whether the document has any child documents

参数

此函数没有参数。

返回值

参见

  • SolrInputDocument::addChildDocument
  • SolrInputDocument::addChildDocuments
  • SolrInputDocument::getChildDocuments
  • SolrInputDocument::getChildDocumentsCount

SolrInputDocument::merge

Merges one input document into another

说明

public bool SolrInputDocument::merge ( SolrInputDocument $sourceDoc [, bool $overwrite = TRUE ] )

Merges one input document into another.

参数

sourceDoc
The source document.

overwrite
If this is TRUE it will replace matching fields in the destination document.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE。 In the future, this will be modified to return the number of fields in the new document.

SolrInputDocument::reset

This is an alias of SolrInputDocument::clear

说明

public bool SolrInputDocument::reset ( void )

This is an alias of SolrInputDocument::clear

参数

此函数没有参数。

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

SolrInputDocument::setBoost

Sets the boost value for this document

说明

public bool SolrInputDocument::setBoost ( float $documentBoostValue )

Sets the boost value for this document.

参数

documentBoostValue
The index-time boost value for this document.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

SolrInputDocument::setFieldBoost

Sets the index-time boost value for a field

说明

public bool SolrInputDocument::setFieldBoost ( string $fieldName , float $fieldBoostValue )

Sets the index-time boost value for a field. This replaces the current boost value for this field.

参数

fieldName
The name of the field.

fieldBoostValue
The index time boost value.

SolrInputDocument::sort

Sorts the fields within the document

说明

public bool SolrInputDocument::sort ( int $sortOrderBy [, int $sortDirection = SolrInputDocument::SORT_ASC ] )

The fields are rearranged according to the specified criteria and sort direction
   
   Fields can be sorted by boost values, field names and number of values.
   
   The $order_by parameter must be one of :
   
   * SolrInputDocument::SORT_FIELD_NAME
   * SolrInputDocument::SORT_FIELD_BOOST_VALUE
   * SolrInputDocument::SORT_FIELD_VALUE_COUNT
   
   The sort direction can be one of :
   
   * SolrInputDocument::SORT_DEFAULT
   * SolrInputDocument::SORT_ASC
   * SolrInputDocument::SORT_DESC

参数

sortOrderBy
The sort criteria

sortDirection
The sort direction

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

SolrInputDocument::toArray

Returns an array representation of the input document

说明

public array SolrInputDocument::toArray ( void )

Returns an array representation of the input document.

参数

此函数没有参数。

返回值

Returns an array containing the fields. It returns FALSE on failure.

简介

Represents a Solr document retrieved from a query response.

类摘要

SolrDocument

final class SolrDocument implements ArrayAccess , Iterator , Serializable {

/* 常量 */

const integer SolrDocument::SORT_DEFAULT = 1 ;

const integer SolrDocument::SORT_ASC = 1 ;

const integer SolrDocument::SORT_DESC = 2 ;

const integer SolrDocument::SORT_FIELD_NAME = 1 ;

const integer SolrDocument::SORT_FIELD_VALUE_COUNT = 2 ;

const integer SolrDocument::SORT_FIELD_BOOST_VALUE = 4 ;

/* 方法 */

public bool addField ( string $fieldName , string $fieldValue )

public bool clear ( void )

public void __clone ( void )

public __construct ( void )

public SolrDocumentField current ( void )

public bool deleteField ( string $fieldName )

public void __destruct ( void )

public bool fieldExists ( string $fieldName )

public SolrDocumentField __get ( string $fieldName )

public array getChildDocuments ( void )

public int getChildDocumentsCount ( void )

public SolrDocumentField getField ( string $fieldName )

public int getFieldCount ( void )

public array getFieldNames ( void )

public SolrInputDocument getInputDocument ( void )

public bool hasChildDocuments ( void )

public bool __isset ( string $fieldName )

public string key ( void )

public bool merge ( SolrDocument $sourceDoc [, bool $overwrite = TRUE ] )

public void next ( void )

public bool offsetExists ( string $fieldName )

public SolrDocumentField offsetGet ( string $fieldName )

public void offsetSet ( string $fieldName , string $fieldValue )

public void offsetUnset ( string $fieldName )

public bool reset ( void )

public void rewind ( void )

public string serialize ( void )

public bool __set ( string $fieldName , string $fieldValue )

public bool sort ( int $sortOrderBy [, int $sortDirection = SolrDocument::SORT_ASC ] )

public array toArray ( void )

public void unserialize ( string $serialized )

public bool __unset ( string $fieldName )

public bool valid ( void )

}

预定义常量

SolrDocument::SORT_DEFAULT
Default mode for sorting fields within the document.

SolrDocument::SORT_ASC
Sorts the fields in ascending order

SolrDocument::SORT_DESC
Sorts the fields in descending order

SolrDocument::SORT_FIELD_NAME
Sorts the fields by field name.

SolrDocument::SORT_FIELD_VALUE_COUNT
Sorts the fields by number of values in each field.

SolrDocument::SORT_FIELD_BOOST_VALUE
Sorts the fields by thier boost values.

SolrDocument::addField

Adds a field to the document

说明

public bool SolrDocument::addField ( string $fieldName , string $fieldValue )

This method adds a field to the SolrDocument instance.

参数

fieldName
The name of the field

fieldValue
The value of the field.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

SolrDocument::clear

Drops all the fields in the document

说明

public bool SolrDocument::clear ( void )

Resets the current object. Discards all the fields and resets the document boost to zero.

参数

此函数没有参数。

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

SolrDocument::__clone

Creates a copy of a SolrDocument object

说明

public void SolrDocument::__clone ( void )

Creates a copy of a SolrDocument object. Not to be called directly.

参数

此函数没有参数。

返回值

None.

SolrDocument::__construct

Constructor

说明

public SolrDocument::__construct ( void )

Constructor for SolrDocument

参数

此函数没有参数。

返回值

SolrDocument::current

Retrieves the current field

说明

public SolrDocumentField SolrDocument::current ( void )

Retrieves the current field

参数

此函数没有参数。

返回值

Returns the field

SolrDocument::deleteField

Removes a field from the document

说明

public bool SolrDocument::deleteField ( string $fieldName )

Removes a field from the document.

参数

fieldName
Name of the field

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

SolrDocument::__destruct

Destructor

说明

public void SolrDocument::__destruct ( void )

Destructor for SolrDocument.

参数

此函数没有参数。

返回值

SolrDocument::fieldExists

Checks if a field exists in the document

说明

public bool SolrDocument::fieldExists ( string $fieldName )

Checks if the requested field as a valid fieldname in the document.

参数

fieldName
The name of the field.

返回值

Returns TRUE if the field is present and FALSE if it does not.

SolrDocument::__get

Access the field as a property

说明

public SolrDocumentField SolrDocument::__get ( string $fieldName )

Magic method for accessing the field as a property.

参数

fieldName
The name of the field.

返回值

Returns a SolrDocumentField instance.

SolrDocument::getChildDocuments

Returns an array of child documents (SolrDocument)

说明

public array SolrDocument::getChildDocuments ( void )

Returns an array of child documents (SolrDocument)

参数

此函数没有参数。

返回值

参见

  • SolrDocument::hasChildDocuments
  • SolrDocument::getChildDocumentsCount

SolrDocument::getChildDocumentsCount

Returns the number of child documents

说明

public int SolrDocument::getChildDocumentsCount ( void )

Returns the number of child documents

参数

此函数没有参数。

返回值

参见

  • SolrDocument::hasChildDocuments
  • SolrDocument::getChildDocuments

SolrDocument::getField

Retrieves a field by name

说明

public SolrDocumentField SolrDocument::getField ( string $fieldName )

Retrieves a field by name.

参数

fieldName
Name of the field.

返回值

Returns a SolrDocumentField on success and FALSE on failure.

SolrDocument::getFieldCount

Returns the number of fields in this document

说明

public int SolrDocument::getFieldCount ( void )

Returns the number of fields in this document. Multi-value fields are only counted once.

参数

此函数没有参数。

返回值

Returns an integer on success and FALSE on failure.

SolrDocument::getFieldNames

Returns an array of fields names in the document

说明

public array SolrDocument::getFieldNames ( void )

Returns an array of fields names in the document.

参数

此函数没有参数。

返回值

Returns an array containing the names of the fields in this document.

SolrDocument::getInputDocument

Returns a SolrInputDocument equivalent of the object

说明

public SolrInputDocument SolrDocument::getInputDocument ( void )

Returns a SolrInputDocument equivalent of the object. This is useful if one wishes to resubmit/update a document retrieved from a query.

参数

此函数没有参数。

返回值

Returns a SolrInputDocument on success and NULL on failure.

SolrDocument::hasChildDocuments

Checks whether the document has any child documents

说明

public bool SolrDocument::hasChildDocuments ( void )

Checks whether the document has any child documents

参数

此函数没有参数。

返回值

参见

  • SolrDocument::getChildDocuments
  • SolrDocument::getChildDocumentsCount

SolrDocument::__isset

Checks if a field exists

说明

public bool SolrDocument::__isset ( string $fieldName )

Checks if a field exists

参数

fieldName
Name of the field.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

SolrDocument::key

Retrieves the current key

说明

public string SolrDocument::key ( void )

Retrieves the current key.

参数

此函数没有参数。

返回值

Returns the current key.

SolrDocument::merge

Merges source to the current SolrDocument

说明

public bool SolrDocument::merge ( SolrDocument $sourceDoc [, bool $overwrite = TRUE ] )

Merges source to the current SolrDocument.

参数

sourceDoc
The source document.

overwrite
If this is TRUE then fields with the same name in the destination document will be overwritten.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

SolrDocument::next

Moves the internal pointer to the next field

说明

public void SolrDocument::next ( void )

Moves the internal pointer to the next field.

参数

此函数没有参数。

返回值

This method has no return value.

SolrDocument::offsetExists

Checks if a particular field exists

说明

public bool SolrDocument::offsetExists ( string $fieldName )

Checks if a particular field exists. This is used when the object is treated as an array.

参数

fieldName
The name of the field.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

SolrDocument::offsetGet

Retrieves a field

说明

public SolrDocumentField SolrDocument::offsetGet ( string $fieldName )

This is used to retrieve the field when the object is treated as an array.

参数

fieldName
The name of the field.

返回值

Returns a SolrDocumentField object.

SolrDocument::offsetSet

Adds a field to the document

说明

public void SolrDocument::offsetSet ( string $fieldName , string $fieldValue )

Used when the object is treated as an array to add a field to the document.

参数

fieldName
The name of the field.

fieldValue
The value for this field.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

SolrDocument::offsetUnset

Removes a field

说明

public void SolrDocument::offsetUnset ( string $fieldName )

Removes a field from the document.

参数

fieldName
The name of the field.

返回值

No return value.

SolrDocument::reset

This is an alias to SolrDocument::clear()

说明

public bool SolrDocument::reset ( void )

This is an alias to SolrDocument::clear()

参数

此函数没有参数。

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

SolrDocument::rewind

Resets the internal pointer to the beginning

说明

public void SolrDocument::rewind ( void )

Resets the internal pointer to the beginning.

参数

此函数没有参数。

返回值

This method has no return value.

SolrDocument::serialize

Used for custom serialization

说明

public string SolrDocument::serialize ( void )

Used for custom serialization.

参数

此函数没有参数。

返回值

Returns a string representing the serialized Solr document.

SolrDocument::__set

Adds another field to the document

说明

public bool SolrDocument::__set ( string $fieldName , string $fieldValue )

Adds another field to the document. Used to set the fields as new properties.

参数

fieldName
Name of the field.

fieldValue
Field value.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

SolrDocument::sort

Sorts the fields in the document

说明

public bool SolrDocument::sort ( int $sortOrderBy [, int $sortDirection = SolrDocument::SORT_ASC ] )

The fields are rearranged according to the specified criteria and sort direction
   
   Fields can be sorted by boost values, field names and number of values.
   
   The sortOrderBy parameter must be one of :
   
   * SolrDocument::SORT_FIELD_NAME
   * SolrDocument::SORT_FIELD_BOOST_VALUE
   * SolrDocument::SORT_FIELD_VALUE_COUNT
   
   The sortDirection can be one of :
   
   * SolrDocument::SORT_DEFAULT
   * SolrDocument::SORT_ASC
   * SolrDocument::SORT_DESC
   
   The default way is to sort in ascending order.

参数

sortOrderBy
The sort criteria.

sortDirection
The sort direction.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

SolrDocument::toArray

Returns an array representation of the document

说明

public array SolrDocument::toArray ( void )

Returns an array representation of the document.

参数

此函数没有参数。

返回值

Returns an array representation of the document.

范例

示例 #1 SolrDocument::toArray example

<?php

$doc = new SolrDocument();

$doc->addField('id', 1123);

$doc->features = "PHP Client Side";
$doc->features = "Fast development cycles";

$doc['cat'] = 'Software';
$doc['cat'] = 'Custom Search';
$doc->cat   = 'Information Technology';

print_r($doc->toArray());

?>

以上例程的输出类似于:

Array
(
    [document_boost] => 0
    [field_count] => 3
    [fields] => Array
        (
            [0] => SolrDocumentField Object
                (
                    [name] => id
                    [boost] => 0
                    [values] => Array
                        (
                            [0] => 1123
                        )

                )

            [1] => SolrDocumentField Object
                (
                    [name] => features
                    [boost] => 0
                    [values] => Array
                        (
                            [0] => PHP Client Side
                            [1] => Fast development cycles
                        )

                )

            [2] => SolrDocumentField Object
                (
                    [name] => cat
                    [boost] => 0
                    [values] => Array
                        (
                            [0] => Software
                            [1] => Custom Search
                            [2] => Information Technology
                        )

                )

        )

)

SolrDocument::unserialize

Custom serialization of SolrDocument objects

说明

public void SolrDocument::unserialize ( string $serialized )

Custom serialization of SolrDocument objects

参数

serialized
An XML representation of the document.

返回值

None.

SolrDocument::__unset

Removes a field from the document

说明

public bool SolrDocument::__unset ( string $fieldName )

Removes a field from the document when the field is access as an object property.

参数

fieldName
The name of the field.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

SolrDocument::valid

Checks if the current position internally is still valid

说明

public bool SolrDocument::valid ( void )

Checks if the current position internally is still valid. It is used during foreach operations.

参数

此函数没有参数。

返回值

Returns TRUE on success and FALSE if the current position is no longer valid.

简介

This represents a field in a Solr document. All its properties are read-only.

类摘要

SolrDocumentField

final class SolrDocumentField {

/* 属性 */

public readonly string $name ;

public readonly float $boost ;

public readonly array $values ;

/* 方法 */

public __construct ( void )

public void __destruct ( void )

}

属性

name
The name of the field.

boost
The boost value for the field

values
An array of values for this field

SolrDocumentField::__construct

Constructor

说明

public SolrDocumentField::__construct ( void )

Constructor.

参数

此函数没有参数。

返回值

None.

SolrDocumentField::__destruct

Destructor

说明

public void SolrDocumentField::__destruct ( void )

Destructor.

参数

此函数没有参数。

返回值

None.

简介

This is an object whose properties can also by accessed using the array syntax. All its properties are read-only.

类摘要

SolrObject

final class SolrObject implements ArrayAccess {

/* 方法 */

public __construct ( void )

public void __destruct ( void )

public array getPropertyNames ( void )

public bool offsetExists ( string $property_name )

public mixed offsetGet ( string $property_name )

public void offsetSet ( string $property_name , string $property_value )

public void offsetUnset ( string $property_name )

}

SolrObject::__construct

Creates Solr object

说明

public SolrObject::__construct ( void )

Creates Solr object.

参数

此函数没有参数。

返回值

None

范例

示例 #1 SolrObject::__construct example

<?php
/* ... */
?>

以上例程的输出类似于:

...

参见

  • Classname::Method

SolrObject::__destruct

Destructor

说明

public void SolrObject::__destruct ( void )

The destructor

参数

此函数没有参数。

返回值

None.

SolrObject::getPropertyNames

Returns an array of all the names of the properties

说明

public array SolrObject::getPropertyNames ( void )

Returns an array of all the names of the properties

参数

此函数没有参数。

返回值

Returns an array.

SolrObject::offsetExists

Checks if the property exists

说明

public bool SolrObject::offsetExists ( string $property_name )

Checks if the property exists. This is used when the object is treated as an array.

参数

property_name
The name of the property.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

SolrObject::offsetGet

Used to retrieve a property

说明

public mixed SolrObject::offsetGet ( string $property_name )

Used to get the value of a property. This is used when the object is treated as an array.

参数

property_name
Name of the property.

返回值

Returns the property value.

SolrObject::offsetSet

Sets the value for a property

说明

public void SolrObject::offsetSet ( string $property_name , string $property_value )

Sets the value for a property. This is used when the object is treated as an array. This object is read-only. This should never be attempted.

参数

property_name
The name of the property.

property_value
The new value.

返回值

None.

SolrObject::offsetUnset

Unsets the value for the property

说明

public void SolrObject::offsetUnset ( string $property_name )

Unsets the value for the property. This is used when the object is treated as an array. This object is read-only. This should never be attempted.

参数

property_name
The name of the property.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

范例

示例 #1 SolrObject::offsetUnset example

<?php
/* ... */
?>

以上例程的输出类似于:

...

参见

  • Classname::Method

简介

Used to send requests to a Solr server. Currently, cloning and serialization of SolrClient instances is not supported.

类摘要

SolrClient

final class SolrClient {

/* 常量 */

const integer SolrClient::SEARCH_SERVLET_TYPE = 1 ;

const integer SolrClient::UPDATE_SERVLET_TYPE = 2 ;

const integer SolrClient::THREADS_SERVLET_TYPE = 4 ;

const integer SolrClient::PING_SERVLET_TYPE = 8 ;

const integer SolrClient::TERMS_SERVLET_TYPE = 16 ;

const integer SolrClient::SYSTEM_SERVLET_TYPE = 32 ;

const string SolrClient::DEFAULT_SEARCH_SERVLET = select ;

const string SolrClient::DEFAULT_UPDATE_SERVLET = update ;

const string SolrClient::DEFAULT_THREADS_SERVLET = admin/threads ;

const string SolrClient::DEFAULT_PING_SERVLET = admin/ping ;

const string SolrClient::DEFAULT_TERMS_SERVLET = terms ;

const string SolrClient::DEFAULT_SYSTEM_SERVLET = admin/system ;

/* 方法 */

public SolrUpdateResponse addDocument ( SolrInputDocument $doc [, bool $overwrite = TRUE [, int $commitWithin = 0 ]] )

public void addDocuments ( array $docs [, bool $overwrite = TRUE [, int $commitWithin = 0 ]] )

public SolrUpdateResponse commit ([ bool $softCommit = FALSE [, bool $waitSearcher = TRUE [, bool $expungeDeletes = FALSE ]]] )

public __construct ( array $clientOptions )

public SolrUpdateResponse deleteById ( string $id )

public SolrUpdateResponse deleteByIds ( array $ids )

public SolrUpdateResponse deleteByQueries ( array $queries )

public SolrUpdateResponse deleteByQuery ( string $query )

public void __destruct ( void )

public SolrQueryResponse getById ( string $id )

public SolrQueryResponse getByIds ( array $ids )

public string getDebug ( void )

public array getOptions ( void )

public SolrUpdateResponse optimize ([ int $maxSegments = 1 [, bool $softCommit = TRUE [, bool $waitSearcher = TRUE ]]] )

public SolrPingResponse ping ( void )

public SolrQueryResponse query ( SolrParams $query )

public SolrUpdateResponse request ( string $raw_request )

public SolrUpdateResponse rollback ( void )

public void setResponseWriter ( string $responseWriter )

public bool setServlet ( int $type , string $value )

public void system ( void )

public void threads ( void )

}

预定义常量

SolrClient::SEARCH_SERVLET_TYPE
Used when updating the search servlet.

SolrClient::UPDATE_SERVLET_TYPE
Used when updating the update servlet.

SolrClient::THREADS_SERVLET_TYPE
Used when updating the threads servlet.

SolrClient::PING_SERVLET_TYPE
Used when updating the ping servlet.

SolrClient::TERMS_SERVLET_TYPE
Used when updating the terms servlet.

SolrClient::SYSTEM_SERVLET_TYPE
Used when retrieving system information from the system servlet.

SolrClient::DEFAULT_SEARCH_SERVLET
This is the initial value for the search servlet.

SolrClient::DEFAULT_UPDATE_SERVLET
This is the initial value for the update servlet.

SolrClient::DEFAULT_THREADS_SERVLET
This is the initial value for the threads servlet.

SolrClient::DEFAULT_PING_SERVLET
This is the initial value for the ping servlet.

SolrClient::DEFAULT_TERMS_SERVLET
This is the initial value for the terms servlet used for the TermsComponent

SolrClient::DEFAULT_SYSTEM_SERVLET
This is the initial value for the system servlet used to obtain Solr Server information

SolrClient::addDocument

Adds a document to the index

说明

public SolrUpdateResponse SolrClient::addDocument ( SolrInputDocument $doc [, bool $overwrite = TRUE [, int $commitWithin = 0 ]] )

This method adds a document to the index.

参数

doc
The SolrInputDocument instance.

overwrite
Whether to overwrite existing document or not. If FALSE there will be duplicates (several documents with the same ID).

Warning PECL Solr < 2.0 $allowDups was used instead of $overwrite, which does the same functionality with exact opposite bool flag.

$allowDups = false is the same as $overwrite = true

commitWithin
Number of milliseconds within which to auto commit this document. Available since Solr 1.4 . Default (0) means disabled.

When this value specified, it leaves the control of when to do the commit to Solr itself, optimizing number of commits to a minimum while still fulfilling the update latency requirements, and Solr will automatically do a commit when the oldest add in the buffer is due.

返回值

Returns a SolrUpdateResponse object or throws an Exception on failure.

错误/异常

Throws SolrClientException if the client had failed, or there was a connection issue.

Throws SolrServerException if the Solr Server had failed to process the request.

范例

示例 #1 SolrClient::addDocument example

<?php

$options = array
(
    'hostname' => SOLR_SERVER_HOSTNAME,
    'login'    => SOLR_SERVER_USERNAME,
    'password' => SOLR_SERVER_PASSWORD,
    'port'     => SOLR_SERVER_PORT,
);

$client = new SolrClient($options);

$doc = new SolrInputDocument();

$doc->addField('id', 334455);
$doc->addField('cat', 'Software');
$doc->addField('cat', 'Lucene');

$updateResponse = $client->addDocument($doc);

// you will have to commit changes to be written if you didn't use $commitWithin
$client->commit();

print_r($updateResponse->getResponse());

?>

以上例程的输出类似于:

SolrObject Object
(
    [responseHeader] => SolrObject Object
        (
            [status] => 0
            [QTime] => 1
        )

)

示例 #2 SolrClient::addDocument example 2

<?php

$options = array
(
    'hostname' => SOLR_SERVER_HOSTNAME,
    'login'    => SOLR_SERVER_USERNAME,
    'password' => SOLR_SERVER_PASSWORD,
    'port'     => SOLR_SERVER_PORT,
);

$client = new SolrClient($options);

$doc = new SolrInputDocument();

$doc->addField('id', 334455);
$doc->addField('cat', 'Software');
$doc->addField('cat', 'Lucene');

// No need to call commit() because $commitWithin is passed, so Solr Server will auto commit within 10 seconds
$updateResponse = $client->addDocument($doc, false, 10000);

print_r($updateResponse->getResponse());

?>

以上例程的输出类似于:

SolrObject Object
(
    [responseHeader] => SolrObject Object
        (
            [status] => 0
            [QTime] => 1
        )

)

参见

  • SolrClient::addDocuments
  • SolrClient::commit

SolrClient::addDocuments

Adds a collection of SolrInputDocument instances to the index

说明

public void SolrClient::addDocuments ( array $docs [, bool $overwrite = TRUE [, int $commitWithin = 0 ]] )

Adds a collection of documents to the index.

参数

docs
An array containing the collection of SolrInputDocument instances. This array must be an actual variable.

overwrite
Whether to overwrite existing documents or not. If FALSE there will be duplicates (several documents with the same ID).

Warning PECL Solr < 2.0 $allowDups was used instead of $overwrite, which does the same functionality with exact opposite bool flag.

$allowDups = false is the same as $overwrite = true

commitWithin
Number of milliseconds within which to auto commit this document. Available since Solr 1.4 . Default (0) means disabled.

When this value specified, it leaves the control of when to do the commit to Solr itself, optimizing number of commits to a minimum while still fulfilling the update latency requirements, and Solr will automatically do a commit when the oldest add in the buffer is due.

返回值

Returns a SolrUpdateResponse object or throws an exception on failure.

错误/异常

Throws SolrClientException if the client had failed, or there was a connection issue.

Throws SolrServerException if the Solr Server had failed to process the request.

范例

示例 #1 SolrClient::addDocuments example

<?php

$options = array
(
    'hostname' => SOLR_SERVER_HOSTNAME,
    'login'    => SOLR_SERVER_USERNAME,
    'password' => SOLR_SERVER_PASSWORD,
    'port'     => SOLR_SERVER_PORT,
);

$client = new SolrClient($options);

$doc = new SolrInputDocument();

$doc->addField('id', 334455);
$doc->addField('cat', 'Software');
$doc->addField('cat', 'Lucene');

$doc2 = clone $doc;

$doc2->deleteField('id');
$doc2->addField('id', 334456);

$docs = array($doc, $doc2);

$updateResponse = $client->addDocuments($docs);

// no changes will be written to disk unless $commitWithin is passed or SolrClient::commit is called

print_r($updateResponse->getResponse());

?>

以上例程的输出类似于:

SolrObject Object
(
    [responseHeader] => SolrObject Object
        (
            [status] => 0
            [QTime] => 2
        )

)

参见

  • SolrClient::addDocument
  • SolrClient::commit

SolrClient::commit

Finalizes all add/deletes made to the index

说明

public SolrUpdateResponse SolrClient::commit ([ bool $softCommit = FALSE [, bool $waitSearcher = TRUE [, bool $expungeDeletes = FALSE ]]] )

This method finalizes all add/deletes made to the index.

参数

softCommit
This will refresh the 'view' of the index in a more performant manner, but without "on-disk" guarantees. (Solr4.0+)

A soft commit is much faster since it only makes index changes visible and does not fsync index files or write a new index descriptor. If the JVM crashes or there is a loss of power, changes that occurred after the last hard commit will be lost. Search collections that have near-real-time requirements (that want index changes to be quickly visible to searches) will want to soft commit often but hard commit less frequently.

waitSearcher
block until a new searcher is opened and registered as the main query searcher, making the changes visible.

expungeDeletes
Merge segments with deletes away. (Solr1.4+)

返回值

Returns a SolrUpdateResponse object on success or throws an exception on failure.

错误/异常

Throws SolrClientException if the client had failed, or there was a connection issue.

Throws SolrServerException if the Solr Server had failed to process the request.

更新日志

版本说明
1.1.0, 2.0.0$maxSegments removed
2.0.0bAPI Changed: SolrClient::commit ([ int $maxSegments = 0 [, bool $softCommit = false [, bool $waitSearcher = true[, bool $expungeDeletes = false ]]] )
0.9.2Signature: SolrClient::commit ([ int $maxSegments = 1 [, bool $waitFlush = true [, bool $waitSearcher = true ]]] ). $waitFlush: Block until index changes are flushed to disk.

注释

Warning

PECL Solr >= 2.0 only supports Solr Server >= 4.0

参见

  • SolrClient::optimize
  • SolrClient::rollback

SolrClient::__construct

Constructor for the SolrClient object

说明

public SolrClient::__construct ( array $clientOptions )

Constructor for the SolrClient object

参数

clientOptions
This is an array containing one of the following keys :

- secure          (Boolean value indicating whether or not to connect in secure mode)
 - hostname        (The hostname for the Solr server)
 - port            (The port number)
 - path            (The path to solr)
 - wt              (The name of the response writer e.g. xml, json)
 - login           (The username used for HTTP Authentication, if any)
 - password        (The HTTP Authentication password)
 - proxy_host      (The hostname for the proxy server, if any)
 - proxy_port      (The proxy port)
 - proxy_login     (The proxy username)
 - proxy_password  (The proxy password)
 - timeout         (This is maximum time in seconds allowed for the http data transfer operation. Default is 30 seconds)
 - ssl_cert        (File name to a PEM-formatted file containing the private key + private certificate (concatenated in that order) )
 - ssl_key         (File name to a PEM-formatted private key file only)
 - ssl_keypassword (Password for private key)
 - ssl_cainfo      (Name of file holding one or more CA certificates to verify peer with)
 - ssl_capath      (Name of directory holding multiple CA certificates to verify peer with )
 
 Please note the if the ssl_cert file only contains the private certificate, you have to specify a separate ssl_key file
 
 The ssl_keypassword option is required if the ssl_cert or ssl_key options are set.

错误/异常

Throws SolrIllegalArgumentException on failure.

范例

示例 #1 SolrClient::__construct example

<?php

$options = array
(
    'hostname' => SOLR_SERVER_HOSTNAME,
    'login'    => SOLR_SERVER_USERNAME,
    'password' => SOLR_SERVER_PASSWORD,
    'port'     => SOLR_SERVER_PORT,
    'path'     => SOLR_PATH_TO_SOLR,
    'wt'       => 'xml',
);

$client = new SolrClient($options);

$doc = new SolrInputDocument();

$doc->addField('id', 334455);
$doc->addField('cat', 'Software');
$doc->addField('cat', 'Lucene');

$updateResponse = $client->addDocument($doc);

?>

以上例程的输出类似于:

参见

  • SolrClient::getOptions

SolrClient::deleteById

Delete by Id

说明

public SolrUpdateResponse SolrClient::deleteById ( string $id )

Deletes the document with the specified ID. Where ID is the value of the uniqueKey field declared in the schema

参数

id
The value of the uniqueKey field declared in the schema

返回值

Returns a SolrUpdateResponse on success and throws an exception on failure.

错误/异常

Throws SolrClientException if the client had failed, or there was a connection issue.

Throws SolrServerException if the Solr Server had failed to process the request.

参见

  • SolrClient::deleteByIds
  • SolrClient::deleteByQuery
  • SolrClient::deleteByQueries

SolrClient::deleteByIds

Deletes by Ids

说明

public SolrUpdateResponse SolrClient::deleteByIds ( array $ids )

Deletes a collection of documents with the specified set of ids.

参数

ids
An array of IDs representing the uniqueKey field declared in the schema for each document to be deleted. This must be an actual php variable.

返回值

Returns a SolrUpdateResponse on success and throws an exception on failure.

错误/异常

Throws SolrClientException if the client had failed, or there was a connection issue.

Throws SolrServerException if the Solr Server had failed to process the request.

参见

  • SolrClient::deleteById
  • SolrClient::deleteByQuery
  • SolrClient::deleteByQueries

SolrClient::deleteByQueries

Removes all documents matching any of the queries

说明

public SolrUpdateResponse SolrClient::deleteByQueries ( array $queries )

Removes all documents matching any of the queries

参数

queries
The array of queries. This must be an actual php variable.

返回值

Returns a SolrUpdateResponse on success and throws a SolrClientException on failure.

错误/异常

Throws SolrClientException if the client had failed, or there was a connection issue.

Throws SolrServerException if the Solr Server had failed to process the request.

参见

  • SolrClient::deleteById
  • SolrClient::deleteByIds
  • SolrClient::deleteByQuery

SolrClient::deleteByQuery

Deletes all documents matching the given query

说明

public SolrUpdateResponse SolrClient::deleteByQuery ( string $query )

Deletes all documents matching the given query.

参数

query
The query

返回值

Returns a SolrUpdateResponse on success and throws an exception on failure.

错误/异常

Throws SolrClientException if the client had failed, or there was a connection issue.

Throws SolrServerException if the Solr Server had failed to process the request.

范例

示例 #1 SolrQuery::deleteByQuery example

<?php

$options = array
(
    'hostname' => SOLR_SERVER_HOSTNAME,
    'login'    => SOLR_SERVER_USERNAME,
    'password' => SOLR_SERVER_PASSWORD,
    'port'     => SOLR_SERVER_PORT,
);

$client = new SolrClient($options);

//This will erase the entire index
$client->deleteByQuery("*:*");
$client->commit();

?>

参见

  • SolrClient::deleteById
  • SolrClient::deleteByIds
  • SolrClient::deleteByQueries

SolrClient::__destruct

Destructor for SolrClient

说明

public void SolrClient::__destruct ( void )

Destructor

参数

此函数没有参数。

返回值

Destructor for SolrClient

参见

  • SolrClient::__construct

SolrClient::getById

Get Document By Id. Utilizes Solr Realtime Get (RTG)

说明

public SolrQueryResponse SolrClient::getById ( string $id )

Get Document By Id. Utilizes Solr Realtime Get (RTG).

参数

id
Document ID

返回值

SolrQueryResponse

范例

示例 #1 SolrClient::getById example

<?php

include "bootstrap.php";

$options = array
(
    'hostname' => SOLR_SERVER_HOSTNAME,
    'login'    => SOLR_SERVER_USERNAME,
    'password' => SOLR_SERVER_PASSWORD,
    'port'     => SOLR_SERVER_PORT,
    'path'     => SOLR_SERVER_PATH
);

$client = new SolrClient($options);
$response = $client->getById('GB18030TEST');
print_r($response->getResponse());

?>

以上例程的输出类似于:

SolrObject Object
(
    [doc] => SolrObject Object
        (
            [id] => GB18030TEST
            [name] => Array
                (
                    [0] => Test with some GB18030 encoded characters
                )

            [features] => Array
                (
                    [0] => No accents here
                    [1] => 这是一个功能
                    [2] => This is a feature (translated)
                    [3] => 这份文件是很有光泽
                    [4] => This document is very shiny (translated)
                )

            [price] => Array
                (
                    [0] => 0
                )

            [inStock] => Array
                (
                    [0] => 1
                )

            [_version_] => 1510294336239042560
        )

)

参见

  • SolrClient::getByIds

SolrClient::getByIds

Get Documents by their Ids. Utilizes Solr Realtime Get (RTG)

说明

public SolrQueryResponse SolrClient::getByIds ( array $ids )

Get Documents by their Ids. Utilizes Solr Realtime Get (RTG).

参数

ids
Document ids

返回值

SolrQueryResponse

范例

示例 #1 SolrClient::getByIds example

<?php

include "bootstrap.php";

$options = array
(
    'hostname' => SOLR_SERVER_HOSTNAME,
    'login'    => SOLR_SERVER_USERNAME,
    'password' => SOLR_SERVER_PASSWORD,
    'port'     => SOLR_SERVER_PORT,
    'path'     => SOLR_SERVER_PATH
);

$client = new SolrClient($options);
$response = $client->getByIds(['GB18030TEST', '6H500F0']);

print_r($response->getResponse());

?>

以上例程的输出类似于:

SolrObject Object
(
    [response] => SolrObject Object
        (
            [numFound] => 2
            [start] => 0
            [docs] => Array
                (
                    [0] => SolrObject Object
                        (
                            [id] => GB18030TEST
                            [name] => Array
                                (
                                    [0] => Test with some GB18030 encoded characters
                                )

                            [features] => Array
                                (
                                    [0] => No accents here
                                    [1] => 这是一个功能
                                    [2] => This is a feature (translated)
                                    [3] => 这份文件是很有光泽
                                    [4] => This document is very shiny (translated)
                                )

                            [price] => Array
                                (
                                    [0] => 0
                                )

                            [inStock] => Array
                                (
                                    [0] => 1
                                )

                            [_version_] => 1510294336239042560
                        )

                    [1] => SolrObject Object
                        (
                            [id] => 6H500F0
                            [name] => Array
                                (
                                    [0] => Maxtor DiamondMax 11 - hard drive - 500 GB - SATA-300
                                )

                            [manu] => Array
                                (
                                    [0] => Maxtor Corp.
                                )

                            [manu_id_s] => maxtor
                            [cat] => Array
                                (
                                    [0] => electronics
                                    [1] => hard drive
                                )

                            [features] => Array
                                (
                                    [0] => SATA 3.0Gb/s, NCQ
                                    [1] => 8.5ms seek
                                    [2] => 16MB cache
                                )

                            [price] => Array
                                (
                                    [0] => 350
                                )

                            [popularity] => Array
                                (
                                    [0] => 6
                                )

                            [inStock] => Array
                                (
                                    [0] => 1
                                )

                            [store] => Array
                                (
                                    [0] => 45.17614,-93.87341
                                )

                            [manufacturedate_dt] => 2006-02-13T15:26:37Z
                            [_version_] => 1510294336449806336
                        )

                )

        )

)

参见

  • SolrClient::getById

SolrClient::getDebug

Returns the debug data for the last connection attempt

说明

public string SolrClient::getDebug ( void )

Returns the debug data for the last connection attempt

参数

此函数没有参数。

返回值

Returns a string on success and null if there is nothing to return.

SolrClient::getOptions

Returns the client options set internally

说明

public array SolrClient::getOptions ( void )

Returns the client options set internally. Very useful for debugging. The values returned are readonly and can only be set when the object is instantiated.

参数

此函数没有参数。

返回值

Returns an array containing all the options for the SolrClient object set internally.

参见

  • SolrClient::__construct

SolrClient::optimize

Defragments the index

说明

public SolrUpdateResponse SolrClient::optimize ([ int $maxSegments = 1 [, bool $softCommit = TRUE [, bool $waitSearcher = TRUE ]]] )

Defragments the index for faster search performance.

参数

maxSegments
Optimizes down to at most this number of segments. Since Solr 1.3

softCommit
This will refresh the 'view' of the index in a more performant manner, but without "on-disk" guarantees. (Solr4.0+)

waitSearcher
Block until a new searcher is opened and registered as the main query searcher, making the changes visible.

返回值

Returns a SolrUpdateResponse on success or throws an exception on failure.

错误/异常

Throws SolrClientException if the client had failed, or there was a connection issue.

Throws SolrServerException if the Solr Server had failed to process the request.

注释

Warning

PECL Solr >= 2.0 only supports Solr Server >= 4.0

Prior to PECL Solr 2.0 this method used to accept these arguments "int $maxSegments, bool $waitFlush, bool $waitSearcher".

参见

  • SolrClient::commit
  • SolrClient::rollback

SolrClient::ping

Checks if Solr server is still up

说明

public SolrPingResponse SolrClient::ping ( void )

Checks if the Solr server is still alive. Sends a HEAD request to the Apache Solr server.

参数

此函数没有参数。

返回值

Returns a SolrPingResponse object on success and throws an exception on failure.

错误/异常

Throws SolrClientException if the client had failed, or there was a connection issue.

Throws SolrServerException if the Solr Server had failed to satisfy the request.

范例

示例 #1 SolrClient::ping example

<?php
$options = array
(
    'hostname' => SOLR_SERVER_HOSTNAME,
    'login'    => SOLR_SERVER_USERNAME,
    'password' => SOLR_SERVER_PASSWORD,
    'port'     => SOLR_SERVER_PORT,
);

$client = new SolrClient($options);

$pingresponse = $client->ping();

?>

以上例程的输出类似于:

SolrClient::query

Sends a query to the server

说明

public SolrQueryResponse SolrClient::query ( SolrParams $query )

Sends a query to the server.

参数

query
A SolrParams object. It is recommended to use SolrQuery for advanced queries.

返回值

Returns a SolrQueryResponse object on success and throws an exception on failure.

错误/异常

Throws SolrClientException if the client had failed, or there was a connection issue.

Throws SolrServerException if the Solr Server had failed to satisfy the query.

范例

示例 #1 SolrClient::query example

<?php

$options = array
(
    'hostname' => 'localhost',
    'login'    => 'username',
    'password' => 'password',
    'port'     => '8983',
);

$client = new SolrClient($options);

$query = new SolrQuery();

$query->setQuery('lucene');

$query->setStart(0);

$query->setRows(50);

$query->addField('cat')->addField('features')->addField('id')->addField('timestamp');

$query_response = $client->query($query);

$response = $query_response->getResponse();

print_r($response);

?>

以上例程的输出类似于:

SolrObject Object
(
    [responseHeader] => SolrObject Object
        (
            [status] => 0
            [QTime] => 3
            [params] => SolrObject Object
                (
                    [fl] => cat,features,id,timestamp
                    [indent] => on
                    [start] => 0
                    [q] => lucene
                    [wt] => xml
                    [version] => 2.2
                    [rows] => 50
                )

        )

    [response] => SolrObject Object
        (
            [numFound] => 1
            [start] => 0
            [docs] => Array
                (
                    [0] => SolrObject Object
                        (
                            [id] => SOLR1000
                            [cat] => Array
                                (
                                    [0] => software
                                    [1] => search
                                )

                            [features] => Array
                                (
                                    [0] => Advanced Full-Text Search Capabilities using Lucene
                                    [1] => Optimized for High Volume Web Traffic
                                    [2] => Standards Based Open Interfaces - XML and HTTP
                                    [3] => Comprehensive HTML Administration Interfaces
                                    [4] => Scalability - Efficient Replication to other Solr Search Servers
                                    [5] => Flexible and Adaptable with XML configuration and Schema
                                    [6] => Good unicode support: héllo (hello with an accent over the e)
                                )

                        )

                )

        )

)

SolrClient::request

Sends a raw update request

说明

public SolrUpdateResponse SolrClient::request ( string $raw_request )

Sends a raw XML update request to the server

参数

raw_request
An XML string with the raw request to the server.

返回值

Returns a SolrUpdateResponse on success. Throws an exception on failure.

错误/异常

Throws SolrIllegalArgumentException if raw_request was an empty string

Throws SolrClientException if the client had failed, or there was a connection issue.

Throws SolrServerException if the Solr Server had failed to satisfy the query.

范例

示例 #1 SolrClient::request example

<?php
$options = array
(
    'hostname' => SOLR_SERVER_HOSTNAME,
    'login'    => SOLR_SERVER_USERNAME,
    'password' => SOLR_SERVER_PASSWORD,
    'port'     => SOLR_SERVER_PORT,
);

$client = new SolrClient($options);

$update_response = $client->request("<commit/>");

$response = $update_response->getResponse();

print_r($response);
?>

以上例程的输出类似于:

...

SolrClient::rollback

Rollbacks all add/deletes made to the index since the last commit

说明

public SolrUpdateResponse SolrClient::rollback ( void )

Rollbacks all add/deletes made to the index since the last commit. It neither calls any event listeners nor creates a new searcher.

参数

此函数没有参数。

返回值

Returns a SolrUpdateResponse on success or throws a SolrClientException on failure.

参见

  • SolrClient::commit
  • SolrClient::optimize

SolrClient::setResponseWriter

Sets the response writer used to prepare the response from Solr

说明

public void SolrClient::setResponseWriter ( string $responseWriter )

Sets the response writer used to prepare the response from Solr

参数

responseWriter
One of the following:

  • json
  • phps
  • xml

返回值

没有返回值。

范例

示例 #1 SolrClient::setResponseWriter example

<?php

// This is my custom class for objects
class SolrClass
{
   public $_properties = array();

   public function __get($property_name) {
      
      if (property_exists($this, $property_name)) {
      
          return $this->$property_name;
      
      } else if (isset($_properties[$property_name])) {
      
          return $_properties[$property_name];
      }
      
      return null;
   }
}

$options = array
(
  'hostname' => 'localhost',
  'port' => 8983,
  'path' => '/solr/core1'
);

$client = new SolrClient($options);

$client->setResponseWriter("json");

//$response = $client->ping();

$query = new SolrQuery();

$query->setQuery("*:*");

$query->set("objectClassName", "SolrClass");

$query->set("objectPropertiesStorageMode", 1); // 0 for independent properties, 1 for combined

try
{

$response = $client->query($query);

$resp = $response->getResponse();

print_r($response);

print_r($resp);

} catch (Exception $e) {

print_r($e);

}

?>

SolrClient::setServlet

Changes the specified servlet type to a new value

说明

public bool SolrClient::setServlet ( int $type , string $value )

Changes the specified servlet type to a new value

参数

type
One of the following :

- SolrClient::SEARCH_SERVLET_TYPE
 - SolrClient::UPDATE_SERVLET_TYPE
 - SolrClient::THREADS_SERVLET_TYPE
 - SolrClient::PING_SERVLET_TYPE
 - SolrClient::TERMS_SERVLET_TYPE

value
The new value for the servlet

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

SolrClient::system

Retrieve Solr Server information

说明

public void SolrClient::system ( void )

Retrieve Solr Server information

参数

此函数没有参数。

返回值

Returns a SolrGenericResponse object on success.

错误/异常

Emits SolrClientException if the client failed, or there was a connection issue.

Emits SolrServerException if the Solr Server failed to satisfy the query.

SolrClient::threads

Checks the threads status

说明

public void SolrClient::threads ( void )

Checks the threads status

参数

此函数没有参数。

返回值

Returns a SolrGenericResponse object.

错误/异常

Throws SolrClientException if the client failed, or there was a connection issue.

throws SolrServerException if the Solr Server failed to process the request.

简介

Represents a response from the Solr server.

类摘要

SolrResponse

abstract class SolrResponse {

/* 常量 */

const integer SolrResponse::PARSE_SOLR_OBJ = 0 ;

const integer SolrResponse::PARSE_SOLR_DOC = 1 ;

/* 属性 */

protected integer $http_status ;

protected integer $parser_mode ;

protected bool $success ;

protected string $http_status_message ;

protected string $http_request_url ;

protected string $http_raw_request_headers ;

protected string $http_raw_request ;

protected string $http_raw_response_headers ;

protected string $http_raw_response ;

protected string $http_digested_response ;

/* 方法 */

public string getDigestedResponse ( void )

public int getHttpStatus ( void )

public string getHttpStatusMessage ( void )

public string getRawRequest ( void )

public string getRawRequestHeaders ( void )

public string getRawResponse ( void )

public string getRawResponseHeaders ( void )

public string getRequestUrl ( void )

public SolrObject getResponse ( void )

public bool setParseMode ([ int $parser_mode = 0 ] )

public bool success ( void )

}

属性

http_status
The http status of the response.

parser_mode
Whether to parse the solr documents as SolrObject or SolrDocument instances.

success
Was there an error during the request

http_status_message
Detailed message on http status

http_request_url
The request URL

http_raw_request_headers
A string of raw headers sent during the request.

http_raw_request
The raw request sent to the server

http_raw_response_headers
Response headers from the Solr server.

http_raw_response
The response message from the server.

http_digested_response
The response in PHP serialized format.

预定义常量

SolrResponse Class Constants

SolrResponse::PARSE_SOLR_OBJ
Documents should be parsed as SolrObject instances

SolrResponse::PARSE_SOLR_DOC
Documents should be parsed as SolrDocument instances.

SolrResponse::getDigestedResponse

Returns the XML response as serialized PHP data

说明

public string SolrResponse::getDigestedResponse ( void )

Returns the XML response as serialized PHP data

参数

此函数没有参数。

返回值

Returns the XML response as serialized PHP data

SolrResponse::getHttpStatus

Returns the HTTP status of the response

说明

public int SolrResponse::getHttpStatus ( void )

Returns the HTTP status of the response.

参数

此函数没有参数。

返回值

Returns the HTTP status of the response.

SolrResponse::getHttpStatusMessage

Returns more details on the HTTP status

说明

public string SolrResponse::getHttpStatusMessage ( void )

Returns more details on the HTTP status.

参数

此函数没有参数。

返回值

Returns more details on the HTTP status

SolrResponse::getRawRequest

Returns the raw request sent to the Solr server

说明

public string SolrResponse::getRawRequest ( void )

Returns the raw request sent to the Solr server.

参数

此函数没有参数。

返回值

Returns the raw request sent to the Solr server

SolrResponse::getRawRequestHeaders

Returns the raw request headers sent to the Solr server

说明

public string SolrResponse::getRawRequestHeaders ( void )

Returns the raw request headers sent to the Solr server.

参数

此函数没有参数。

返回值

Returns the raw request headers sent to the Solr server

SolrResponse::getRawResponse

Returns the raw response from the server

说明

public string SolrResponse::getRawResponse ( void )

Returns the raw response from the server.

参数

此函数没有参数。

返回值

Returns the raw response from the server.

SolrResponse::getRawResponseHeaders

Returns the raw response headers from the server

说明

public string SolrResponse::getRawResponseHeaders ( void )

Returns the raw response headers from the server.

参数

此函数没有参数。

返回值

Returns the raw response headers from the server.

SolrResponse::getRequestUrl

Returns the full URL the request was sent to

说明

public string SolrResponse::getRequestUrl ( void )

Returns the full URL the request was sent to.

参数

此函数没有参数。

返回值

Returns the full URL the request was sent to

SolrResponse::getResponse

Returns a SolrObject representing the XML response from the server

说明

public SolrObject SolrResponse::getResponse ( void )

Returns a SolrObject representing the XML response from the server.

参数

此函数没有参数。

返回值

Returns a SolrObject representing the XML response from the server

SolrResponse::setParseMode

Sets the parse mode

说明

public bool SolrResponse::setParseMode ([ int $parser_mode = 0 ] )

Sets the parse mode.

参数

parser_mode
SolrResponse::PARSE_SOLR_DOC parses documents in SolrDocument instances. SolrResponse::PARSE_SOLR_OBJ parses document into SolrObjects.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

SolrResponse::success

Was the request a success

说明

public bool SolrResponse::success ( void )

Used to check if the request to the server was successful.

参数

此函数没有参数。

返回值

Returns TRUE if it was successful and FALSE if it was not.

简介

Represents a response to a query request.

类摘要

SolrQueryResponse

final class SolrQueryResponse extends SolrResponse {

/* 常量 */

const integer SolrQueryResponse::PARSE_SOLR_OBJ = 0 ;

const integer SolrQueryResponse::PARSE_SOLR_DOC = 1 ;

/* 继承的属性 */

const integer SolrResponse::PARSE_SOLR_OBJ = 0 ;

const integer SolrResponse::PARSE_SOLR_DOC = 1 ;

protected integer $http_status ;

protected integer $parser_mode ;

protected bool $success ;

protected string $http_status_message ;

protected string $http_request_url ;

protected string $http_raw_request_headers ;

protected string $http_raw_request ;

protected string $http_raw_response_headers ;

protected string $http_raw_response ;

protected string $http_digested_response ;

/* 方法 */

public __construct ( void )

public void __destruct ( void )

/* 继承的方法 */

public string SolrResponse::getDigestedResponse ( void )

public int SolrResponse::getHttpStatus ( void )

public string SolrResponse::getHttpStatusMessage ( void )

public string SolrResponse::getRawRequest ( void )

public string SolrResponse::getRawRequestHeaders ( void )

public string SolrResponse::getRawResponse ( void )

public string SolrResponse::getRawResponseHeaders ( void )

public string SolrResponse::getRequestUrl ( void )

public SolrObject SolrResponse::getResponse ( void )

public bool SolrResponse::setParseMode ([ int $parser_mode = 0 ] )

public bool SolrResponse::success ( void )

}

预定义常量

SolrQueryResponse Class constants

SolrQueryResponse::PARSE_SOLR_OBJ
Documents should be parsed as SolrObject instances

SolrQueryResponse::PARSE_SOLR_DOC
Documents should be parsed as SolrDocument instances.

SolrQueryResponse::__construct

Constructor

说明

public SolrQueryResponse::__construct ( void )

Constructor

参数

此函数没有参数。

返回值

None

SolrQueryResponse::__destruct

Destructor

说明

public void SolrQueryResponse::__destruct ( void )

Destructor.

参数

此函数没有参数。

返回值

None

简介

Represents a response to an update request.

类摘要

SolrUpdateResponse

final class SolrUpdateResponse extends SolrResponse {

/* 常量 */

const integer SolrUpdateResponse::PARSE_SOLR_OBJ = 0 ;

const integer SolrUpdateResponse::PARSE_SOLR_DOC = 1 ;

/* 继承的属性 */

const integer SolrResponse::PARSE_SOLR_OBJ = 0 ;

const integer SolrResponse::PARSE_SOLR_DOC = 1 ;

protected integer $http_status ;

protected integer $parser_mode ;

protected bool $success ;

protected string $http_status_message ;

protected string $http_request_url ;

protected string $http_raw_request_headers ;

protected string $http_raw_request ;

protected string $http_raw_response_headers ;

protected string $http_raw_response ;

protected string $http_digested_response ;

/* 方法 */

public __construct ( void )

public void __destruct ( void )

/* 继承的方法 */

public string SolrResponse::getDigestedResponse ( void )

public int SolrResponse::getHttpStatus ( void )

public string SolrResponse::getHttpStatusMessage ( void )

public string SolrResponse::getRawRequest ( void )

public string SolrResponse::getRawRequestHeaders ( void )

public string SolrResponse::getRawResponse ( void )

public string SolrResponse::getRawResponseHeaders ( void )

public string SolrResponse::getRequestUrl ( void )

public SolrObject SolrResponse::getResponse ( void )

public bool SolrResponse::setParseMode ([ int $parser_mode = 0 ] )

public bool SolrResponse::success ( void )

}

预定义常量

SolrUpdateResponse Class Constants

SolrUpdateResponse::PARSE_SOLR_OBJ
Documents should be parsed as SolrObject instances

SolrUpdateResponse::PARSE_SOLR_DOC
Documents should be parsed as SolrDocument instances.

SolrUpdateResponse::__construct

Constructor

说明

public SolrUpdateResponse::__construct ( void )

Constructor

参数

此函数没有参数。

返回值

None

SolrUpdateResponse::__destruct

Destructor

说明

public void SolrUpdateResponse::__destruct ( void )

Destructor

参数

此函数没有参数。

返回值

None

简介

Represents a response to a ping request to the server

类摘要

SolrPingResponse

final class SolrPingResponse extends SolrResponse {

/* 常量 */

const integer SolrPingResponse::PARSE_SOLR_OBJ = 0 ;

const integer SolrPingResponse::PARSE_SOLR_DOC = 1 ;

/* 属性 */

/* 方法 */

public __construct ( void )

public void __destruct ( void )

public string getResponse ( void )

/* 继承的方法 */

public string SolrResponse::getDigestedResponse ( void )

public int SolrResponse::getHttpStatus ( void )

public string SolrResponse::getHttpStatusMessage ( void )

public string SolrResponse::getRawRequest ( void )

public string SolrResponse::getRawRequestHeaders ( void )

public string SolrResponse::getRawResponse ( void )

public string SolrResponse::getRawResponseHeaders ( void )

public string SolrResponse::getRequestUrl ( void )

public SolrObject SolrResponse::getResponse ( void )

public bool SolrResponse::setParseMode ([ int $parser_mode = 0 ] )

public bool SolrResponse::success ( void )

}

属性

http_status
The http status of the response.

parser_mode
Whether to parse the solr documents as SolrObject or SolrDocument instances.

success
Was there an error during the request

http_status_message
Detailed message on http status

http_request_url
The request URL

http_raw_request_headers
A string of raw headers sent during the request

http_raw_request
The raw request sent to the server

http_raw_response_headers
Response headers from the Solr server

http_raw_response
The response message from the server

http_digested_response
The response in PHP serialized format.

预定义常量

SolrPingResponse Class Constants

SolrPingResponse::PARSE_SOLR_OBJ
Documents should be parsed as SolrObject instances

SolrPingResponse::PARSE_SOLR_DOC
Documents should be parsed as SolrDocument instances.

SolrPingResponse::__construct

Constructor

说明

public SolrPingResponse::__construct ( void )

Constructor

参数

此函数没有参数。

返回值

None

SolrPingResponse::__destruct

Destructor

说明

public void SolrPingResponse::__destruct ( void )

Destructor

参数

此函数没有参数。

返回值

None

SolrPingResponse::getResponse

Returns the response from the server

说明

public string SolrPingResponse::getResponse ( void )

Returns the response from the server. This should be empty because the request as a HEAD request.

参数

此函数没有参数。

返回值

Returns an empty string.

简介

Represents a response from the solr server.

类摘要

SolrGenericResponse

final class SolrGenericResponse extends SolrResponse {

/* 常量 */

const integer SolrGenericResponse::PARSE_SOLR_OBJ = 0 ;

const integer SolrGenericResponse::PARSE_SOLR_DOC = 1 ;

/* 继承的属性 */

const integer SolrResponse::PARSE_SOLR_OBJ = 0 ;

const integer SolrResponse::PARSE_SOLR_DOC = 1 ;

protected integer $http_status ;

protected integer $parser_mode ;

protected bool $success ;

protected string $http_status_message ;

protected string $http_request_url ;

protected string $http_raw_request_headers ;

protected string $http_raw_request ;

protected string $http_raw_response_headers ;

protected string $http_raw_response ;

protected string $http_digested_response ;

/* 方法 */

public __construct ( void )

public void __destruct ( void )

/* 继承的方法 */

public string SolrResponse::getDigestedResponse ( void )

public int SolrResponse::getHttpStatus ( void )

public string SolrResponse::getHttpStatusMessage ( void )

public string SolrResponse::getRawRequest ( void )

public string SolrResponse::getRawRequestHeaders ( void )

public string SolrResponse::getRawResponse ( void )

public string SolrResponse::getRawResponseHeaders ( void )

public string SolrResponse::getRequestUrl ( void )

public SolrObject SolrResponse::getResponse ( void )

public bool SolrResponse::setParseMode ([ int $parser_mode = 0 ] )

public bool SolrResponse::success ( void )

}

预定义常量

SolrGenericResponse Class constants

SolrGenericResponse::PARSE_SOLR_OBJ
Documents should be parsed as SolrObject instances

SolrGenericResponse::PARSE_SOLR_DOC
Documents should be parsed as SolrDocument instances.

SolrGenericResponse::__construct

Constructor

说明

public SolrGenericResponse::__construct ( void )

Constructor

参数

此函数没有参数。

返回值

None

SolrGenericResponse::__destruct

Destructor

说明

public void SolrGenericResponse::__destruct ( void )

Destructor.

参数

此函数没有参数。

返回值

None

简介

Represents a collection of name-value pairs sent to the Solr server during a request.

类摘要

SolrParams

abstract class SolrParams implements Serializable {

/* 方法 */

final public SolrParams add ( string $name , string $value )

public SolrParams addParam ( string $name , string $value )

final public mixed get ( string $param_name )

final public mixed getParam ([ string $param_name ] )

final public array getParams ( void )

final public array getPreparedParams ( void )

final public string serialize ( void )

final public void set ( string $name , string $value )

public SolrParams setParam ( string $name , string $value )

final public string toString ([ bool $url_encode = FALSE ] )

final public void unserialize ( string $serialized )

}

SolrParams::add

This is an alias for SolrParams::addParam

说明

final public SolrParams SolrParams::add ( string $name , string $value )

This is an alias for SolrParams::addParam

参数

name
The name of the parameter

value
The value of the parameter

返回值

Returns a SolrParams instance on success

SolrParams::addParam

Adds a parameter to the object

说明

public SolrParams SolrParams::addParam ( string $name , string $value )

Adds a parameter to the object. This is used for parameters that can be specified multiple times.

参数

name
Name of parameter

value
Value of parameter

返回值

Returns a SolrParam object on success and FALSE on failure.

SolrParams::get

This is an alias for SolrParams::getParam

说明

final public mixed SolrParams::get ( string $param_name )

This is an alias for SolrParams::getParam

参数

param_name
Then name of the parameter

返回值

Returns an array or string depending on the type of parameter

SolrParams::getParam

Returns a parameter value

说明

final public mixed SolrParams::getParam ([ string $param_name ] )

Returns a parameter with name param_name

参数

param_name
The name of the parameter

返回值

Returns a string or an array depending on the type of the parameter

SolrParams::getParams

Returns an array of non URL-encoded parameters

说明

final public array SolrParams::getParams ( void )

Returns an array of non URL-encoded parameters

参数

此函数没有参数。

返回值

Returns an array of non URL-encoded parameters

SolrParams::getPreparedParams

Returns an array of URL-encoded parameters

说明

final public array SolrParams::getPreparedParams ( void )

Returns an array on URL-encoded parameters

参数

此函数没有参数。

返回值

Returns an array on URL-encoded parameters

SolrParams::serialize

Used for custom serialization

说明

final public string SolrParams::serialize ( void )

Used for custom serialization

参数

此函数没有参数。

返回值

Used for custom serialization

SolrParams::set

An alias of SolrParams::setParam

说明

final public void SolrParams::set ( string $name , string $value )

An alias of SolrParams::setParam

参数

name
Then name of the parameter

value
The parameter value

返回值

Returns an instance of the SolrParams object on success

SolrParams::setParam

Sets the parameter to the specified value

说明

public SolrParams SolrParams::setParam ( string $name , string $value )

Sets the query parameter to the specified value. This is used for parameters that can only be specified once. Subsequent calls with the same parameter name will override the existing value

参数

name
Name of the parameter

value
Value of the parameter

返回值

Returns a SolrParam object on success and FALSE on value.

范例

示例 #1 SolrParams::setParam example

<?php

$param = new SolrParams();

$param->setParam('q', 'solr')->setParam('rows', 2);

?>

以上例程的输出类似于:

SolrParams::toString

Returns all the name-value pair parameters in the object

说明

final public string SolrParams::toString ([ bool $url_encode = FALSE ] )

Returns all the name-value pair parameters in the object

参数

url_encode
Whether to return URL-encoded values

返回值

Returns a string on success and FALSE on failure.

SolrParams::unserialize

Used for custom serialization

说明

final public void SolrParams::unserialize ( string $serialized )

Used for custom serialization

参数

serialized
The serialized representation of the object

返回值

None

简介

Represents a collection of name-value pairs sent to the Solr server during a request.

类摘要

SolrModifiableParams

class SolrModifiableParams extends SolrParams implements Serializable {

/* 方法 */

public __construct ( void )

public void __destruct ( void )

/* 继承的方法 */

final public SolrParams SolrParams::add ( string $name , string $value )

public SolrParams SolrParams::addParam ( string $name , string $value )

final public mixed SolrParams::get ( string $param_name )

final public mixed SolrParams::getParam ([ string $param_name ] )

final public array SolrParams::getParams ( void )

final public array SolrParams::getPreparedParams ( void )

final public string SolrParams::serialize ( void )

final public void SolrParams::set ( string $name , string $value )

public SolrParams SolrParams::setParam ( string $name , string $value )

final public string SolrParams::toString ([ bool $url_encode = FALSE ] )

final public void SolrParams::unserialize ( string $serialized )

}

SolrModifiableParams::__construct

Constructor

说明

public SolrModifiableParams::__construct ( void )

Constructor

参数

此函数没有参数。

返回值

None

SolrModifiableParams::__destruct

Destructor

说明

public void SolrModifiableParams::__destruct ( void )

Destructor

参数

此函数没有参数。

返回值

None

简介

Represents a collection of name-value pairs sent to the Solr server during a request.

类摘要

SolrQuery

class SolrQuery extends SolrModifiableParams implements Serializable {

/* 常量 */

const integer SolrQuery::ORDER_ASC = 0 ;

const integer SolrQuery::ORDER_DESC = 1 ;

const integer SolrQuery::FACET_SORT_INDEX = 0 ;

const integer SolrQuery::FACET_SORT_COUNT = 1 ;

const integer SolrQuery::TERMS_SORT_INDEX = 0 ;

const integer SolrQuery::TERMS_SORT_COUNT = 1 ;

/* 属性 */

/* 方法 */

public SolrQuery addExpandFilterQuery ( string $fq )

public SolrQuery addExpandSortField ( string $field [, string $order ] )

public SolrQuery addFacetDateField ( string $dateField )

public SolrQuery addFacetDateOther ( string $value [, string $field_override ] )

public SolrQuery addFacetField ( string $field )

public SolrQuery addFacetQuery ( string $facetQuery )

public SolrQuery addField ( string $field )

public SolrQuery addFilterQuery ( string $fq )

public SolrQuery addGroupField ( string $value )

public SolrQuery addGroupFunction ( string $value )

public SolrQuery addGroupQuery ( string $value )

public SolrQuery addGroupSortField ( string $field [, int $order ] )

public SolrQuery addHighlightField ( string $field )

public SolrQuery addMltField ( string $field )

public SolrQuery addMltQueryField ( string $field , float $boost )

public SolrQuery addSortField ( string $field [, int $order = SolrQuery::ORDER_DESC ] )

public SolrQuery addStatsFacet ( string $field )

public SolrQuery addStatsField ( string $field )

public SolrQuery collapse ( SolrCollapseFunction $collapseFunction )

public __construct ([ string $q ] )

public void __destruct ( void )

public bool getExpand ( void )

public array getExpandFilterQueries ( void )

public array getExpandQuery ( void )

public int getExpandRows ( void )

public array getExpandSortFields ( void )

public bool getFacet ( void )

public string getFacetDateEnd ([ string $field_override ] )

public array getFacetDateFields ( void )

public string getFacetDateGap ([ string $field_override ] )

public string getFacetDateHardEnd ([ string $field_override ] )

public array getFacetDateOther ([ string $field_override ] )

public string getFacetDateStart ([ string $field_override ] )

public array getFacetFields ( void )

public int getFacetLimit ([ string $field_override ] )

public string getFacetMethod ([ string $field_override ] )

public int getFacetMinCount ([ string $field_override ] )

public bool getFacetMissing ([ string $field_override ] )

public int getFacetOffset ([ string $field_override ] )

public string getFacetPrefix ([ string $field_override ] )

public array getFacetQueries ( void )

public int getFacetSort ([ string $field_override ] )

public array getFields ( void )

public array getFilterQueries ( void )

public bool getGroup ( void )

public int getGroupCachePercent ( void )

public bool getGroupFacet ( void )

public array getGroupFields ( void )

public string getGroupFormat ( void )

public array getGroupFunctions ( void )

public int getGroupLimit ( void )

public bool getGroupMain ( void )

public bool getGroupNGroups ( void )

public int getGroupOffset ( void )

public array getGroupQueries ( void )

public array getGroupSortFields ( void )

public bool getGroupTruncate ( void )

public bool getHighlight ( void )

public string getHighlightAlternateField ([ string $field_override ] )

public array getHighlightFields ( void )

public string getHighlightFormatter ([ string $field_override ] )

public string getHighlightFragmenter ([ string $field_override ] )

public int getHighlightFragsize ([ string $field_override ] )

public bool getHighlightHighlightMultiTerm ( void )

public int getHighlightMaxAlternateFieldLength ([ string $field_override ] )

public int getHighlightMaxAnalyzedChars ( void )

public bool getHighlightMergeContiguous ([ string $field_override ] )

public int getHighlightRegexMaxAnalyzedChars ( void )

public string getHighlightRegexPattern ( void )

public float getHighlightRegexSlop ( void )

public bool getHighlightRequireFieldMatch ( void )

public string getHighlightSimplePost ([ string $field_override ] )

public string getHighlightSimplePre ([ string $field_override ] )

public int getHighlightSnippets ([ string $field_override ] )

public bool getHighlightUsePhraseHighlighter ( void )

public bool getMlt ( void )

public bool getMltBoost ( void )

public int getMltCount ( void )

public array getMltFields ( void )

public int getMltMaxNumQueryTerms ( void )

public int getMltMaxNumTokens ( void )

public int getMltMaxWordLength ( void )

public int getMltMinDocFrequency ( void )

public int getMltMinTermFrequency ( void )

public int getMltMinWordLength ( void )

public array getMltQueryFields ( void )

public string getQuery ( void )

public int getRows ( void )

public array getSortFields ( void )

public int getStart ( void )

public bool getStats ( void )

public array getStatsFacets ( void )

public array getStatsFields ( void )

public bool getTerms ( void )

public string getTermsField ( void )

public bool getTermsIncludeLowerBound ( void )

public bool getTermsIncludeUpperBound ( void )

public int getTermsLimit ( void )

public string getTermsLowerBound ( void )

public int getTermsMaxCount ( void )

public int getTermsMinCount ( void )

public string getTermsPrefix ( void )

public bool getTermsReturnRaw ( void )

public int getTermsSort ( void )

public string getTermsUpperBound ( void )

public int getTimeAllowed ( void )

public SolrQuery removeExpandFilterQuery ( string $fq )

public SolrQuery removeExpandSortField ( string $field )

public SolrQuery removeFacetDateField ( string $field )

public SolrQuery removeFacetDateOther ( string $value [, string $field_override ] )

public SolrQuery removeFacetField ( string $field )

public SolrQuery removeFacetQuery ( string $value )

public SolrQuery removeField ( string $field )

public SolrQuery removeFilterQuery ( string $fq )

public SolrQuery removeHighlightField ( string $field )

public SolrQuery removeMltField ( string $field )

public SolrQuery removeMltQueryField ( string $queryField )

public SolrQuery removeSortField ( string $field )

public SolrQuery removeStatsFacet ( string $value )

public SolrQuery removeStatsField ( string $field )

public SolrQuery setEchoHandler ( bool $flag )

public SolrQuery setEchoParams ( string $type )

public SolrQuery setExpand ( bool $value )

public SolrQuery setExpandQuery ( string $q )

public SolrQuery setExpandRows ( int $value )

public SolrQuery setExplainOther ( string $query )

public SolrQuery setFacet ( bool $flag )

public SolrQuery setFacetDateEnd ( string $value [, string $field_override ] )

public SolrQuery setFacetDateGap ( string $value [, string $field_override ] )

public SolrQuery setFacetDateHardEnd ( bool $value [, string $field_override ] )

public SolrQuery setFacetDateStart ( string $value [, string $field_override ] )

public SolrQuery setFacetEnumCacheMinDefaultFrequency ( int $frequency [, string $field_override ] )

public SolrQuery setFacetLimit ( int $limit [, string $field_override ] )

public SolrQuery setFacetMethod ( string $method [, string $field_override ] )

public SolrQuery setFacetMinCount ( int $mincount [, string $field_override ] )

public SolrQuery setFacetMissing ( bool $flag [, string $field_override ] )

public SolrQuery setFacetOffset ( int $offset [, string $field_override ] )

public SolrQuery setFacetPrefix ( string $prefix [, string $field_override ] )

public SolrQuery setFacetSort ( int $facetSort [, string $field_override ] )

public SolrQuery setGroup ( bool $value )

public SolrQuery setGroupCachePercent ( int $percent )

public SolrQuery setGroupFacet ( bool $value )

public SolrQuery setGroupFormat ( string $value )

public SolrQuery setGroupLimit ( int $value )

public SolrQuery setGroupMain ( string $value )

public SolrQuery setGroupNGroups ( bool $value )

public SolrQuery setGroupOffset ( int $value )

public SolrQuery setGroupTruncate ( bool $value )

public SolrQuery setHighlight ( bool $flag )

public SolrQuery setHighlightAlternateField ( string $field [, string $field_override ] )

public SolrQuery setHighlightFormatter ( string $formatter [, string $field_override ] )

public SolrQuery setHighlightFragmenter ( string $fragmenter [, string $field_override ] )

public SolrQuery setHighlightFragsize ( int $size [, string $field_override ] )

public SolrQuery setHighlightHighlightMultiTerm ( bool $flag )

public SolrQuery setHighlightMaxAlternateFieldLength ( int $fieldLength [, string $field_override ] )

public SolrQuery setHighlightMaxAnalyzedChars ( int $value )

public SolrQuery setHighlightMergeContiguous ( bool $flag [, string $field_override ] )

public SolrQuery setHighlightRegexMaxAnalyzedChars ( int $maxAnalyzedChars )

public SolrQuery setHighlightRegexPattern ( string $value )

public SolrQuery setHighlightRegexSlop ( float $factor )

public SolrQuery setHighlightRequireFieldMatch ( bool $flag )

public SolrQuery setHighlightSimplePost ( string $simplePost [, string $field_override ] )

public SolrQuery setHighlightSimplePre ( string $simplePre [, string $field_override ] )

public SolrQuery setHighlightSnippets ( int $value [, string $field_override ] )

public SolrQuery setHighlightUsePhraseHighlighter ( bool $flag )

public SolrQuery setMlt ( bool $flag )

public SolrQuery setMltBoost ( bool $flag )

public SolrQuery setMltCount ( int $count )

public SolrQuery setMltMaxNumQueryTerms ( int $value )

public SolrQuery setMltMaxNumTokens ( int $value )

public SolrQuery setMltMaxWordLength ( int $maxWordLength )

public SolrQuery setMltMinDocFrequency ( int $minDocFrequency )

public SolrQuery setMltMinTermFrequency ( int $minTermFrequency )

public SolrQuery setMltMinWordLength ( int $minWordLength )

public SolrQuery setOmitHeader ( bool $flag )

public SolrQuery setQuery ( string $query )

public SolrQuery setRows ( int $rows )

public SolrQuery setShowDebugInfo ( bool $flag )

public SolrQuery setStart ( int $start )

public SolrQuery setStats ( bool $flag )

public SolrQuery setTerms ( bool $flag )

public SolrQuery setTermsField ( string $fieldname )

public SolrQuery setTermsIncludeLowerBound ( bool $flag )

public SolrQuery setTermsIncludeUpperBound ( bool $flag )

public SolrQuery setTermsLimit ( int $limit )

public SolrQuery setTermsLowerBound ( string $lowerBound )

public SolrQuery setTermsMaxCount ( int $frequency )

public SolrQuery setTermsMinCount ( int $frequency )

public SolrQuery setTermsPrefix ( string $prefix )

public SolrQuery setTermsReturnRaw ( bool $flag )

public SolrQuery setTermsSort ( int $sortType )

public SolrQuery setTermsUpperBound ( string $upperBound )

public SolrQuery setTimeAllowed ( int $timeAllowed )

/* 继承的方法 */

public SolrModifiableParams::__construct ( void )

public void SolrModifiableParams::__destruct ( void )

}

预定义常量

SolrQuery::ORDER_ASC
Used to specify that the sorting should be in acending order

SolrQuery::ORDER_DESC
Used to specify that the sorting should be in descending order

SolrQuery::FACET_SORT_INDEX
Used to specify that the facet should sort by index

SolrQuery::FACET_SORT_COUNT
Used to specify that the facet should sort by count

SolrQuery::TERMS_SORT_INDEX
Used in the TermsComponent

SolrQuery::TERMS_SORT_COUNT
Used in the TermsComponent

SolrQuery::addExpandFilterQuery

Overrides main filter query, determines which documents to include in the main group

说明

public SolrQuery SolrQuery::addExpandFilterQuery ( string $fq )

Overrides main filter query, determines which documents to include in the main group.

参数

fq

返回值

SolrQuery

参见

  • SolrQuery::setExpand
  • SolrQuery::addExpandSortField
  • SolrQuery::removeExpandSortField
  • SolrQuery::setExpandRows
  • SolrQuery::setExpandQuery
  • SolrQuery::removeExpandFilterQuery

SolrQuery::addExpandSortField

Orders the documents within the expanded groups (expand.sort parameter)

说明

public SolrQuery SolrQuery::addExpandSortField ( string $field [, string $order ] )

Orders the documents within the expanded groups (expand.sort parameter).

参数

field
field name

order
Order ASC/DESC, utilizes SolrQuery::ORDER_* constants.

Default: SolrQuery::ORDER_DESC

返回值

SolrQuery

参见

  • SolrQuery::setExpand
  • SolrQuery::removeExpandSortField
  • SolrQuery::setExpandRows
  • SolrQuery::setExpandQuery
  • SolrQuery::addExpandFilterQuery
  • SolrQuery::removeExpandFilterQuery

SolrQuery::addFacetDateField

Maps to facet.date

说明

public SolrQuery SolrQuery::addFacetDateField ( string $dateField )

This method allows you to specify a field which should be treated as a facet.

It can be used multiple times with different field names to indicate multiple facet fields

参数

dateField
The name of the date field.

返回值

Returns a SolrQuery object.

SolrQuery::addFacetDateOther

Adds another facet.date.other parameter

说明

public SolrQuery SolrQuery::addFacetDateOther ( string $value [, string $field_override ] )

Sets the facet.date.other parameter. Accepts an optional field override

参数

value
The value to use.

field_override
The field name for the override.

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::addFacetField

Adds another field to the facet

说明

public SolrQuery SolrQuery::addFacetField ( string $field )

Adds another field to the facet

参数

field
The name of the field

返回值

Returns the current SolrQuery object, if the return value is used.

范例

示例 #1 SolrQuery::addFacetField example

<?php

$options = array
(
    'hostname' => SOLR_SERVER_HOSTNAME,
    'login'    => SOLR_SERVER_USERNAME,
    'password' => SOLR_SERVER_PASSWORD,
    'port'     => SOLR_SERVER_PORT,
);

$client = new SolrClient($options);

$query = new SolrQuery();

$query->setQuery($query);

$query->addField('price')->addField('color');

$query->setFacet(true);

$query->addFacetField('price')->addFacetField('color');

$query_response = $client->query($query);

$response = $query_response->getResponse();

print_r($response['facet_counts']['facet_fields']);

?>

以上例程的输出类似于:

SolrObject Object
(
    [color] => SolrObject Object
        (
            [blue] => 20
            [green] => 100
        )

)

SolrQuery::addFacetQuery

Adds a facet query

说明

public SolrQuery SolrQuery::addFacetQuery ( string $facetQuery )

Adds a facet query

参数

facetQuery
The facet query

返回值

Returns the current SolrQuery object, if the return value is used.

范例

示例 #1 SolrQuery::addFacetField example

<?php

$options = array
(
        'hostname' => SOLR_SERVER_HOSTNAME,
        'login'    => SOLR_SERVER_USERNAME,
        'password' => SOLR_SERVER_PASSWORD,
        'port'     => SOLR_SERVER_PORT,
);

$client = new SolrClient($options);

$query = new SolrQuery('*:*');

$query->setFacet(true);

$query->addFacetQuery('price:[* TO 500]')->addFacetQuery('price:[500 TO *]');

$query_response = $client->query($query);

$response = $query_response->getResponse();

print_r($response->facet_counts->facet_queries);

?>

以上例程的输出类似于:

SolrObject Object
(
    [price:[* TO 500]] => 14
    [price:[500 TO *]] => 2
)

SolrQuery::addField

Specifies which fields to return in the result

说明

public SolrQuery SolrQuery::addField ( string $field )

This method is used to used to specify a set of fields to return, thereby restricting the amount of data returned in the response.

It should be called multiple time, once for each field name.

参数

field
The name of the field

返回值

Returns the current SolrQuery object

SolrQuery::addFilterQuery

Specifies a filter query

说明

public SolrQuery SolrQuery::addFilterQuery ( string $fq )

Specifies a filter query

参数

fq
The filter query

返回值

Returns the current SolrQuery object.

范例

示例 #1 SolrQuery::addFilterQuery example

<?php

$options = array
(
    'hostname' => SOLR_SERVER_HOSTNAME,
    'login'    => SOLR_SERVER_USERNAME,
    'password' => SOLR_SERVER_PASSWORD,
    'port'     => SOLR_SERVER_PORT,
);

$client = new SolrClient($options);

$query = new SolrQuery();

$query->setQuery('*:*');

$query->addFilterQuery('color:blue,green');

$query_response = $client->query($query);

$response = $query_response->getResponse();

print_r($response['facet_counts']['facet_fields']);

?>

以上例程的输出类似于:

 &fq=color:blue,green

SolrQuery::addGroupField

Add a field to be used to group results

说明

public SolrQuery SolrQuery::addGroupField ( string $value )

The name of the field by which to group results. The field must be single-valued, and either be indexed or a field type that has a value source and works in a function query, such as ExternalFileField. It must also be a string-based field, such as StrField or TextField Uses group.field parameter

参数

value

参见

  • SolrQuery::setGroup
  • SolrQuery::addGroupFunction
  • SolrQuery::addGroupQuery
  • SolrQuery::addGroupSortField
  • SolrQuery::setGroupFacet
  • SolrQuery::setGroupOffset
  • SolrQuery::setGroupLimit
  • SolrQuery::setGroupMain
  • SolrQuery::setGroupNGroups
  • SolrQuery::setGroupTruncate
  • SolrQuery::setGroupFormat
  • SolrQuery::setGroupCachePercent

SolrQuery::addGroupFunction

Allows grouping results based on the unique values of a function query (group.func parameter)

说明

public SolrQuery SolrQuery::addGroupFunction ( string $value )

Adds a group function (group.func parameter) Allows grouping results based on the unique values of a function query.

参数

value

返回值

SolrQuery

参见

  • SolrQuery::setGroup
  • SolrQuery::addGroupField
  • SolrQuery::addGroupQuery
  • SolrQuery::addGroupSortField
  • SolrQuery::setGroupFacet
  • SolrQuery::setGroupOffset
  • SolrQuery::setGroupLimit
  • SolrQuery::setGroupMain
  • SolrQuery::setGroupNGroups
  • SolrQuery::setGroupTruncate
  • SolrQuery::setGroupFormat
  • SolrQuery::setGroupCachePercent

SolrQuery::addGroupQuery

Allows grouping of documents that match the given query

说明

public SolrQuery SolrQuery::addGroupQuery ( string $value )

Allows grouping of documents that match the given query. Adds query to the group.query parameter

参数

value

返回值

SolrQuery

参见

  • SolrQuery::setGroup
  • SolrQuery::addGroupField
  • SolrQuery::addGroupFunction
  • SolrQuery::addGroupSortField
  • SolrQuery::setGroupFacet
  • SolrQuery::setGroupOffset
  • SolrQuery::setGroupLimit
  • SolrQuery::setGroupMain
  • SolrQuery::setGroupNGroups
  • SolrQuery::setGroupTruncate
  • SolrQuery::setGroupFormat
  • SolrQuery::setGroupCachePercent

SolrQuery::addGroupSortField

Add a group sort field (group.sort parameter)

说明

public SolrQuery SolrQuery::addGroupSortField ( string $field [, int $order ] )

Allow sorting group documents, using group sort field (group.sort parameter).

参数

field
Field name

order
Order ASC/DESC, utilizes SolrQuery::ORDER_* constants

返回值

范例

示例 #1 SolrQuery::addGroupSortField example

<?php

$solrQuery = new SolrQuery('*:*');
$solrQuery
    ->setGroup(true)
    ->addGroupSortField('price', SolrQuery::ORDER_ASC);
    
echo $solrQuery; 
?>

以上例程的输出类似于:

q=*:*&group=true&group.sort=price asc

参见

  • SolrQuery::setGroup
  • SolrQuery::addGroupField
  • SolrQuery::addGroupFunction
  • SolrQuery::addGroupQuery
  • SolrQuery::setGroupFacet
  • SolrQuery::setGroupOffset
  • SolrQuery::setGroupLimit
  • SolrQuery::setGroupMain
  • SolrQuery::setGroupNGroups
  • SolrQuery::setGroupTruncate
  • SolrQuery::setGroupFormat
  • SolrQuery::setGroupCachePercent

SolrQuery::addHighlightField

Maps to hl.fl

说明

public SolrQuery SolrQuery::addHighlightField ( string $field )

Maps to hl.fl. This is used to specify that highlighted snippets should be generated for a particular field

参数

field
Name of the field

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::addMltField

Sets a field to use for similarity

说明

public SolrQuery SolrQuery::addMltField ( string $field )

Maps to mlt.fl. It specifies that a field should be used for similarity.

参数

field
The name of the field

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::addMltQueryField

Maps to mlt.qf

说明

public SolrQuery SolrQuery::addMltQueryField ( string $field , float $boost )

Maps to mlt.qf. It is used to specify query fields and their boosts

参数

field
The name of the field

boost
Its boost value

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::addSortField

Used to control how the results should be sorted

说明

public SolrQuery SolrQuery::addSortField ( string $field [, int $order = SolrQuery::ORDER_DESC ] )

Used to control how the results should be sorted.

参数

field
The name of the field

order
The sort direction. This should be either SolrQuery::ORDER_ASC or SolrQuery::ORDER_DESC.

返回值

Returns the current SolrQuery object.

SolrQuery::addStatsFacet

Requests a return of sub results for values within the given facet

说明

public SolrQuery SolrQuery::addStatsFacet ( string $field )

Requests a return of sub results for values within the given facet. Maps to the stats.facet field

参数

field
The name of the field

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::addStatsField

Maps to stats.field parameter

说明

public SolrQuery SolrQuery::addStatsField ( string $field )

Maps to stats.field parameter This methods adds another stats.field parameter.

参数

field
The name of the field

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::collapse

Collapses the result set to a single document per group

说明

public SolrQuery SolrQuery::collapse ( SolrCollapseFunction $collapseFunction )

Collapses the result set to a single document per group before it forwards the result set to the rest of the search components.

So all downstream components (faceting, highlighting, etc...) will work with the collapsed result set.

参数

collapseFunction

返回值

Returns the current SolrQuery object

范例

示例 #1 SolrQuery::collapse example

<?php

include "bootstrap.php";

$options = array
(
        'hostname' => SOLR_SERVER_HOSTNAME,
        'login'    => SOLR_SERVER_USERNAME,
        'password' => SOLR_SERVER_PASSWORD,
        'port'     => SOLR_SERVER_PORT,
        'path'     => SOLR_SERVER_PATH
);

$client = new SolrClient($options);

$query = new SolrQuery('*:*');

$collapseFunction = new SolrCollapseFunction('manu_id_s');

$collapseFunction
->setSize(2)
->setNullPolicy(SolrCollapseFunction::NULLPOLICY_IGNORE);

$query
->collapse($collapseFunction)
->setRows(4);

$queryResponse = $client->query($query);

$response = $queryResponse->getResponse();

print_r($response);

?>

以上例程的输出类似于:

SolrObject Object
(
    [responseHeader] => SolrObject Object
        (
            [status] => 0
            [QTime] => 1
            [params] => SolrObject Object
                (
                    [q] => *:*
                    [indent] => on
                    [fq] => {!collapse field=manu_id_s size=2 nullPolicy=ignore}
                    [rows] => 4
                    [version] => 2.2
                    [wt] => xml
                )

        )

    [response] => SolrObject Object
        (
            [numFound] => 14
            [start] => 0
            [docs] => Array
                (
                    [0] => SolrObject Object
                        (
                            [id] => SP2514N
                            [name] => Array
                                (
                                    [0] => Samsung SpinPoint P120 SP2514N - hard drive - 250 GB - ATA-133
                                )

                            [manu] => Array
                                (
                                    [0] => Samsung Electronics Co. Ltd.
                                )

                            [manu_id_s] => samsung
                            [cat] => Array
                                (
                                    [0] => electronics
                                    [1] => hard drive
                                )

                            [features] => Array
                                (
                                    [0] => 7200RPM, 8MB cache, IDE Ultra ATA-133
                                    [1] => NoiseGuard, SilentSeek technology, Fluid Dynamic Bearing (FDB) motor
                                )

                            [price] => Array
                                (
                                    [0] => 92
                                )

                            [popularity] => Array
                                (
                                    [0] => 6
                                )

                            [inStock] => Array
                                (
                                    [0] => 1
                                )

                            [manufacturedate_dt] => 2006-02-13T15:26:37Z
                            [store] => Array
                                (
                                    [0] => 35.0752,-97.032
                                )

                            [_version_] => 1510294336412057600
                        )

                    [1] => SolrObject Object
                        (
                            [id] => 6H500F0
                            [name] => Array
                                (
                                    [0] => Maxtor DiamondMax 11 - hard drive - 500 GB - SATA-300
                                )

                            [manu] => Array
                                (
                                    [0] => Maxtor Corp.
                                )

                            [manu_id_s] => maxtor
                            [cat] => Array
                                (
                                    [0] => electronics
                                    [1] => hard drive
                                )

                            [features] => Array
                                (
                                    [0] => SATA 3.0Gb/s, NCQ
                                    [1] => 8.5ms seek
                                    [2] => 16MB cache
                                )

                            [price] => Array
                                (
                                    [0] => 350
                                )

                            [popularity] => Array
                                (
                                    [0] => 6
                                )

                            [inStock] => Array
                                (
                                    [0] => 1
                                )

                            [store] => Array
                                (
                                    [0] => 45.17614,-93.87341
                                )

                            [manufacturedate_dt] => 2006-02-13T15:26:37Z
                            [_version_] => 1510294336449806336
                        )

                    [2] => SolrObject Object
                        (
                            [id] => F8V7067-APL-KIT
                            [name] => Array
                                (
                                    [0] => Belkin Mobile Power Cord for iPod w/ Dock
                                )

                            [manu] => Array
                                (
                                    [0] => Belkin
                                )

                            [manu_id_s] => belkin
                            [cat] => Array
                                (
                                    [0] => electronics
                                    [1] => connector
                                )

                            [features] => Array
                                (
                                    [0] => car power adapter, white
                                )

                            [weight] => Array
                                (
                                    [0] => 4
                                )

                            [price] => Array
                                (
                                    [0] => 19.95
                                )

                            [popularity] => Array
                                (
                                    [0] => 1
                                )

                            [inStock] => Array
                                (
                                    [0] => 
                                )

                            [store] => Array
                                (
                                    [0] => 45.18014,-93.87741
                                )

                            [manufacturedate_dt] => 2005-08-01T16:30:25Z
                            [_version_] => 1510294336458194944
                        )

                    [3] => SolrObject Object
                        (
                            [id] => MA147LL/A
                            [name] => Array
                                (
                                    [0] => Apple 60 GB iPod with Video Playback Black
                                )

                            [manu] => Array
                                (
                                    [0] => Apple Computer Inc.
                                )

                            [manu_id_s] => apple
                            [cat] => Array
                                (
                                    [0] => electronics
                                    [1] => music
                                )

                            [features] => Array
                                (
                                    [0] => iTunes, Podcasts, Audiobooks
                                    [1] => Stores up to 15,000 songs, 25,000 photos, or 150 hours of video
                                    [2] => 2.5-inch, 320x240 color TFT LCD display with LED backlight
                                    [3] => Up to 20 hours of battery life
                                    [4] => Plays AAC, MP3, WAV, AIFF, Audible, Apple Lossless, H.264 video
                                    [5] => Notes, Calendar, Phone book, Hold button, Date display, Photo wallet, Built-in games, JPEG photo playback, Upgradeable firmware, USB 2.0 compatibility, Playback speed control, Rechargeable capability, Battery level indication
                                )

                            [includes] => Array
                                (
                                    [0] => earbud headphones, USB cable
                                )

                            [weight] => Array
                                (
                                    [0] => 5.5
                                )

                            [price] => Array
                                (
                                    [0] => 399
                                )

                            [popularity] => Array
                                (
                                    [0] => 10
                                )

                            [inStock] => Array
                                (
                                    [0] => 1
                                )

                            [store] => Array
                                (
                                    [0] => 37.7752,-100.0232
                                )

                            [manufacturedate_dt] => 2005-10-12T08:00:00Z
                            [_version_] => 1510294336562003968
                        )

                )

        )

)

SolrQuery::__construct

Constructor

说明

public SolrQuery::__construct ([ string $q ] )

Constructor.

参数

q
Optional search query

返回值

None

错误/异常

Emits SolrIllegalArgumentException in case of an invalid parameter was passed.

更新日志

版本说明
2.0.0If q was invalid, then a SolrIllegalArgumentException is now thrown. Previously an error was emitted.

SolrQuery::__destruct

Destructor

说明

public void SolrQuery::__destruct ( void )

Destructor

参数

此函数没有参数。

返回值

None.

SolrQuery::getExpand

Returns true if group expanding is enabled

说明

public bool SolrQuery::getExpand ( void )

Returns TRUE if group expanding is enabled

SolrQuery::getExpandFilterQueries

Returns the expand filter queries

说明

public array SolrQuery::getExpandFilterQueries ( void )

Returns the expand filter queries

SolrQuery::getExpandQuery

Returns the expand query expand.q parameter

说明

public array SolrQuery::getExpandQuery ( void )

Returns the expand query expand.q parameter

SolrQuery::getExpandRows

Returns The number of rows to display in each group (expand.rows)

说明

public int SolrQuery::getExpandRows ( void )

Returns The number of rows to display in each group (expand.rows)

SolrQuery::getExpandSortFields

Returns an array of fields

说明

public array SolrQuery::getExpandSortFields ( void )

Returns an array of fields

SolrQuery::getFacet

Returns the value of the facet parameter

说明

public bool SolrQuery::getFacet ( void )

Returns the value of the facet parameter.

参数

此函数没有参数。

返回值

Returns a boolean on success and NULL if not set

SolrQuery::getFacetDateEnd

Returns the value for the facet.date.end parameter

说明

public string SolrQuery::getFacetDateEnd ([ string $field_override ] )

Returns the value for the facet.date.end parameter. This method accepts an optional field override

参数

field_override
The name of the field

返回值

Returns a string on success and NULL if not set

SolrQuery::getFacetDateFields

Returns all the facet.date fields

说明

public array SolrQuery::getFacetDateFields ( void )

Returns all the facet.date fields

参数

此函数没有参数。

返回值

Returns all the facet.date fields as an array or NULL if none was set

SolrQuery::getFacetDateGap

Returns the value of the facet.date.gap parameter

说明

public string SolrQuery::getFacetDateGap ([ string $field_override ] )

Returns the value of the facet.date.gap parameter. It accepts an optional field override

参数

field_override
The name of the field

返回值

Returns a string on success and NULL if not set

SolrQuery::getFacetDateHardEnd

Returns the value of the facet.date.hardend parameter

说明

public string SolrQuery::getFacetDateHardEnd ([ string $field_override ] )

Returns the value of the facet.date.hardend parameter. Accepts an optional field override

参数

field_override
The name of the field

返回值

Returns a string on success and NULL if not set

SolrQuery::getFacetDateOther

Returns the value for the facet.date.other parameter

说明

public array SolrQuery::getFacetDateOther ([ string $field_override ] )

Returns the value for the facet.date.other parameter. This method accepts an optional field override.

参数

field_override
The name of the field

返回值

Returns an array on success and NULL if not set.

SolrQuery::getFacetDateStart

Returns the lower bound for the first date range for all date faceting on this field

说明

public string SolrQuery::getFacetDateStart ([ string $field_override ] )

Returns the lower bound for the first date range for all date faceting on this field. Accepts an optional field override

参数

field_override
The name of the field

返回值

Returns a string on success and NULL if not set

SolrQuery::getFacetFields

Returns all the facet fields

说明

public array SolrQuery::getFacetFields ( void )

Returns all the facet fields

参数

此函数没有参数。

返回值

Returns an array of all the fields and NULL if none was set

SolrQuery::getFacetLimit

Returns the maximum number of constraint counts that should be returned for the facet fields

说明

public int SolrQuery::getFacetLimit ([ string $field_override ] )

Returns the maximum number of constraint counts that should be returned for the facet fields. This method accepts an optional field override

参数

field_override
The name of the field to override for

返回值

Returns an integer on success and NULL if not set

SolrQuery::getFacetMethod

Returns the value of the facet.method parameter

说明

public string SolrQuery::getFacetMethod ([ string $field_override ] )

Returns the value of the facet.method parameter. This accepts an optional field override.

参数

field_override
The name of the field

返回值

Returns a string on success and NULL if not set

SolrQuery::getFacetMinCount

Returns the minimum counts for facet fields should be included in the response

说明

public int SolrQuery::getFacetMinCount ([ string $field_override ] )

Returns the minimum counts for facet fields should be included in the response. It accepts an optional field override

参数

field_override
The name of the field

返回值

Returns an integer on success and NULL if not set

SolrQuery::getFacetMissing

Returns the current state of the facet.missing parameter

说明

public bool SolrQuery::getFacetMissing ([ string $field_override ] )

Returns the current state of the facet.missing parameter. This accepts an optional field override

参数

field_override
The name of the field

返回值

Returns a boolean on success and NULL if not set

SolrQuery::getFacetOffset

Returns an offset into the list of constraints to be used for pagination

说明

public int SolrQuery::getFacetOffset ([ string $field_override ] )

Returns an offset into the list of constraints to be used for pagination. Accepts an optional field override

参数

field_override
The name of the field to override for.

返回值

Returns an integer on success and NULL if not set

SolrQuery::getFacetPrefix

Returns the facet prefix

说明

public string SolrQuery::getFacetPrefix ([ string $field_override ] )

Returns the facet prefix

参数

field_override
The name of the field

返回值

Returns a string on success and NULL if not set.

SolrQuery::getFacetQueries

Returns all the facet queries

说明

public array SolrQuery::getFacetQueries ( void )

Returns all the facet queries

参数

此函数没有参数。

返回值

Returns an array on success and NULL if not set.

SolrQuery::getFacetSort

Returns the facet sort type

说明

public int SolrQuery::getFacetSort ([ string $field_override ] )

Returns an integer (SolrQuery::FACET_SORT_INDEX or SolrQuery::FACET_SORT_COUNT)

参数

field_override
The name of the field

返回值

Returns an integer (SolrQuery::FACET_SORT_INDEX or SolrQuery::FACET_SORT_COUNT) on success or NULL if not set.

SolrQuery::getFields

Returns the list of fields that will be returned in the response

说明

public array SolrQuery::getFields ( void )

Returns the list of fields that will be returned in the response

参数

此函数没有参数。

返回值

Returns an array on success and NULL if not set.

SolrQuery::getFilterQueries

Returns an array of filter queries

说明

public array SolrQuery::getFilterQueries ( void )

Returns an array of filter queries. These are queries that can be used to restrict the super set of documents that can be returned, without influencing score

参数

此函数没有参数。

返回值

Returns an array on success and NULL if not set.

SolrQuery::getGroup

Returns true if grouping is enabled

说明

public bool SolrQuery::getGroup ( void )

Returns true if grouping is enabled

参数

此函数没有参数。

返回值

参见

  • SolrQuery::setGroup

SolrQuery::getGroupCachePercent

Returns group cache percent value

说明

public int SolrQuery::getGroupCachePercent ( void )

Returns group cache percent value

参数

此函数没有参数。

返回值

参见

  • SolrQuery::setGroupCachePercent

SolrQuery::getGroupFacet

Returns the group.facet parameter value

说明

public bool SolrQuery::getGroupFacet ( void )

Returns the group.facet parameter value

参数

此函数没有参数。

返回值

参见

  • SolrQuery::setGroupFacet

SolrQuery::getGroupFields

Returns group fields (group.field parameter values)

说明

public array SolrQuery::getGroupFields ( void )

Returns group fields (group.field parameter values)

参数

此函数没有参数。

返回值

参见

  • SolrQuery::addGroupField

SolrQuery::getGroupFormat

Returns the group.format value

说明

public string SolrQuery::getGroupFormat ( void )

Returns the group.format value

参数

此函数没有参数。

返回值

参见

  • SolrQuery::setGroupFormat

SolrQuery::getGroupFunctions

Returns group functions (group.func parameter values)

说明

public array SolrQuery::getGroupFunctions ( void )

Returns group functions (group.func parameter values)

参数

此函数没有参数。

返回值

参见

  • SolrQuery::addGroupFunction

SolrQuery::getGroupLimit

Returns the group.limit value

说明

public int SolrQuery::getGroupLimit ( void )

Returns the group.limit value

参数

此函数没有参数。

返回值

参见

  • SolrQuery::setGroupLimit

SolrQuery::getGroupMain

Returns the group.main value

说明

public bool SolrQuery::getGroupMain ( void )

Returns the group.main value

参数

此函数没有参数。

返回值

参见

  • SolrQuery::setGroupMain

SolrQuery::getGroupNGroups

Returns the group.ngroups value

说明

public bool SolrQuery::getGroupNGroups ( void )

Returns the group.ngroups value

参数

此函数没有参数。

返回值

参见

  • SolrQuery::setGroupNGroups

SolrQuery::getGroupOffset

Returns the group.offset value

说明

public int SolrQuery::getGroupOffset ( void )

Returns the group.offset value

参数

此函数没有参数。

返回值

参见

  • SolrQuery::setGroupOffset

SolrQuery::getGroupQueries

Returns all the group.query parameter values

说明

public array SolrQuery::getGroupQueries ( void )

Returns all the group.query parameter values

参数

此函数没有参数。

返回值

array

参见

  • SolrQuery::addGroupQuery

SolrQuery::getGroupSortFields

Returns the group.sort value

说明

public array SolrQuery::getGroupSortFields ( void )

Returns the group.sort value

参数

此函数没有参数。

返回值

参见

  • SolrQuery::addGroupSortField

SolrQuery::getGroupTruncate

Returns the group.truncate value

说明

public bool SolrQuery::getGroupTruncate ( void )

Returns the group.truncate value

参数

此函数没有参数。

返回值

参见

  • SolrQuery::setGroupTruncate

SolrQuery::getHighlight

Returns the state of the hl parameter

说明

public bool SolrQuery::getHighlight ( void )

Returns a boolean indicating whether or not to enable highlighted snippets to be generated in the query response.

参数

此函数没有参数。

返回值

Returns a boolean on success and NULL if not set.

SolrQuery::getHighlightAlternateField

Returns the highlight field to use as backup or default

说明

public string SolrQuery::getHighlightAlternateField ([ string $field_override ] )

Returns the highlight field to use as backup or default. It accepts an optional override.

参数

field_override
The name of the field

返回值

Returns a string on success and NULL if not set.

SolrQuery::getHighlightFields

Returns all the fields that Solr should generate highlighted snippets for

说明

public array SolrQuery::getHighlightFields ( void )

Returns all the fields that Solr should generate highlighted snippets for

参数

此函数没有参数。

返回值

Returns an array on success and NULL if not set.

SolrQuery::getHighlightFormatter

Returns the formatter for the highlighted output

说明

public string SolrQuery::getHighlightFormatter ([ string $field_override ] )

Returns the formatter for the highlighted output

参数

field_override
The name of the field

返回值

Returns a string on success and NULL if not set.

SolrQuery::getHighlightFragmenter

Returns the text snippet generator for highlighted text

说明

public string SolrQuery::getHighlightFragmenter ([ string $field_override ] )

Returns the text snippet generator for highlighted text. Accepts an optional field override.

参数

field_override
The name of the field

返回值

Returns a string on success and NULL if not set.

SolrQuery::getHighlightFragsize

Returns the number of characters of fragments to consider for highlighting

说明

public int SolrQuery::getHighlightFragsize ([ string $field_override ] )

Returns the number of characters of fragments to consider for highlighting. Zero implies no fragmenting. The entire field should be used.

参数

field_override
The name of the field

返回值

Returns an integer on success or NULL if not set.

SolrQuery::getHighlightHighlightMultiTerm

Returns whether or not to enable highlighting for range/wildcard/fuzzy/prefix queries

说明

public bool SolrQuery::getHighlightHighlightMultiTerm ( void )

Returns whether or not to enable highlighting for range/wildcard/fuzzy/prefix queries

参数

此函数没有参数。

返回值

Returns a boolean on success and NULL if not set.

SolrQuery::getHighlightMaxAlternateFieldLength

Returns the maximum number of characters of the field to return

说明

public int SolrQuery::getHighlightMaxAlternateFieldLength ([ string $field_override ] )

Returns the maximum number of characters of the field to return

参数

field_override
The name of the field

返回值

Returns an integer on success and NULL if not set.

SolrQuery::getHighlightMaxAnalyzedChars

Returns the maximum number of characters into a document to look for suitable snippets

说明

public int SolrQuery::getHighlightMaxAnalyzedChars ( void )

Returns the maximum number of characters into a document to look for suitable snippets

参数

此函数没有参数。

返回值

Returns an integer on success and NULL if not set.

SolrQuery::getHighlightMergeContiguous

Returns whether or not the collapse contiguous fragments into a single fragment

说明

public bool SolrQuery::getHighlightMergeContiguous ([ string $field_override ] )

Returns whether or not the collapse contiguous fragments into a single fragment. Accepts an optional field override.

参数

field_override
The name of the field

返回值

Returns a boolean on success and NULL if not set.

SolrQuery::getHighlightRegexMaxAnalyzedChars

Returns the maximum number of characters from a field when using the regex fragmenter

说明

public int SolrQuery::getHighlightRegexMaxAnalyzedChars ( void )

Returns the maximum number of characters from a field when using the regex fragmenter

参数

此函数没有参数。

返回值

Returns an integer on success and NULL if not set.

SolrQuery::getHighlightRegexPattern

Returns the regular expression for fragmenting

说明

public string SolrQuery::getHighlightRegexPattern ( void )

Returns the regular expression used for fragmenting

参数

此函数没有参数。

返回值

Returns a string on success and NULL if not set.

SolrQuery::getHighlightRegexSlop

Returns the deviation factor from the ideal fragment size

说明

public float SolrQuery::getHighlightRegexSlop ( void )

Returns the factor by which the regex fragmenter can deviate from the ideal fragment size to accomodate the regular expression

参数

此函数没有参数。

返回值

Returns a double on success and NULL if not set.

SolrQuery::getHighlightRequireFieldMatch

Returns if a field will only be highlighted if the query matched in this particular field

说明

public bool SolrQuery::getHighlightRequireFieldMatch ( void )

Returns if a field will only be highlighted if the query matched in this particular field.

参数

此函数没有参数。

返回值

Returns a boolean on success and NULL if not set.

SolrQuery::getHighlightSimplePost

Returns the text which appears after a highlighted term

说明

public string SolrQuery::getHighlightSimplePost ([ string $field_override ] )

Returns the text which appears after a highlighted term. Accepts an optional field override

参数

field_override
The name of the field

返回值

Returns a string on success and NULL if not set.

SolrQuery::getHighlightSimplePre

Returns the text which appears before a highlighted term

说明

public string SolrQuery::getHighlightSimplePre ([ string $field_override ] )

Returns the text which appears before a highlighted term. Accepts an optional field override

参数

field_override
The name of the field

返回值

Returns a string on success and NULL if not set.

SolrQuery::getHighlightSnippets

Returns the maximum number of highlighted snippets to generate per field

说明

public int SolrQuery::getHighlightSnippets ([ string $field_override ] )

Returns the maximum number of highlighted snippets to generate per field. Accepts an optional field override

参数

field_override
The name of the field

返回值

Returns an integer on success and NULL if not set.

SolrQuery::getHighlightUsePhraseHighlighter

Returns the state of the hl.usePhraseHighlighter parameter

说明

public bool SolrQuery::getHighlightUsePhraseHighlighter ( void )

Returns whether or not to use SpanScorer to highlight phrase terms only when they appear within the query phrase in the document.

参数

此函数没有参数。

返回值

Returns a boolean on success and NULL if not set.

SolrQuery::getMlt

Returns whether or not MoreLikeThis results should be enabled

说明

public bool SolrQuery::getMlt ( void )

Returns whether or not MoreLikeThis results should be enabled

参数

此函数没有参数。

返回值

Returns a boolean on success and NULL if not set.

SolrQuery::getMltBoost

Returns whether or not the query will be boosted by the interesting term relevance

说明

public bool SolrQuery::getMltBoost ( void )

Returns whether or not the query will be boosted by the interesting term relevance

参数

此函数没有参数。

返回值

Returns a boolean on success and NULL if not set.

SolrQuery::getMltCount

Returns the number of similar documents to return for each result

说明

public int SolrQuery::getMltCount ( void )

Returns the number of similar documents to return for each result

参数

此函数没有参数。

返回值

Returns an integer on success and NULL if not set.

SolrQuery::getMltFields

Returns all the fields to use for similarity

说明

public array SolrQuery::getMltFields ( void )

Returns all the fields to use for similarity

参数

此函数没有参数。

返回值

Returns an array on success and NULL if not set.

SolrQuery::getMltMaxNumQueryTerms

Returns the maximum number of query terms that will be included in any generated query

说明

public int SolrQuery::getMltMaxNumQueryTerms ( void )

Returns the maximum number of query terms that will be included in any generated query

参数

此函数没有参数。

返回值

Returns an integer on success and NULL if not set.

SolrQuery::getMltMaxNumTokens

Returns the maximum number of tokens to parse in each document field that is not stored with TermVector support

说明

public int SolrQuery::getMltMaxNumTokens ( void )

Returns the maximum number of tokens to parse in each document field that is not stored with TermVector support

参数

此函数没有参数。

返回值

Returns an integer on success and NULL if not set.

SolrQuery::getMltMaxWordLength

Returns the maximum word length above which words will be ignored

说明

public int SolrQuery::getMltMaxWordLength ( void )

Returns the maximum word length above which words will be ignored

参数

此函数没有参数。

返回值

Returns an integer on success and NULL if not set.

SolrQuery::getMltMinDocFrequency

Returns the treshold frequency at which words will be ignored which do not occur in at least this many docs

说明

public int SolrQuery::getMltMinDocFrequency ( void )

Returns the treshold frequency at which words will be ignored which do not occur in at least this many docs

参数

此函数没有参数。

返回值

Returns an integer on success and NULL if not set.

SolrQuery::getMltMinTermFrequency

Returns the frequency below which terms will be ignored in the source document

说明

public int SolrQuery::getMltMinTermFrequency ( void )

Returns the frequency below which terms will be ignored in the source document

参数

此函数没有参数。

返回值

Returns an integer on success and NULL if not set.

SolrQuery::getMltMinWordLength

Returns the minimum word length below which words will be ignored

说明

public int SolrQuery::getMltMinWordLength ( void )

Returns the minimum word length below which words will be ignored

参数

此函数没有参数。

返回值

Returns an integer on success and NULL if not set.

SolrQuery::getMltQueryFields

Returns the query fields and their boosts

说明

public array SolrQuery::getMltQueryFields ( void )

Returns the query fields and their boosts

参数

此函数没有参数。

返回值

Returns an array on success and NULL if not set.

SolrQuery::getQuery

Returns the main query

说明

public string SolrQuery::getQuery ( void )

Returns the main search query

参数

此函数没有参数。

返回值

Returns a string on success and NULL if not set.

SolrQuery::getRows

Returns the maximum number of documents

说明

public int SolrQuery::getRows ( void )

Returns the maximum number of documents from the complete result set to return to the client for every request

参数

此函数没有参数。

返回值

Returns an integer on success and NULL if not set.

SolrQuery::getSortFields

Returns all the sort fields

说明

public array SolrQuery::getSortFields ( void )

Returns all the sort fields

参数

此函数没有参数。

返回值

Returns an array on success and NULL if none of the parameters was set.

SolrQuery::getStart

Returns the offset in the complete result set

说明

public int SolrQuery::getStart ( void )

Returns the offset in the complete result set for the queries where the set of returned documents should begin.

参数

此函数没有参数。

返回值

Returns an integer on success and NULL if not set.

SolrQuery::getStats

Returns whether or not stats is enabled

说明

public bool SolrQuery::getStats ( void )

Returns whether or not stats is enabled

参数

此函数没有参数。

返回值

Returns a boolean on success and NULL if not set.

SolrQuery::getStatsFacets

Returns all the stats facets that were set

说明

public array SolrQuery::getStatsFacets ( void )

Returns all the stats facets that were set

参数

此函数没有参数。

返回值

Returns an array on success and NULL if not set.

SolrQuery::getStatsFields

Returns all the statistics fields

说明

public array SolrQuery::getStatsFields ( void )

Returns all the statistics fields

参数

此函数没有参数。

返回值

Returns an array on success and NULL if not set.

SolrQuery::getTerms

Returns whether or not the TermsComponent is enabled

说明

public bool SolrQuery::getTerms ( void )

Returns whether or not the TermsComponent is enabled

参数

此函数没有参数。

返回值

Returns a boolean on success and NULL if not set.

SolrQuery::getTermsField

Returns the field from which the terms are retrieved

说明

public string SolrQuery::getTermsField ( void )

Returns the field from which the terms are retrieved

参数

此函数没有参数。

返回值

Returns a string on success and NULL if not set.

SolrQuery::getTermsIncludeLowerBound

Returns whether or not to include the lower bound in the result set

说明

public bool SolrQuery::getTermsIncludeLowerBound ( void )

Returns whether or not to include the lower bound in the result set

参数

此函数没有参数。

返回值

Returns a boolean on success and NULL if not set.

SolrQuery::getTermsIncludeUpperBound

Returns whether or not to include the upper bound term in the result set

说明

public bool SolrQuery::getTermsIncludeUpperBound ( void )

Returns whether or not to include the upper bound term in the result set

参数

此函数没有参数。

返回值

Returns a boolean on success and NULL if not set.

SolrQuery::getTermsLimit

Returns the maximum number of terms Solr should return

说明

public int SolrQuery::getTermsLimit ( void )

Returns the maximum number of terms Solr should return

参数

此函数没有参数。

返回值

Returns an integer on success and NULL if not set.

SolrQuery::getTermsLowerBound

Returns the term to start at

说明

public string SolrQuery::getTermsLowerBound ( void )

Returns the term to start at

参数

此函数没有参数。

返回值

Returns a string on success and NULL if not set.

SolrQuery::getTermsMaxCount

Returns the maximum document frequency

说明

public int SolrQuery::getTermsMaxCount ( void )

Returns the maximum document frequency

参数

此函数没有参数。

返回值

Returns an integer on success and NULL if not set.

SolrQuery::getTermsMinCount

Returns the minimum document frequency to return in order to be included

说明

public int SolrQuery::getTermsMinCount ( void )

Returns the minimum document frequency to return in order to be included

参数

此函数没有参数。

返回值

Returns an integer on success and NULL if not set.

SolrQuery::getTermsPrefix

Returns the term prefix

说明

public string SolrQuery::getTermsPrefix ( void )

Returns the prefix to which matching terms must be restricted. This will restrict matches to only terms that start with the prefix

参数

此函数没有参数。

返回值

Returns a string on success and NULL if not set.

SolrQuery::getTermsReturnRaw

Whether or not to return raw characters

说明

public bool SolrQuery::getTermsReturnRaw ( void )

Returns a boolean indicating whether or not to return the raw characters of the indexed term, regardless of if it is human readable

参数

此函数没有参数。

返回值

Returns a boolean on success and NULL if not set.

SolrQuery::getTermsSort

Returns an integer indicating how terms are sorted

说明

public int SolrQuery::getTermsSort ( void )

SolrQuery::TERMS_SORT_INDEX indicates that the terms are returned by index order. SolrQuery::TERMS_SORT_COUNT implies that the terms are sorted by term frequency (highest count first)

参数

此函数没有参数。

返回值

Returns an integer on success and NULL if not set.

SolrQuery::getTermsUpperBound

Returns the term to stop at

说明

public string SolrQuery::getTermsUpperBound ( void )

Returns the term to stop at

参数

此函数没有参数。

返回值

Returns a string on success and NULL if not set.

SolrQuery::getTimeAllowed

Returns the time in milliseconds allowed for the query to finish

说明

public int SolrQuery::getTimeAllowed ( void )

Returns the time in milliseconds allowed for the query to finish.

参数

此函数没有参数。

返回值

Returns and integer on success and NULL if it is not set.

SolrQuery::removeExpandFilterQuery

Removes an expand filter query

说明

public SolrQuery SolrQuery::removeExpandFilterQuery ( string $fq )

Removes an expand filter query.

参数

fq

返回值

SolrQuery

参见

  • SolrQuery::setExpand
  • SolrQuery::addExpandSortField
  • SolrQuery::removeExpandSortField
  • SolrQuery::setExpandRows
  • SolrQuery::setExpandQuery
  • SolrQuery::addExpandFilterQuery

SolrQuery::removeExpandSortField

Removes an expand sort field from the expand.sort parameter

说明

public SolrQuery SolrQuery::removeExpandSortField ( string $field )

Removes an expand sort field from the expand.sort parameter.

参数

field
field name

返回值

SolrQuery

参见

  • SolrQuery::setExpand
  • SolrQuery::addExpandSortField
  • SolrQuery::setExpandRows
  • SolrQuery::setExpandQuery
  • SolrQuery::addExpandFilterQuery
  • SolrQuery::removeExpandFilterQuery

SolrQuery::removeFacetDateField

Removes one of the facet date fields

说明

public SolrQuery SolrQuery::removeFacetDateField ( string $field )

The name of the field

参数

field
The name of the date field to remove

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::removeFacetDateOther

Removes one of the facet.date.other parameters

说明

public SolrQuery SolrQuery::removeFacetDateOther ( string $value [, string $field_override ] )

Removes one of the facet.date.other parameters

参数

value
The value

field_override
The name of the field.

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::removeFacetField

Removes one of the facet.date parameters

说明

public SolrQuery SolrQuery::removeFacetField ( string $field )

Removes one of the facet.date parameters

参数

field
The name of the field

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::removeFacetQuery

Removes one of the facet.query parameters

说明

public SolrQuery SolrQuery::removeFacetQuery ( string $value )

Removes one of the facet.query parameters.

参数

value
The value

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::removeField

Removes a field from the list of fields

说明

public SolrQuery SolrQuery::removeField ( string $field )

Removes a field from the list of fields

参数

field
Name of the field.

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::removeFilterQuery

Removes a filter query

说明

public SolrQuery SolrQuery::removeFilterQuery ( string $fq )

Removes a filter query.

参数

fq
The filter query to remove

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::removeHighlightField

Removes one of the fields used for highlighting

说明

public SolrQuery SolrQuery::removeHighlightField ( string $field )

Removes one of the fields used for highlighting.

参数

field
The name of the field

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::removeMltField

Removes one of the moreLikeThis fields

说明

public SolrQuery SolrQuery::removeMltField ( string $field )

Removes one of the moreLikeThis fields.

参数

field
Name of the field

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::removeMltQueryField

Removes one of the moreLikeThis query fields

说明

public SolrQuery SolrQuery::removeMltQueryField ( string $queryField )

Removes one of the moreLikeThis query fields.

参数

queryField
The query field

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::removeSortField

Removes one of the sort fields

说明

public SolrQuery SolrQuery::removeSortField ( string $field )

Removes one of the sort fields

参数

field
The name of the field

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::removeStatsFacet

Removes one of the stats.facet parameters

说明

public SolrQuery SolrQuery::removeStatsFacet ( string $value )

Removes one of the stats.facet parameters

参数

value
The value

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::removeStatsField

Removes one of the stats.field parameters

说明

public SolrQuery SolrQuery::removeStatsField ( string $field )

Removes one of the stats.field parameters

参数

field
The name of the field.

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::setEchoHandler

Toggles the echoHandler parameter

说明

public SolrQuery SolrQuery::setEchoHandler ( bool $flag )

If set to true, Solr places the name of the handle used in the response to the client for debugging purposes.

参数

flag
TRUE or FALSE

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::setEchoParams

Determines what kind of parameters to include in the response

说明

public SolrQuery SolrQuery::setEchoParams ( string $type )

Instructs Solr what kinds of Request parameters should be included in the response for debugging purposes, legal values include:

- none - don't include any request parameters for debugging
- explicit - include the parameters explicitly specified by the client in the request
- all - include all parameters involved in this request, either specified explicitly by the client, or implicit because of the request handler configuration.

参数

type
The type of parameters to include

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::setExpand

Enables/Disables the Expand Component

说明

public SolrQuery SolrQuery::setExpand ( bool $value )

Enables/Disables the Expand Component.

参数

value
Bool flag

返回值

SolrQuery

范例

示例 #1 SolrQuery::setExpand example

<?php

$query = new SolrQuery('lucene');

$query
    ->setExpand(true)
    ->setExpandRows(50)
    ->setExpandQuery('text:product')
    ->addExpandFilterQuery('manu:apple')
    ->addExpandFilterQuery('inStock:true')
    ->addExpandSortField('score', SolrQuery::ORDER_DESC)
    ->addExpandSortField('title', SolrQuery::ORDER_ASC);

echo $query.PHP_EOL;

?>

以上例程的输出类似于:

q=lucene&expand=true&expand.rows=50&expand.q=text:product&expand.fq=manu:apple&expand.fq=inStock:true&expand.sort=score desc,title asc

参见

  • SolrQuery::addExpandSortField
  • SolrQuery::removeExpandSortField
  • SolrQuery::setExpandRows
  • SolrQuery::setExpandQuery
  • SolrQuery::addExpandFilterQuery
  • SolrQuery::removeExpandFilterQuery

SolrQuery::setExpandQuery

Sets the expand.q parameter

说明

public SolrQuery SolrQuery::setExpandQuery ( string $q )

Sets the expand.q parameter.

Overrides the main q parameter, determines which documents to include in the main group.

参数

q

返回值

SolrQuery

参见

  • SolrQuery::setExpand
  • SolrQuery::addExpandSortField
  • SolrQuery::removeExpandSortField
  • SolrQuery::setExpandRows
  • SolrQuery::addExpandFilterQuery
  • SolrQuery::removeExpandFilterQuery

SolrQuery::setExpandRows

Sets the number of rows to display in each group (expand.rows). Server Default 5

说明

public SolrQuery SolrQuery::setExpandRows ( int $value )

Sets the number of rows to display in each group (expand.rows). Server Default 5

参数

value

返回值

SolrQuery

参见

  • SolrQuery::setExpand
  • SolrQuery::addExpandSortField
  • SolrQuery::removeExpandSortField
  • SolrQuery::setExpandQuery
  • SolrQuery::addExpandFilterQuery
  • SolrQuery::removeExpandFilterQuery

SolrQuery::setExplainOther

Sets the explainOther common query parameter

说明

public SolrQuery SolrQuery::setExplainOther ( string $query )

Sets the explainOther common query parameter

参数

query
The Lucene query to identify a set of documents

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::setFacet

Maps to the facet parameter. Enables or disables facetting

说明

public SolrQuery SolrQuery::setFacet ( bool $flag )

Enables or disables faceting.

参数

value
TRUE enables faceting and FALSE disables it.

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::setFacetDateEnd

Maps to facet.date.end

说明

public SolrQuery SolrQuery::setFacetDateEnd ( string $value [, string $field_override ] )

Maps to facet.date.end

参数

value
See facet.date.end

field_override
Name of the field

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::setFacetDateGap

Maps to facet.date.gap

说明

public SolrQuery SolrQuery::setFacetDateGap ( string $value [, string $field_override ] )

Maps to facet.date.gap

参数

value
See facet.date.gap

field_override
The name of the field

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::setFacetDateHardEnd

Maps to facet.date.hardend

说明

public SolrQuery SolrQuery::setFacetDateHardEnd ( bool $value [, string $field_override ] )

Maps to facet.date.hardend

参数

value
See facet.date.hardend

field_override
The name of the field

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::setFacetDateStart

Maps to facet.date.start

说明

public SolrQuery SolrQuery::setFacetDateStart ( string $value [, string $field_override ] )

Maps to facet.date.start

参数

value
See facet.date.start

field_override
The name of the field.

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::setFacetEnumCacheMinDefaultFrequency

Sets the minimum document frequency used for determining term count

说明

public SolrQuery SolrQuery::setFacetEnumCacheMinDefaultFrequency ( int $frequency [, string $field_override ] )

Sets the minimum document frequency used for determining term count

参数

value
The minimum frequency

field_override
The name of the field.

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::setFacetLimit

Maps to facet.limit

说明

public SolrQuery SolrQuery::setFacetLimit ( int $limit [, string $field_override ] )

Maps to facet.limit. Sets the maximum number of constraint counts that should be returned for the facet fields.

参数

limit
The maximum number of constraint counts

field_override
The name of the field.

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::setFacetMethod

Specifies the type of algorithm to use when faceting a field

说明

public SolrQuery SolrQuery::setFacetMethod ( string $method [, string $field_override ] )

Specifies the type of algorithm to use when faceting a field. This method accepts optional field override.

参数

method
The method to use.

field_override
The name of the field.

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::setFacetMinCount

Maps to facet.mincount

说明

public SolrQuery SolrQuery::setFacetMinCount ( int $mincount [, string $field_override ] )

Sets the minimum counts for facet fields that should be included in the response

参数

mincount
The minimum count

field_override
The name of the field.

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::setFacetMissing

Maps to facet.missing

说明

public SolrQuery SolrQuery::setFacetMissing ( bool $flag [, string $field_override ] )

Used to indicate that in addition to the Term-based constraints of a facet field, a count of all matching results which have no value for the field should be computed

参数

flag
TRUE turns this feature on. FALSE disables it.

field_override
The name of the field.

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::setFacetOffset

Sets the offset into the list of constraints to allow for pagination

说明

public SolrQuery SolrQuery::setFacetOffset ( int $offset [, string $field_override ] )

Sets the offset into the list of constraints to allow for pagination.

参数

offset
The offset

field_override
The name of the field.

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::setFacetPrefix

Specifies a string prefix with which to limits the terms on which to facet

说明

public SolrQuery SolrQuery::setFacetPrefix ( string $prefix [, string $field_override ] )

Specifies a string prefix with which to limits the terms on which to facet.

参数

prefix
The prefix string

field_override
The name of the field.

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::setFacetSort

Determines the ordering of the facet field constraints

说明

public SolrQuery SolrQuery::setFacetSort ( int $facetSort [, string $field_override ] )

Determines the ordering of the facet field constraints

参数

facetSort
Use SolrQuery::FACET_SORT_INDEX for sorting by index order or SolrQuery::FACET_SORT_COUNT for sorting by count.

field_override
The name of the field.

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::setGroup

Enable/Disable result grouping (group parameter)

说明

public SolrQuery SolrQuery::setGroup ( bool $value )

Enable/Disable result grouping (group parameter)

参数

value

返回值

参见

  • SolrQuery::getGroup
  • SolrQuery::addGroupField
  • SolrQuery::addGroupFunction
  • SolrQuery::addGroupQuery
  • SolrQuery::addGroupSortField
  • SolrQuery::setGroupFacet
  • SolrQuery::setGroupOffset
  • SolrQuery::setGroupLimit
  • SolrQuery::setGroupMain
  • SolrQuery::setGroupNGroups
  • SolrQuery::setGroupTruncate
  • SolrQuery::setGroupFormat
  • SolrQuery::setGroupCachePercent

SolrQuery::setGroupCachePercent

Enables caching for result grouping

说明

public SolrQuery SolrQuery::setGroupCachePercent ( int $percent )

Setting this parameter to a number greater than 0 enables caching for result grouping. Result Grouping executes two searches; this option caches the second search. The server default value is 0. Testing has shown that group caching only improves search time with Boolean, wildcard, and fuzzy queries. For simple queries like term or "match all" queries, group caching degrades performance. group.cache.percent parameter

参数

percent

返回值

错误/异常

Emits SolrIllegalArgumentException in case of an invalid parameter was passed.

参见

  • SolrQuery::setGroup
  • SolrQuery::addGroupField
  • SolrQuery::addGroupFunction
  • SolrQuery::addGroupQuery
  • SolrQuery::addGroupSortField
  • SolrQuery::setGroupFacet
  • SolrQuery::setGroupOffset
  • SolrQuery::setGroupLimit
  • SolrQuery::setGroupMain
  • SolrQuery::setGroupNGroups
  • SolrQuery::setGroupTruncate
  • SolrQuery::setGroupFormat

SolrQuery::setGroupFacet

Sets group.facet parameter

说明

public SolrQuery SolrQuery::setGroupFacet ( bool $value )

Determines whether to compute grouped facets for the field facets specified in facet.field parameters. Grouped facets are computed based on the first specified group.

参数

value

返回值

参见

  • SolrQuery::setGroup
  • SolrQuery::addGroupField
  • SolrQuery::addGroupFunction
  • SolrQuery::addGroupQuery
  • SolrQuery::addGroupSortField
  • SolrQuery::setGroupOffset
  • SolrQuery::setGroupLimit
  • SolrQuery::setGroupMain
  • SolrQuery::setGroupNGroups
  • SolrQuery::setGroupTruncate
  • SolrQuery::setGroupFormat
  • SolrQuery::setGroupCachePercent

SolrQuery::setGroupFormat

Sets the group format, result structure (group.format parameter)

说明

public SolrQuery SolrQuery::setGroupFormat ( string $value )

Sets the group.format parameter. If this parameter is set to simple, the grouped documents are presented in a single flat list, and the start and rows parameters affect the numbers of documents instead of groups. Accepts: grouped/simple

参数

value

返回值

参见

  • SolrQuery::setGroup
  • SolrQuery::addGroupField
  • SolrQuery::addGroupFunction
  • SolrQuery::addGroupQuery
  • SolrQuery::addGroupSortField
  • SolrQuery::setGroupFacet
  • SolrQuery::setGroupOffset
  • SolrQuery::setGroupLimit
  • SolrQuery::setGroupMain
  • SolrQuery::setGroupNGroups
  • SolrQuery::setGroupTruncate
  • SolrQuery::setGroupCachePercent

SolrQuery::setGroupLimit

Specifies the number of results to return for each group. The server default value is 1

说明

public SolrQuery SolrQuery::setGroupLimit ( int $value )

Specifies the number of results to return for each group. The server default value is 1.

参数

value

返回值

参见

  • SolrQuery::setGroup
  • SolrQuery::addGroupField
  • SolrQuery::addGroupFunction
  • SolrQuery::addGroupQuery
  • SolrQuery::addGroupSortField
  • SolrQuery::setGroupFacet
  • SolrQuery::setGroupOffset
  • SolrQuery::setGroupMain
  • SolrQuery::setGroupNGroups
  • SolrQuery::setGroupTruncate
  • SolrQuery::setGroupFormat
  • SolrQuery::setGroupCachePercent

SolrQuery::setGroupMain

If true, the result of the first field grouping command is used as the main result list in the response, using group.format=simple

说明

public SolrQuery SolrQuery::setGroupMain ( string $value )

If true, the result of the first field grouping command is used as the main result list in the response, using group.format=simple.

参数

value

返回值

参见

参见

  • SolrQuery::setGroup
  • SolrQuery::addGroupField
  • SolrQuery::addGroupFunction
  • SolrQuery::addGroupQuery
  • SolrQuery::addGroupSortField
  • SolrQuery::setGroupFacet
  • SolrQuery::setGroupOffset
  • SolrQuery::setGroupMain
  • SolrQuery::setGroupNGroups
  • SolrQuery::setGroupTruncate
  • SolrQuery::setGroupFormat
  • SolrQuery::setGroupCachePercent

SolrQuery::setGroupNGroups

If true, Solr includes the number of groups that have matched the query in the results

说明

public SolrQuery SolrQuery::setGroupNGroups ( bool $value )

If true, Solr includes the number of groups that have matched the query in the results.

参数

value

返回值

参见

  • SolrQuery::setGroup
  • SolrQuery::addGroupField
  • SolrQuery::addGroupFunction
  • SolrQuery::addGroupQuery
  • SolrQuery::addGroupSortField
  • SolrQuery::setGroupFacet
  • SolrQuery::setGroupOffset
  • SolrQuery::setGroupLimit
  • SolrQuery::setGroupMain
  • SolrQuery::setGroupTruncate
  • SolrQuery::setGroupFormat
  • SolrQuery::setGroupCachePercent

SolrQuery::setGroupOffset

Sets the group.offset parameter

说明

public SolrQuery SolrQuery::setGroupOffset ( int $value )

Sets the group.offset parameter.

参数

value

返回值

参见

  • SolrQuery::setGroup
  • SolrQuery::addGroupField
  • SolrQuery::addGroupFunction
  • SolrQuery::addGroupQuery
  • SolrQuery::addGroupSortField
  • SolrQuery::setGroupFacet
  • SolrQuery::setGroupLimit
  • SolrQuery::setGroupMain
  • SolrQuery::setGroupNGroups
  • SolrQuery::setGroupTruncate
  • SolrQuery::setGroupFormat
  • SolrQuery::setGroupCachePercent

SolrQuery::setGroupTruncate

If true, facet counts are based on the most relevant document of each group matching the query

说明

public SolrQuery SolrQuery::setGroupTruncate ( bool $value )

If true, facet counts are based on the most relevant document of each group matching the query. The server default value is false. group.truncate parameter

参数

value

返回值

参见

  • SolrQuery::setGroup
  • SolrQuery::addGroupField
  • SolrQuery::addGroupFunction
  • SolrQuery::addGroupQuery
  • SolrQuery::addGroupSortField
  • SolrQuery::setGroupFacet
  • SolrQuery::setGroupOffset
  • SolrQuery::setGroupLimit
  • SolrQuery::setGroupMain
  • SolrQuery::setGroupNGroups
  • SolrQuery::setGroupFormat
  • SolrQuery::setGroupCachePercent

SolrQuery::setHighlight

Enables or disables highlighting

说明

public SolrQuery SolrQuery::setHighlight ( bool $flag )

Setting it to TRUE enables highlighted snippets to be generated in the query response.

Setting it to FALSE disables highlighting

参数

flag
Enable or disable highlighting

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::setHighlightAlternateField

Specifies the backup field to use

说明

public SolrQuery SolrQuery::setHighlightAlternateField ( string $field [, string $field_override ] )

If a snippet cannot be generated because there were no matching terms, one can specify a field to use as the backup or default summary

参数

field
The name of the backup field

field_override
The name of the field we are overriding this setting for.

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::setHighlightFormatter

Specify a formatter for the highlight output

说明

public SolrQuery SolrQuery::setHighlightFormatter ( string $formatter [, string $field_override ] )

Specify a formatter for the highlight output.

参数

formatter
Currently the only legal value is "simple"

field_override
The name of the field.

SolrQuery::setHighlightFragmenter

Sets a text snippet generator for highlighted text

说明

public SolrQuery SolrQuery::setHighlightFragmenter ( string $fragmenter [, string $field_override ] )

Specify a text snippet generator for highlighted text.

参数

fragmenter
The standard fragmenter is gap. Another option is regex, which tries to create fragments that resembles a certain regular expression

field_override
The name of the field.

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::setHighlightFragsize

The size of fragments to consider for highlighting

说明

public SolrQuery SolrQuery::setHighlightFragsize ( int $size [, string $field_override ] )

Sets the size, in characters, of fragments to consider for highlighting. "0" indicates that the whole field value should be used (no fragmenting).

参数

size
The size, in characters, of fragments to consider for highlighting

field_override
The name of the field.

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::setHighlightHighlightMultiTerm

Use SpanScorer to highlight phrase terms

说明

public SolrQuery SolrQuery::setHighlightHighlightMultiTerm ( bool $flag )

Use SpanScorer to highlight phrase terms only when they appear within the query phrase in the document.

参数

flag
Whether or not to use SpanScorer to highlight phrase terms only when they appear within the query phrase in the document.

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::setHighlightMaxAlternateFieldLength

Sets the maximum number of characters of the field to return

说明

public SolrQuery SolrQuery::setHighlightMaxAlternateFieldLength ( int $fieldLength [, string $field_override ] )

If SolrQuery::setHighlightAlternateField() was passed the value TRUE, this parameter specifies the maximum number of characters of the field to return

Any value less than or equal to 0 means unlimited.

参数

fieldLength
The length of the field

field_override
The name of the field.

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::setHighlightMaxAnalyzedChars

Specifies the number of characters into a document to look for suitable snippets

说明

public SolrQuery SolrQuery::setHighlightMaxAnalyzedChars ( int $value )

Specifies the number of characters into a document to look for suitable snippets

参数

value
The number of characters into a document to look for suitable snippets

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::setHighlightMergeContiguous

Whether or not to collapse contiguous fragments into a single fragment

说明

public SolrQuery SolrQuery::setHighlightMergeContiguous ( bool $flag [, string $field_override ] )

Whether or not to collapse contiguous fragments into a single fragment

参数

value
Whether or not to collapse contiguous fragments into a single fragment

field_override
The name of the field.

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::setHighlightRegexMaxAnalyzedChars

Specify the maximum number of characters to analyze

说明

public SolrQuery SolrQuery::setHighlightRegexMaxAnalyzedChars ( int $maxAnalyzedChars )

Specify the maximum number of characters to analyze from a field when using the regex fragmenter

参数

maxAnalyzedChars
The maximum number of characters to analyze from a field when using the regex fragmenter

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::setHighlightRegexPattern

Specify the regular expression for fragmenting

说明

public SolrQuery SolrQuery::setHighlightRegexPattern ( string $value )

Specifies the regular expression for fragmenting. This could be used to extract sentences

参数

value
The regular expression for fragmenting. This could be used to extract sentences

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::setHighlightRegexSlop

Sets the factor by which the regex fragmenter can stray from the ideal fragment size

说明

public SolrQuery SolrQuery::setHighlightRegexSlop ( float $factor )

The factor by which the regex fragmenter can stray from the ideal fragment size ( specfied by SolrQuery::setHighlightFragsize )to accommodate the regular expression

参数

factor
The factor by which the regex fragmenter can stray from the ideal fragment size

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::setHighlightRequireFieldMatch

Require field matching during highlighting

说明

public SolrQuery SolrQuery::setHighlightRequireFieldMatch ( bool $flag )

If TRUE, then a field will only be highlighted if the query matched in this particular field.

This will only work if SolrQuery::setHighlightUsePhraseHighlighter() was set to TRUE

参数

flag
TRUE or FALSE

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::setHighlightSimplePost

Sets the text which appears after a highlighted term

说明

public SolrQuery SolrQuery::setHighlightSimplePost ( string $simplePost [, string $field_override ] )

Sets the text which appears before a highlighted term

参数

simplePost
Sets the text which appears after a highlighted term

The default is </em>

field_override
The name of the field.

SolrQuery::setHighlightSimplePre

Sets the text which appears before a highlighted term

说明

public SolrQuery SolrQuery::setHighlightSimplePre ( string $simplePre [, string $field_override ] )

Sets the text which appears before a highlighted term

The default is <em>

参数

simplePre
The text which appears before a highlighted term

field_override
The name of the field.

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::setHighlightSnippets

Sets the maximum number of highlighted snippets to generate per field

说明

public SolrQuery SolrQuery::setHighlightSnippets ( int $value [, string $field_override ] )

Sets the maximum number of highlighted snippets to generate per field

参数

value
The maximum number of highlighted snippets to generate per field

field_override
The name of the field.

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::setHighlightUsePhraseHighlighter

Whether to highlight phrase terms only when they appear within the query phrase

说明

public SolrQuery SolrQuery::setHighlightUsePhraseHighlighter ( bool $flag )

Sets whether or not to use SpanScorer to highlight phrase terms only when they appear within the query phrase in the document

参数

value
Whether or not to use SpanScorer to highlight phrase terms only when they appear within the query phrase in the document

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::setMlt

Enables or disables moreLikeThis

说明

public SolrQuery SolrQuery::setMlt ( bool $flag )

Enables or disables moreLikeThis

参数

flag
TRUE enables it and FALSE turns it off.

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::setMltBoost

Set if the query will be boosted by the interesting term relevance

说明

public SolrQuery SolrQuery::setMltBoost ( bool $flag )

Set if the query will be boosted by the interesting term relevance

参数

value
Sets to TRUE or FALSE

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::setMltCount

Set the number of similar documents to return for each result

说明

public SolrQuery SolrQuery::setMltCount ( int $count )

Set the number of similar documents to return for each result

参数

count
The number of similar documents to return for each result

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::setMltMaxNumQueryTerms

Sets the maximum number of query terms included

说明

public SolrQuery SolrQuery::setMltMaxNumQueryTerms ( int $value )

Sets the maximum number of query terms that will be included in any generated query.

参数

value
The maximum number of query terms that will be included in any generated query

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::setMltMaxNumTokens

Specifies the maximum number of tokens to parse

说明

public SolrQuery SolrQuery::setMltMaxNumTokens ( int $value )

Specifies the maximum number of tokens to parse in each example doc field that is not stored with TermVector support.

参数

value
The maximum number of tokens to parse

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::setMltMaxWordLength

Sets the maximum word length

说明

public SolrQuery SolrQuery::setMltMaxWordLength ( int $maxWordLength )

Sets the maximum word length above which words will be ignored.

参数

maxWordLength
The maximum word length above which words will be ignored

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::setMltMinDocFrequency

Sets the mltMinDoc frequency

说明

public SolrQuery SolrQuery::setMltMinDocFrequency ( int $minDocFrequency )

The frequency at which words will be ignored which do not occur in at least this many docs.

参数

minDocFrequency
Sets the frequency at which words will be ignored which do not occur in at least this many docs.

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::setMltMinTermFrequency

Sets the frequency below which terms will be ignored in the source docs

说明

public SolrQuery SolrQuery::setMltMinTermFrequency ( int $minTermFrequency )

Sets the frequency below which terms will be ignored in the source docs

参数

minTermFrequency
The frequency below which terms will be ignored in the source docs

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::setMltMinWordLength

Sets the minimum word length

说明

public SolrQuery SolrQuery::setMltMinWordLength ( int $minWordLength )

Sets the minimum word length below which words will be ignored.

参数

minWordLength
The minimum word length below which words will be ignored

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::setOmitHeader

Exclude the header from the returned results

说明

public SolrQuery SolrQuery::setOmitHeader ( bool $flag )

Exclude the header from the returned results.

参数

flag
TRUE excludes the header from the result.

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::setQuery

Sets the search query

说明

public SolrQuery SolrQuery::setQuery ( string $query )

Sets the search query.

参数

query
The search query

返回值

Returns the current SolrQuery object

SolrQuery::setRows

Specifies the maximum number of rows to return in the result

说明

public SolrQuery SolrQuery::setRows ( int $rows )

Specifies the maximum number of rows to return in the result

参数

rows
The maximum number of rows to return

返回值

Returns the current SolrQuery object.

SolrQuery::setShowDebugInfo

Flag to show debug information

说明

public SolrQuery SolrQuery::setShowDebugInfo ( bool $flag )

Whether to show debug info

参数

flag
Whether to show debug info. TRUE or FALSE

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::setStart

Specifies the number of rows to skip

说明

public SolrQuery SolrQuery::setStart ( int $start )

Specifies the number of rows to skip. Useful in pagination of results.

参数

start
The number of rows to skip.

返回值

Returns the current SolrQuery object.

SolrQuery::setStats

Enables or disables the Stats component

说明

public SolrQuery SolrQuery::setStats ( bool $flag )

Enables or disables the Stats component.

参数

flag
TRUE turns on the stats component and FALSE disables it.

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::setTerms

Enables or disables the TermsComponent

说明

public SolrQuery SolrQuery::setTerms ( bool $flag )

Enables or disables the TermsComponent

参数

flag
TRUE enables it. FALSE turns it off

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::setTermsField

Sets the name of the field to get the Terms from

说明

public SolrQuery SolrQuery::setTermsField ( string $fieldname )

Sets the name of the field to get the terms from

参数

fieldname
The field name

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::setTermsIncludeLowerBound

Include the lower bound term in the result set

说明

public SolrQuery SolrQuery::setTermsIncludeLowerBound ( bool $flag )

Include the lower bound term in the result set.

参数

flag
Include the lower bound term in the result set

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::setTermsIncludeUpperBound

Include the upper bound term in the result set

说明

public SolrQuery SolrQuery::setTermsIncludeUpperBound ( bool $flag )

Include the upper bound term in the result set.

参数

flag
TRUE or FALSE

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::setTermsLimit

Sets the maximum number of terms to return

说明

public SolrQuery SolrQuery::setTermsLimit ( int $limit )

Sets the maximum number of terms to return

参数

limit
The maximum number of terms to return. All the terms will be returned if the limit is negative.

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::setTermsLowerBound

Specifies the Term to start from

说明

public SolrQuery SolrQuery::setTermsLowerBound ( string $lowerBound )

Specifies the Term to start from

参数

lowerBound
The lower bound Term

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::setTermsMaxCount

Sets the maximum document frequency

说明

public SolrQuery SolrQuery::setTermsMaxCount ( int $frequency )

Sets the maximum document frequency.

参数

frequency
The maximum document frequency.

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::setTermsMinCount

Sets the minimum document frequency

说明

public SolrQuery SolrQuery::setTermsMinCount ( int $frequency )

Sets the minimum doc frequency to return in order to be included

参数

frequency
The minimum frequency

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::setTermsPrefix

Restrict matches to terms that start with the prefix

说明

public SolrQuery SolrQuery::setTermsPrefix ( string $prefix )

Restrict matches to terms that start with the prefix

参数

prefix
Restrict matches to terms that start with the prefix

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::setTermsReturnRaw

Return the raw characters of the indexed term

说明

public SolrQuery SolrQuery::setTermsReturnRaw ( bool $flag )

If true, return the raw characters of the indexed term, regardless of if it is human readable

参数

value
TRUE or FALSE

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::setTermsSort

Specifies how to sort the returned terms

说明

public SolrQuery SolrQuery::setTermsSort ( int $sortType )

If SolrQuery::TERMS_SORT_COUNT, sorts the terms by the term frequency (highest count first). If SolrQuery::TERMS_SORT_INDEX, returns the terms in index order

参数

sortType
SolrQuery::TERMS_SORT_INDEX or SolrQuery::TERMS_SORT_COUNT

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::setTermsUpperBound

Sets the term to stop at

说明

public SolrQuery SolrQuery::setTermsUpperBound ( string $upperBound )

Sets the term to stop at

参数

upperBound
The term to stop at

返回值

Returns the current SolrQuery object, if the return value is used.

SolrQuery::setTimeAllowed

The time allowed for search to finish

说明

public SolrQuery SolrQuery::setTimeAllowed ( int $timeAllowed )

The time allowed for a search to finish. This value only applies to the search and not to requests in general. Time is in milliseconds. Values less than or equal to zero implies no time restriction. Partial results may be returned, if there are any.

参数

timeAllowed
The time allowed for a search to finish.

返回值

Returns the current SolrQuery object, if the return value is used.

简介

类摘要

SolrDisMaxQuery

class SolrDisMaxQuery extends SolrQuery implements Serializable {

/* 继承的属性 */

const integer SolrQuery::ORDER_ASC = 0 ;

const integer SolrQuery::ORDER_DESC = 1 ;

const integer SolrQuery::FACET_SORT_INDEX = 0 ;

const integer SolrQuery::FACET_SORT_COUNT = 1 ;

const integer SolrQuery::TERMS_SORT_INDEX = 0 ;

const integer SolrQuery::TERMS_SORT_COUNT = 1 ;

/* 方法 */

public SolrDisMaxQuery addBigramPhraseField ( string $field , string $boost [, string $slop ] )

public SolrDisMaxQuery addBoostQuery ( string $field , string $value [, string $boost ] )

public SolrDisMaxQuery addPhraseField ( string $field , string $boost [, string $slop ] )

public SolrDisMaxQuery addQueryField ( string $field [, string $boost ] )

public SolrDisMaxQuery addTrigramPhraseField ( string $field , string $boost [, string $slop ] )

public SolrDisMaxQuery addUserField ( string $field )

public __construct ([ string $q ] )

public SolrDisMaxQuery removeBigramPhraseField ( string $field )

public SolrDisMaxQuery removeBoostQuery ( string $field )

public SolrDisMaxQuery removePhraseField ( string $field )

public SolrDisMaxQuery removeQueryField ( string $field )

public SolrDisMaxQuery removeTrigramPhraseField ( string $field )

public SolrDisMaxQuery removeUserField ( string $field )

public SolrDisMaxQuery setBigramPhraseFields ( string $fields )

public SolrDisMaxQuery setBigramPhraseSlop ( string $slop )

public SolrDisMaxQuery setBoostFunction ( string $function )

public SolrDisMaxQuery setBoostQuery ( string $q )

public SolrDisMaxQuery setMinimumMatch ( string $value )

public SolrDisMaxQuery setPhraseFields ( string $fields )

public SolrDisMaxQuery setPhraseSlop ( string $slop )

public SolrDisMaxQuery setQueryAlt ( string $q )

public SolrDisMaxQuery setQueryPhraseSlop ( string $slop )

public SolrDisMaxQuery setTieBreaker ( string $tieBreaker )

public SolrDisMaxQuery setTrigramPhraseFields ( string $fields )

public SolrDisMaxQuery setTrigramPhraseSlop ( string $slop )

public SolrDisMaxQuery setUserFields ( string $fields )

public SolrDisMaxQuery useDisMaxQueryParser ( void )

public SolrDisMaxQuery useEDisMaxQueryParser ( void )

/* 继承的方法 */

public SolrQuery SolrQuery::addExpandFilterQuery ( string $fq )

public SolrQuery SolrQuery::addExpandSortField ( string $field [, string $order ] )

public SolrQuery SolrQuery::addFacetDateField ( string $dateField )

public SolrQuery SolrQuery::addFacetDateOther ( string $value [, string $field_override ] )

public SolrQuery SolrQuery::addFacetField ( string $field )

public SolrQuery SolrQuery::addFacetQuery ( string $facetQuery )

public SolrQuery SolrQuery::addField ( string $field )

public SolrQuery SolrQuery::addFilterQuery ( string $fq )

public SolrQuery SolrQuery::addGroupField ( string $value )

public SolrQuery SolrQuery::addGroupFunction ( string $value )

public SolrQuery SolrQuery::addGroupQuery ( string $value )

public SolrQuery SolrQuery::addGroupSortField ( string $field [, int $order ] )

public SolrQuery SolrQuery::addHighlightField ( string $field )

public SolrQuery SolrQuery::addMltField ( string $field )

public SolrQuery SolrQuery::addMltQueryField ( string $field , float $boost )

public SolrQuery SolrQuery::addSortField ( string $field [, int $order = SolrQuery::ORDER_DESC ] )

public SolrQuery SolrQuery::addStatsFacet ( string $field )

public SolrQuery SolrQuery::addStatsField ( string $field )

public SolrQuery SolrQuery::collapse ( SolrCollapseFunction $collapseFunction )

public SolrQuery::__construct ([ string $q ] )

public void SolrQuery::__destruct ( void )

public bool SolrQuery::getExpand ( void )

public array SolrQuery::getExpandFilterQueries ( void )

public array SolrQuery::getExpandQuery ( void )

public int SolrQuery::getExpandRows ( void )

public array SolrQuery::getExpandSortFields ( void )

public bool SolrQuery::getFacet ( void )

public string SolrQuery::getFacetDateEnd ([ string $field_override ] )

public array SolrQuery::getFacetDateFields ( void )

public string SolrQuery::getFacetDateGap ([ string $field_override ] )

public string SolrQuery::getFacetDateHardEnd ([ string $field_override ] )

public array SolrQuery::getFacetDateOther ([ string $field_override ] )

public string SolrQuery::getFacetDateStart ([ string $field_override ] )

public array SolrQuery::getFacetFields ( void )

public int SolrQuery::getFacetLimit ([ string $field_override ] )

public string SolrQuery::getFacetMethod ([ string $field_override ] )

public int SolrQuery::getFacetMinCount ([ string $field_override ] )

public bool SolrQuery::getFacetMissing ([ string $field_override ] )

public int SolrQuery::getFacetOffset ([ string $field_override ] )

public string SolrQuery::getFacetPrefix ([ string $field_override ] )

public array SolrQuery::getFacetQueries ( void )

public int SolrQuery::getFacetSort ([ string $field_override ] )

public array SolrQuery::getFields ( void )

public array SolrQuery::getFilterQueries ( void )

public bool SolrQuery::getGroup ( void )

public int SolrQuery::getGroupCachePercent ( void )

public bool SolrQuery::getGroupFacet ( void )

public array SolrQuery::getGroupFields ( void )

public string SolrQuery::getGroupFormat ( void )

public array SolrQuery::getGroupFunctions ( void )

public int SolrQuery::getGroupLimit ( void )

public bool SolrQuery::getGroupMain ( void )

public bool SolrQuery::getGroupNGroups ( void )

public int SolrQuery::getGroupOffset ( void )

public array SolrQuery::getGroupQueries ( void )

public array SolrQuery::getGroupSortFields ( void )

public bool SolrQuery::getGroupTruncate ( void )

public bool SolrQuery::getHighlight ( void )

public string SolrQuery::getHighlightAlternateField ([ string $field_override ] )

public array SolrQuery::getHighlightFields ( void )

public string SolrQuery::getHighlightFormatter ([ string $field_override ] )

public string SolrQuery::getHighlightFragmenter ([ string $field_override ] )

public int SolrQuery::getHighlightFragsize ([ string $field_override ] )

public bool SolrQuery::getHighlightHighlightMultiTerm ( void )

public int SolrQuery::getHighlightMaxAlternateFieldLength ([ string $field_override ] )

public int SolrQuery::getHighlightMaxAnalyzedChars ( void )

public bool SolrQuery::getHighlightMergeContiguous ([ string $field_override ] )

public int SolrQuery::getHighlightRegexMaxAnalyzedChars ( void )

public string SolrQuery::getHighlightRegexPattern ( void )

public float SolrQuery::getHighlightRegexSlop ( void )

public bool SolrQuery::getHighlightRequireFieldMatch ( void )

public string SolrQuery::getHighlightSimplePost ([ string $field_override ] )

public string SolrQuery::getHighlightSimplePre ([ string $field_override ] )

public int SolrQuery::getHighlightSnippets ([ string $field_override ] )

public bool SolrQuery::getHighlightUsePhraseHighlighter ( void )

public bool SolrQuery::getMlt ( void )

public bool SolrQuery::getMltBoost ( void )

public int SolrQuery::getMltCount ( void )

public array SolrQuery::getMltFields ( void )

public int SolrQuery::getMltMaxNumQueryTerms ( void )

public int SolrQuery::getMltMaxNumTokens ( void )

public int SolrQuery::getMltMaxWordLength ( void )

public int SolrQuery::getMltMinDocFrequency ( void )

public int SolrQuery::getMltMinTermFrequency ( void )

public int SolrQuery::getMltMinWordLength ( void )

public array SolrQuery::getMltQueryFields ( void )

public string SolrQuery::getQuery ( void )

public int SolrQuery::getRows ( void )

public array SolrQuery::getSortFields ( void )

public int SolrQuery::getStart ( void )

public bool SolrQuery::getStats ( void )

public array SolrQuery::getStatsFacets ( void )

public array SolrQuery::getStatsFields ( void )

public bool SolrQuery::getTerms ( void )

public string SolrQuery::getTermsField ( void )

public bool SolrQuery::getTermsIncludeLowerBound ( void )

public bool SolrQuery::getTermsIncludeUpperBound ( void )

public int SolrQuery::getTermsLimit ( void )

public string SolrQuery::getTermsLowerBound ( void )

public int SolrQuery::getTermsMaxCount ( void )

public int SolrQuery::getTermsMinCount ( void )

public string SolrQuery::getTermsPrefix ( void )

public bool SolrQuery::getTermsReturnRaw ( void )

public int SolrQuery::getTermsSort ( void )

public string SolrQuery::getTermsUpperBound ( void )

public int SolrQuery::getTimeAllowed ( void )

public SolrQuery SolrQuery::removeExpandFilterQuery ( string $fq )

public SolrQuery SolrQuery::removeExpandSortField ( string $field )

public SolrQuery SolrQuery::removeFacetDateField ( string $field )

public SolrQuery SolrQuery::removeFacetDateOther ( string $value [, string $field_override ] )

public SolrQuery SolrQuery::removeFacetField ( string $field )

public SolrQuery SolrQuery::removeFacetQuery ( string $value )

public SolrQuery SolrQuery::removeField ( string $field )

public SolrQuery SolrQuery::removeFilterQuery ( string $fq )

public SolrQuery SolrQuery::removeHighlightField ( string $field )

public SolrQuery SolrQuery::removeMltField ( string $field )

public SolrQuery SolrQuery::removeMltQueryField ( string $queryField )

public SolrQuery SolrQuery::removeSortField ( string $field )

public SolrQuery SolrQuery::removeStatsFacet ( string $value )

public SolrQuery SolrQuery::removeStatsField ( string $field )

public SolrQuery SolrQuery::setEchoHandler ( bool $flag )

public SolrQuery SolrQuery::setEchoParams ( string $type )

public SolrQuery SolrQuery::setExpand ( bool $value )

public SolrQuery SolrQuery::setExpandQuery ( string $q )

public SolrQuery SolrQuery::setExpandRows ( int $value )

public SolrQuery SolrQuery::setExplainOther ( string $query )

public SolrQuery SolrQuery::setFacet ( bool $flag )

public SolrQuery SolrQuery::setFacetDateEnd ( string $value [, string $field_override ] )

public SolrQuery SolrQuery::setFacetDateGap ( string $value [, string $field_override ] )

public SolrQuery SolrQuery::setFacetDateHardEnd ( bool $value [, string $field_override ] )

public SolrQuery SolrQuery::setFacetDateStart ( string $value [, string $field_override ] )

public SolrQuery SolrQuery::setFacetEnumCacheMinDefaultFrequency ( int $frequency [, string $field_override ] )

public SolrQuery SolrQuery::setFacetLimit ( int $limit [, string $field_override ] )

public SolrQuery SolrQuery::setFacetMethod ( string $method [, string $field_override ] )

public SolrQuery SolrQuery::setFacetMinCount ( int $mincount [, string $field_override ] )

public SolrQuery SolrQuery::setFacetMissing ( bool $flag [, string $field_override ] )

public SolrQuery SolrQuery::setFacetOffset ( int $offset [, string $field_override ] )

public SolrQuery SolrQuery::setFacetPrefix ( string $prefix [, string $field_override ] )

public SolrQuery SolrQuery::setFacetSort ( int $facetSort [, string $field_override ] )

public SolrQuery SolrQuery::setGroup ( bool $value )

public SolrQuery SolrQuery::setGroupCachePercent ( int $percent )

public SolrQuery SolrQuery::setGroupFacet ( bool $value )

public SolrQuery SolrQuery::setGroupFormat ( string $value )

public SolrQuery SolrQuery::setGroupLimit ( int $value )

public SolrQuery SolrQuery::setGroupMain ( string $value )

public SolrQuery SolrQuery::setGroupNGroups ( bool $value )

public SolrQuery SolrQuery::setGroupOffset ( int $value )

public SolrQuery SolrQuery::setGroupTruncate ( bool $value )

public SolrQuery SolrQuery::setHighlight ( bool $flag )

public SolrQuery SolrQuery::setHighlightAlternateField ( string $field [, string $field_override ] )

public SolrQuery SolrQuery::setHighlightFormatter ( string $formatter [, string $field_override ] )

public SolrQuery SolrQuery::setHighlightFragmenter ( string $fragmenter [, string $field_override ] )

public SolrQuery SolrQuery::setHighlightFragsize ( int $size [, string $field_override ] )

public SolrQuery SolrQuery::setHighlightHighlightMultiTerm ( bool $flag )

public SolrQuery SolrQuery::setHighlightMaxAlternateFieldLength ( int $fieldLength [, string $field_override ] )

public SolrQuery SolrQuery::setHighlightMaxAnalyzedChars ( int $value )

public SolrQuery SolrQuery::setHighlightMergeContiguous ( bool $flag [, string $field_override ] )

public SolrQuery SolrQuery::setHighlightRegexMaxAnalyzedChars ( int $maxAnalyzedChars )

public SolrQuery SolrQuery::setHighlightRegexPattern ( string $value )

public SolrQuery SolrQuery::setHighlightRegexSlop ( float $factor )

public SolrQuery SolrQuery::setHighlightRequireFieldMatch ( bool $flag )

public SolrQuery SolrQuery::setHighlightSimplePost ( string $simplePost [, string $field_override ] )

public SolrQuery SolrQuery::setHighlightSimplePre ( string $simplePre [, string $field_override ] )

public SolrQuery SolrQuery::setHighlightSnippets ( int $value [, string $field_override ] )

public SolrQuery SolrQuery::setHighlightUsePhraseHighlighter ( bool $flag )

public SolrQuery SolrQuery::setMlt ( bool $flag )

public SolrQuery SolrQuery::setMltBoost ( bool $flag )

public SolrQuery SolrQuery::setMltCount ( int $count )

public SolrQuery SolrQuery::setMltMaxNumQueryTerms ( int $value )

public SolrQuery SolrQuery::setMltMaxNumTokens ( int $value )

public SolrQuery SolrQuery::setMltMaxWordLength ( int $maxWordLength )

public SolrQuery SolrQuery::setMltMinDocFrequency ( int $minDocFrequency )

public SolrQuery SolrQuery::setMltMinTermFrequency ( int $minTermFrequency )

public SolrQuery SolrQuery::setMltMinWordLength ( int $minWordLength )

public SolrQuery SolrQuery::setOmitHeader ( bool $flag )

public SolrQuery SolrQuery::setQuery ( string $query )

public SolrQuery SolrQuery::setRows ( int $rows )

public SolrQuery SolrQuery::setShowDebugInfo ( bool $flag )

public SolrQuery SolrQuery::setStart ( int $start )

public SolrQuery SolrQuery::setStats ( bool $flag )

public SolrQuery SolrQuery::setTerms ( bool $flag )

public SolrQuery SolrQuery::setTermsField ( string $fieldname )

public SolrQuery SolrQuery::setTermsIncludeLowerBound ( bool $flag )

public SolrQuery SolrQuery::setTermsIncludeUpperBound ( bool $flag )

public SolrQuery SolrQuery::setTermsLimit ( int $limit )

public SolrQuery SolrQuery::setTermsLowerBound ( string $lowerBound )

public SolrQuery SolrQuery::setTermsMaxCount ( int $frequency )

public SolrQuery SolrQuery::setTermsMinCount ( int $frequency )

public SolrQuery SolrQuery::setTermsPrefix ( string $prefix )

public SolrQuery SolrQuery::setTermsReturnRaw ( bool $flag )

public SolrQuery SolrQuery::setTermsSort ( int $sortType )

public SolrQuery SolrQuery::setTermsUpperBound ( string $upperBound )

public SolrQuery SolrQuery::setTimeAllowed ( int $timeAllowed )

}

预定义常量

SolrDisMaxQuery::ORDER_ASC
Used to specify that the sorting should be in acending order (Duplicated for easier migration)

SolrDisMaxQuery::ORDER_DESC
Used to specify that the sorting should be in descending order (Duplicated for easier migration)

SolrDisMaxQuery::FACET_SORT_INDEX
Used to specify that the facet should sort by index (Duplicated for easier migration)

SolrDisMaxQuery::FACET_SORT_COUNT
Used to specify that the facet should sort by count (Duplicated for easier migration)

SolrDisMaxQuery::TERMS_SORT_INDEX
Used in the TermsComponent (Duplicated for easier migration)

SolrDisMaxQuery::TERMS_SORT_COUNT
Used in the TermsComponent (Duplicated for easier migration)

SolrDisMaxQuery::addBigramPhraseField

Adds a Phrase Bigram Field (pf2 parameter)

说明

public SolrDisMaxQuery SolrDisMaxQuery::addBigramPhraseField ( string $field , string $boost [, string $slop ] )

Adds a Phrase Bigram Field (pf2 parameter) output format: field~slop^boost OR field^boost Slop is optional

参数

field

boost

slop

返回值

SolrDisMaxQuery

范例

示例 #1 SolrDisMaxQuery::addBigramPhraseField example

<?php

$dismaxQuery = new SolrDisMaxQuery("lucene");
$dismaxQuery
    ->addBigramPhraseField('cat', 2, 5.1)
    ->addBigramPhraseField('feature', 4.5)
;
echo $dismaxQuery;

?>

以上例程的输出类似于:

q=lucene&defType=edismax&pf2=cat~5.1^2 feature^4.5

参见

  • SolrDisMaxQuery::removeBigramPhraseField
  • SolrDisMaxQuery::setBigramPhraseFields
  • SolrDisMaxQuery::setBigramPhraseSlop

SolrDisMaxQuery::addBoostQuery

Adds a boost query field with value and optional boost (bq parameter)

说明

public SolrDisMaxQuery SolrDisMaxQuery::addBoostQuery ( string $field , string $value [, string $boost ] )

Adds a Boost Query field with value [and boost] (bq parameter)

参数

field

value

boost

返回值

SolrDisMaxQuery

范例

示例 #1 SolrDisMaxQuery::addBoostQuery example

<?php

$dismaxQuery = new SolrDisMaxQuery("lucene");
$dismaxQuery
    ->addBoostQuery('cat', 'clothing', 2)
    ->addBoostQuery('cat', 'electronics', 5.1)
;
echo $dismaxQuery.PHP_EOL;
?>

以上例程的输出类似于:

q=lucene&defType=edismax&bq=cat:clothing^2 cat:electronics^5.1

参见

  • SolrDisMaxQuery::removeBoostQuery
  • SolrDisMaxQuery::setBoostQuery

SolrDisMaxQuery::addPhraseField

Adds a Phrase Field (pf parameter)

说明

public SolrDisMaxQuery SolrDisMaxQuery::addPhraseField ( string $field , string $boost [, string $slop ] )

Adds a Phrase Field (pf parameter)

参数

field
field name

boost

slop

返回值

SolrDisMaxQuery

范例

示例 #1 SolrDisMaxQuery::addPhraseField example

<?php
$dismaxQuery = new SolrDisMaxQuery("lucene");
$dismaxQuery
    ->addPhraseField('cat', 3, 1)
    ->addPhraseField('third', 4, 2)
    ->addPhraseField('source', 55)
;
echo $dismaxQuery;
?>

以上例程的输出类似于:

q=lucene&defType=edismax&pf=cat~1^3 third~2^4 source^55

参见

  • SolrDisMaxQuery::removePhraseField
  • SolrDisMaxQuery::setPhraseFields

SolrDisMaxQuery::addQueryField

Add a query field with optional boost (qf parameter)

说明

public SolrDisMaxQuery SolrDisMaxQuery::addQueryField ( string $field [, string $boost ] )

Add a query field with optional boost (qf parameter)

参数

field
field name

boost
Boost value. Boosts documents with matching terms.

返回值

SolrDisMaxQuery

范例

示例 #1 SolrDisMaxQuery::addQueryField example

<?php

$dismaxQuery = new SolrDisMaxQuery("lucene");
$dismaxQuery
    ->addQueryField("location", 4)
    ->addQueryField("price")
    ->addQueryField("sku")
    ->addQueryField("title",3.4)
;
echo $dismaxQuery;

?>

以上例程的输出类似于:

q=lucene&defType=edismax&qf=location^4 price sku title^3.4

参见

  • SolrDisMaxQuery::removeQueryField

SolrDisMaxQuery::addTrigramPhraseField

Adds a Trigram Phrase Field (pf3 parameter)

说明

public SolrDisMaxQuery SolrDisMaxQuery::addTrigramPhraseField ( string $field , string $boost [, string $slop ] )

Adds a Trigram Phrase Field (pf3 parameter)

参数

field
Field Name

boost
Field Boost

slop
Field Slop

返回值

SolrDisMaxQuery

范例

示例 #1 SolrDisMaxQuery::addTrigramPhraseField example

<?php

$dismaxQuery = new SolrDisMaxQuery('lucene');
$dismaxQuery
->addTrigramPhraseField('cat', 2, 5.1)
->addTrigramPhraseField('feature', 4.5)
;
echo $dismaxQuery.PHP_EOL;

?>

以上例程会输出:

q=lucene&defType=%s&pf3=cat~5.1^2 feature^4.5

参见

  • SolrDisMaxQuery::removeTrigramPhraseField
  • SolrDisMaxQuery::setTrigramPhraseFields
  • SolrDisMaxQuery::setTrigramPhraseSlop

SolrDisMaxQuery::addUserField

Adds a field to User Fields Parameter (uf)

说明

public SolrDisMaxQuery SolrDisMaxQuery::addUserField ( string $field )

Adds a field to The User Fields Parameter (uf)

参数

field
Field Name

返回值

SolrDisMaxQuery

范例

示例 #1 SolrDisMaxQuery::addUserField example

<?php

$dismaxQuery = new SolrDisMaxQuery('lucene');
$dismaxQuery
->addUserField('cat')
->addUserField('text')
->addUserField('*_dt');

echo $dismaxQuery.PHP_EOL;

?>

以上例程的输出类似于:

q=lucene&defType=edismax&uf=cat text *_dt

参见

  • SolrDisMaxQuery::removeUserField
  • SolrDisMaxQuery::setUserFields

SolrDisMaxQuery::__construct

Class Constructor

说明

public SolrDisMaxQuery::__construct ([ string $q ] )

Class constructor initializes the object and sets the q parameter if passed

参数

q
Search Query (q parameter)

返回值

错误/异常

Emits SolrIllegalArgumentException in case of an invalid parameter was passed.

范例

示例 #1 SolrDisMaxQuery::__construct example

<?php

$dismaxQuery = new SolrDisMaxQuery('lucene');
echo $dismaxQuery;

?>

以上例程会输出:

q=lucene&defType=edismax

参见

SolrDisMaxQuery::removeBigramPhraseField

Removes phrase bigram field (pf2 parameter)

说明

public SolrDisMaxQuery SolrDisMaxQuery::removeBigramPhraseField ( string $field )

Removes a Bigram Phrase Field (pf2 parameter) that was previously added using SolrDisMaxQuery::addBigramPhraseField

参数

field
The Field Name

返回值

SolrDisMaxQuery

范例

示例 #1 SolrDisMaxQuery::removeBigramPhraseField example

<?php

$dismaxQuery = new SolrDisMaxQuery("lucene");
$dismaxQuery
    ->addBigramPhraseField('cat', 2, 5.1)
    ->addBigramPhraseField('feature', 4.5)
;
echo $dismaxQuery.PHP_EOL;

// remove cat from pf2
$dismaxQuery
    ->removeBigramPhraseField('cat');
echo $dismaxQuery.PHP_EOL;

?>

以上例程的输出类似于:

q=lucene&defType=edismax&pf2=cat~5.1^2 feature^4.5
q=lucene&defType=edismax&pf2=feature^4.5

参见

  • SolrDisMaxQuery::addBigramPhraseField
  • SolrDisMaxQuery::setBigramPhraseFields
  • SolrDisMaxQuery::setBigramPhraseSlop

SolrDisMaxQuery::removeBoostQuery

Removes a boost query partial by field name (bq)

说明

public SolrDisMaxQuery SolrDisMaxQuery::removeBoostQuery ( string $field )

Removes a boost query partial from the existing query, only if SolrDisMaxQuery::addBoostQuery was used.

参数

field
Field Name

返回值

SolrDisMaxQuery

范例

示例 #1 SolrDisMaxQuery::removeBoostQuery example

<?php

$dismaxQuery = new SolrDisMaxQuery("lucene");
$dismaxQuery
    ->addBoostQuery('cat', 'electronics', 5.1)
    ->addBoostQuery('cat', 'hard drive')
;
echo $dismaxQuery.PHP_EOL;
// now remove a query part with field 'cat'
$dismaxQuery
->removeBoostQuery('cat');
echo $dismaxQuery . PHP_EOL;

?>

以上例程的输出类似于:

q=lucene&defType=edismax&bq=cat:electronics^5.1 cat:hard drive
q=lucene&defType=edismax&bq=cat:hard drive

参见

  • SolrDisMaxQuery::addBoostQuery
  • SolrDisMaxQuery::setBoostQuery

SolrDisMaxQuery::removePhraseField

Removes a Phrase Field (pf parameter)

说明

public SolrDisMaxQuery SolrDisMaxQuery::removePhraseField ( string $field )

Removes a Phrase Field (pf parameter) that was previously added using SolrDisMaxQuery::addPhraseField

参数

field
Field Name

返回值

SolrDisMaxQuery

范例

示例 #1 SolrDisMaxQuery::removePhraseField example

<?php
$dismaxQuery = new SolrDisMaxQuery('lucene');
$dismaxQuery
    ->addPhraseField('first', 3, 1)
    ->addPhraseField('second', 4, 1)
    ->addPhraseField('cat', 55);
echo $dismaxQuery . PHP_EOL;
echo $dismaxQuery->removePhraseField('second');
?>

以上例程的输出类似于:

q=lucene&defType=edismax&pf=first~1^3 second~1^4 cat^55
q=lucene&defType=edismax&pf=first~1^3 cat^55

参见

  • SolrDisMaxQuery::addPhraseField
  • SolrDisMaxQuery::setPhraseFields

SolrDisMaxQuery::removeQueryField

Removes a Query Field (qf parameter)

说明

public SolrDisMaxQuery SolrDisMaxQuery::removeQueryField ( string $field )

Removes a Query Field (qf parameter) from the field list added by SolrDisMaxQuery::addQueryField

qf: When building DisjunctionMaxQueries from the user's query it specifies the fields to search in, and boosts for those fields.

参数

field
Field Name

返回值

SolrDisMaxQuery

范例

示例 #1 SolrDisMaxQuery::removeQueryField example

<?php

$dismaxQuery = new SolrDisMaxQuery('lucene');
$dismaxQuery
    ->addQueryField('first', 3)
    ->addQueryField('second', 0.2)
    ->addQueryField('cat');
echo $dismaxQuery . PHP_EOL;
// remove field 'second'
echo $dismaxQuery->removeQueryField('second');
?>

以上例程的输出类似于:

q=lucene&defType=edismax&qf=first^3 second^0.2 cat
q=lucene&defType=edismax&qf=first^3 cat

参见

  • SolrDisMaxQuery::addQueryField

SolrDisMaxQuery::removeTrigramPhraseField

Removes a Trigram Phrase Field (pf3 parameter)

说明

public SolrDisMaxQuery SolrDisMaxQuery::removeTrigramPhraseField ( string $field )

Removes a Trigram Phrase Field (pf3 parameter)

参数

field
Field Name

返回值

SolrDisMaxQuery

范例

示例 #1 SolrDisMaxQuery::removeTrigramPhraseField example

<?php

$dismaxQuery = new SolrDisMaxQuery('lucene');
$dismaxQuery
->addTrigramPhraseField('cat', 2, 5.1)
->addTrigramPhraseField('feature', 4.5)
;
echo $dismaxQuery.PHP_EOL;
// reverse
$dismaxQuery
->removeTrigramPhraseField('cat');
echo $dismaxQuery.PHP_EOL;

?>

以上例程会输出:

q=lucene&defType=%s&pf3=cat~5.1^2 feature^4.5
q=lucene&defType=%s&pf3=feature^4.5

参见

  • SolrDisMaxQuery::addTrigramPhraseField
  • SolrDisMaxQuery::setTrigramPhraseFields
  • SolrDisMaxQuery::setTrigramPhraseSlop

SolrDisMaxQuery::removeUserField

Removes a field from The User Fields Parameter (uf)

说明

public SolrDisMaxQuery SolrDisMaxQuery::removeUserField ( string $field )

Removes a field from The User Fields Parameter (uf)

Warning

本函数还未编写文档,仅有参数列表。

参数

field
Field Name

返回值

SolrDisMaxQuery

范例

示例 #1 SolrDisMaxQuery::removeUserField example

<?php

$dismaxQuery = new SolrDisMaxQuery('lucene');
$dismaxQuery
->addUserField('cat')
->addUserField('text')
->addUserField('*_dt')
;
echo $dismaxQuery.PHP_EOL;

// remove field named 'text'
$dismaxQuery
->removeUserField('text');
echo $dismaxQuery.PHP_EOL;

?>

以上例程的输出类似于:

q=lucene&defType=%s&uf=cat text *_dt
q=lucene&defType=%s&uf=cat *_dt

参见

  • SolrDisMaxQuery::addUserField
  • SolrDisMaxQuery::setUserFields

SolrDisMaxQuery::setBigramPhraseFields

Sets Bigram Phrase Fields and their boosts (and slops) using pf2 parameter

说明

public SolrDisMaxQuery SolrDisMaxQuery::setBigramPhraseFields ( string $fields )

Sets Bigram Phrase Fields (pf2) and their boosts (and slops)

参数

fields
Fields boosts (slops)

返回值

SolrDisMaxQuery

范例

示例 #1 SolrDisMaxQuery::setBigramPhraseFields example

<?php
$dismaxQuery = new SolrDisMaxQuery("lucene");
$dismaxQuery->setBigramPhraseFields("cat~5.1^2 feature^4.5");
echo $dismaxQuery.PHP_EOL;

?>

以上例程的输出类似于:

q=lucene&defType=edismax&pf2=cat~5.1^2 feature^4.5

参见

  • SolrDisMaxQuery::setBigramPhraseSlop
  • SolrDisMaxQuery::addBigramPhraseFields
  • SolrDisMaxQuery::removeBigramPhraseField
  • SolrDisMaxQuery::setTrigramPhraseFields

SolrDisMaxQuery::setBigramPhraseSlop

Sets Bigram Phrase Slop (ps2 parameter)

说明

public SolrDisMaxQuery SolrDisMaxQuery::setBigramPhraseSlop ( string $slop )

Sets Bigram Phrase Slop (ps2 parameter). A default slop for Bigram phrase fields.

参数

slop

返回值

SolrDisMaxQuery

范例

示例 #1 SolrDisMaxQuery::setBigramPhraseSlop example

<?php

$dismaxQuery = new SolrDisMaxQuery('lucene');

$dismaxQuery->setBigramPhraseSlop(5);
echo $dismaxQuery.PHP_EOL;

?>

以上例程的输出类似于:

q=lucene&defType=edismax&ps2=5

参见

SolrDisMaxQuery::setBoostFunction

Sets a Boost Function (bf parameter)

说明

public SolrDisMaxQuery SolrDisMaxQuery::setBoostFunction ( string $function )

Sets Boost Function (bf parameter).

Functions (with optional boosts) that will be included in the user's query to influence the score. Any function supported natively by Solr can be used, along with a boost value. e.g.:

recip(rord(myfield),1,2,3)^1.5

参数

function

返回值

SolrDisMaxQuery

范例

示例 #1 SolrDisMaxQuery::setBoostFunction example

<?php

$dismaxQuery = new SolrDisMaxQuery('lucene');

$boostRecentDocsFunction = "recip(ms(NOW,mydatefield),3.16e-11,1,1)";
$dismaxQuery->setBoostFunction($boostRecentDocsFunction);

echo $dismaxQuery.PHP_EOL;

?>

以上例程的输出类似于:

q=lucene&defType=edismax&bf=recip(ms(NOW,mydatefield),3.16e-11,1,1)

参见

SolrDisMaxQuery::setBoostQuery

Directly Sets Boost Query Parameter (bq)

说明

public SolrDisMaxQuery SolrDisMaxQuery::setBoostQuery ( string $q )

Sets Boost Query Parameter (bq)

参数

q
query

返回值

SolrDisMaxQuery

范例

示例 #1 SolrDisMaxQuery::setBoostQuery example

<?php
$dismaxQuery = new SolrDisMaxQuery("lucene");

$dismaxQuery->setBoostQuery('cat:electronics manu:local^2');
echo $dismaxQuery.PHP_EOL;
?>

以上例程的输出类似于:

q=lucene&defType=edismax&bq=cat:electronics manu:local^2

参见

  • SolrDisMaxQuery::addBoostQuery
  • SolrDisMaxQuery::removeBoostQuery

SolrDisMaxQuery::setMinimumMatch

Set Minimum "Should" Match (mm)

说明

public SolrDisMaxQuery SolrDisMaxQuery::setMinimumMatch ( string $value )

Set Minimum "Should" Match parameter (mm). If the default query operator is AND then mm=100%, if the default query operator (q.op) is OR, then mm=0%.

参数

value
Minimum match value/expression

返回值

SolrDisMaxQuery

范例

示例 #1 SolrDisMaxQuery::setMinimumMatch example

<?php

$dismaxQuery = new SolrDisMaxQuery("lucene");
// 75% of the query clauses must match
$dismaxQuery->setMinimumMatch("75%");
echo $dismaxQuery . PHP_EOL;

?>

以上例程会输出:

q=lucene&defType=edismax&mm=75%

SolrDisMaxQuery::setPhraseFields

Sets Phrase Fields and their boosts (and slops) using pf2 parameter

说明

public SolrDisMaxQuery SolrDisMaxQuery::setPhraseFields ( string $fields )

Sets Phrase Fields (pf) and their boosts (and slops)

参数

fields
Fields, boosts [, slops]

返回值

SolrDisMaxQuery

范例

示例 #1 SolrDisMaxQuery::setPhraseFields example

<?php
$dismaxQuery = new SolrDisMaxQuery("lucene");
$dismaxQuery->setPhraseFields("cat~5.1^2 feature^4.5");
echo $dismaxQuery.PHP_EOL;

?>

以上例程的输出类似于:

q=lucene&defType=edismax&pf=cat~5.1^2 feature^4.5

参见

  • SolrDisMaxQuery::addPhraseFields
  • SolrDisMaxQuery::removePhraseField

SolrDisMaxQuery::setPhraseSlop

Sets the default slop on phrase queries (ps parameter)

说明

public SolrDisMaxQuery SolrDisMaxQuery::setPhraseSlop ( string $slop )

Sets the default amount of slop on phrase queries built with "pf", "pf2" and/or "pf3" fields (affects boosting). "ps" parameter

参数

slop

返回值

SolrDisMaxQuery

范例

示例 #1 SolrDisMaxQuery::setPhraseSlop example

<?php

$dismaxQuery = new SolrDisMaxQuery('lucene');

$dismaxQuery->setPhraseSlop(4);
echo $dismaxQuery.PHP_EOL;

?>

以上例程会输出:

q=lucene&defType=edismax&ps=4

参见

SolrDisMaxQuery::setQueryAlt

Set Query Alternate (q.alt parameter)

说明

public SolrDisMaxQuery SolrDisMaxQuery::setQueryAlt ( string $q )

Set Query Alternate (q.alt parameter)

When the main q parameter is not specified or is blank. The q.alt parameter is used

参数

q
Query String

返回值

SolrDisMaxQuery

范例

示例 #1 SolrDisMaxQuery::setQueryAlt example

<?php

$dismaxQuery = new DisMaxQuery();
$dismaxQuery->setQueryAlt('*:*');

?>

以上例程的输出类似于:

defType=edismax&q.alt=*:*&q=

SolrDisMaxQuery::setQueryPhraseSlop

Specifies the amount of slop permitted on phrase queries explicitly included in the user's query string (qf parameter)

说明

public SolrDisMaxQuery SolrDisMaxQuery::setQueryPhraseSlop ( string $slop )

The Query Phrase Slop is the amount of slop permitted on phrase queries explicitly included in the user's query string with the qf parameter.

slop refers to the number of positions one token needs to be moved in relation to another token in order to match a phrase specified in a query.

参数

slop
Amount of slop

返回值

SolrDisMaxQuery

范例

示例 #1 SolrDisMaxQuery::setQueryPhraseSlop example

<?php

$dismaxQuery = new SolrDisMaxQuery();
$dismaxQuery->setQueryPhraseSlop(3);
echo $dismaxQuery;
?>

以上例程的输出类似于:

defType=edismax&qs=3

SolrDisMaxQuery::setTieBreaker

Sets Tie Breaker parameter (tie parameter)

说明

public SolrDisMaxQuery SolrDisMaxQuery::setTieBreaker ( string $tieBreaker )

Sets Tie Breaker parameter (tie parameter)

参数

tieBreaker
The tie parameter specifies a float value (which should be something much less than 1) to use as tiebreaker in DisMax queries.

返回值

SolrDisMaxQuery

范例

示例 #1 SolrDisMaxQuery::setTieBreaker example

<?php

$dismaxQuery = new SolrDisMaxQuery();
$dismaxQuery->setTieBreaker(0.1);

echo $dismaxQuery;

?>

以上例程会输出:

defType=edismax&tie=0.1

SolrDisMaxQuery::setTrigramPhraseFields

Directly Sets Trigram Phrase Fields (pf3 parameter)

说明

public SolrDisMaxQuery SolrDisMaxQuery::setTrigramPhraseFields ( string $fields )

Directly Sets Trigram Phrase Fields (pf3 parameter)

参数

fields
Trigram Phrase Fields

返回值

SolrDisMaxQuery

范例

示例 #1 SolrDisMaxQuery::setTrigramPhraseFields example

<?php

$dismaxQuery = new SolrDisMaxQuery('lucene');
$dismaxQuery->setTrigramPhraseFields('cat~5.1^2 feature^4.5');
echo $dismaxQuery.PHP_EOL;

?>

以上例程会输出:

q=lucene&defType=edismax&pf3=cat~5.1^2 feature^4.5

参见

  • SolrDisMaxQuery::addTrigramPhraseField
  • SolrDisMaxQuery::removeTrigramPhraseField
  • SolrDisMaxQuery::setTrigramPhraseSlop

SolrDisMaxQuery::setTrigramPhraseSlop

Sets Trigram Phrase Slop (ps3 parameter)

说明

public SolrDisMaxQuery SolrDisMaxQuery::setTrigramPhraseSlop ( string $slop )

Sets Trigram Phrase Slop (ps3 parameter)

参数

slop
Phrase slop

返回值

SolrDisMaxQuery

范例

示例 #1 SolrDisMaxQuery::setTrigramPhraseSlop example

<?php

$dismaxQuery = new SolrDisMaxQuery('lucene');
$dismaxQuery->setTrigramPhraseSlop(2);
echo $dismaxQuery.PHP_EOL;

?>

以上例程的输出类似于:

q=lucene&defType=edismax&ps3=2

参见

  • SolrDisMaxQuery::addTrigramPhraseField
  • SolrDisMaxQuery::removeTrigramPhraseField
  • SolrDisMaxQuery::setTrigramPhraseFields

SolrDisMaxQuery::setUserFields

Sets User Fields parameter (uf)

说明

public SolrDisMaxQuery SolrDisMaxQuery::setUserFields ( string $fields )

Sets User Fields parameter (uf)

User Fields: Specifies which schema fields the end user shall be allowed to query.

参数

fields
Fields names separated by space

This parameter supports wildcards.

返回值

SolrDisMaxQuery

范例

示例 #1 SolrDisMaxQuery::setUserFields example

<?php

$dismaxQuery = new SolrDisMaxQuery('lucene');
$dismaxQuery->setUserFields('field1 field2 *_txt');
echo $dismaxQuery.PHP_EOL;

?>

以上例程的输出类似于:

q=lucene&defType=edismax&uf=field1 field2 *_txt

参见

  • SolrDisMaxQuery::addUserField
  • SolrDisMaxQuery::removeUserField

SolrDisMaxQuery::useDisMaxQueryParser

Switch QueryParser to be DisMax Query Parser

说明

public SolrDisMaxQuery SolrDisMaxQuery::useDisMaxQueryParser ( void )

Switch QueryParser to be DisMax Query Parser

参数

此函数没有参数。

返回值

SolrDisMaxQuery

范例

示例 #1 SolrDisMaxQuery::useDisMaxQueryParser example

<?php

$dismaxQuery = new SolrDisMaxQuery();
$dismaxQuery->useDisMaxQueryParser();
echo $dismaxQuery;
?>

以上例程的输出类似于:

defType=dismax

参见

  • SolrDisMaxQuery::useDisMaxQueryParser

SolrDisMaxQuery::useEDisMaxQueryParser

Switch QueryParser to be EDisMax

说明

public SolrDisMaxQuery SolrDisMaxQuery::useEDisMaxQueryParser ( void )

Switch QueryParser to be EDisMax. By default the query builder uses edismax, if it was switched using SolrDisMaxQuery::useDisMaxQueryParser, it can be switched back using this method.

参数

此函数没有参数。

返回值

SolrDisMaxQuery

范例

示例 #1 SolrDisMaxQuery::useEDisMaxQueryParser example

<?php

$dismaxQuery = new SolrDisMaxQuery();
$dismaxQuery->useEDisMaxQueryParser();
echo $dismaxQuery;

?>

以上例程的输出类似于:

defType=edismax

参见

简介

类摘要

SolrCollapseFunction

class SolrCollapseFunction {

/* Constants */

const string SolrCollapseFunction::NULLPOLICY_IGNORE = ignore ;

const string SolrCollapseFunction::NULLPOLICY_EXPAND = expand ;

const string SolrCollapseFunction::NULLPOLICY_COLLAPSE = collapse ;

/* 方法 */

public __construct ([ string $field ] )

public string getField ( void )

public string getHint ( void )

public string getMax ( void )

public string getMin ( void )

public string getNullPolicy ( void )

public int getSize ( void )

public SolrCollapseFunction setField ( string $fieldName )

public SolrCollapseFunction setHint ( string $hint )

public SolrCollapseFunction setMax ( string $max )

public SolrCollapseFunction setMin ( string $min )

public SolrCollapseFunction setNullPolicy ( string $nullPolicy )

public SolrCollapseFunction setSize ( int $size )

public string __toString ( void )

}

预定义常量

SolrCollapseFunction::NULLPOLICY_IGNORE

SolrCollapseFunction::NULLPOLICY_EXPAND

SolrCollapseFunction::NULLPOLICY_COLLAPSE

SolrCollapseFunction::__construct

Constructor

说明

public SolrCollapseFunction::__construct ([ string $field ] )

Collapse Function constructor

参数

field
The field name to collapse on.

In order to collapse a result. The field type must be a single valued String, Int or Float.

范例

示例 #1 SolrCollapseFunction::__construct example

<?php

include "bootstrap.php";

$options = array
(
    'hostname' => SOLR_SERVER_HOSTNAME,
    'login'    => SOLR_SERVER_USERNAME,
    'password' => SOLR_SERVER_PASSWORD,
    'port'     => SOLR_SERVER_PORT,
    'path'     => SOLR_SERVER_PATH
);

$client = new SolrClient($options);

$query = new SolrQuery('*:*');

$func = new SolrCollapseFunction('field_name');

$func->setMax('sum(cscore(),field(some_other_field))');
$func->setSize(100);
$func->setNullPolicy(SolrCollapseFunction::NULLPOLICY_EXPAND);

$query->collapse($func);

$queryResponse = $client->query($query);

$response = $queryResponse->getResponse();

print_r($response);

?>

参见

  • SolrQuery::collapse

SolrCollapseFunction::getField

Returns the field that is being collapsed on

说明

public string SolrCollapseFunction::getField ( void )

Returns the field that is being collapsed on.

参数

此函数没有参数。

返回值

参见

  • SolrCollapseFunction::setField

SolrCollapseFunction::getHint

Returns collapse hint

说明

public string SolrCollapseFunction::getHint ( void )

Returns collapse hint

参数

此函数没有参数。

返回值

参见

  • SolrCollapseFunction::setHint

SolrCollapseFunction::getMax

Returns max parameter

说明

public string SolrCollapseFunction::getMax ( void )

Returns max parameter

参数

此函数没有参数。

返回值

参见

  • SolrCollapseFunction::setMax

SolrCollapseFunction::getMin

Returns min parameter

说明

public string SolrCollapseFunction::getMin ( void )

Returns min parameter

参数

此函数没有参数。

返回值

参见

  • SolrCollapseFunction::setMin

SolrCollapseFunction::getNullPolicy

Returns null policy

说明

public string SolrCollapseFunction::getNullPolicy ( void )

Returns null policy used or null

参数

此函数没有参数。

返回值

参见

  • SolrCollapseFunction::setNullPolicy

SolrCollapseFunction::getSize

Returns size parameter

说明

public int SolrCollapseFunction::getSize ( void )

Gets the initial size of the collapse data structures when collapsing on a numeric field only

参数

此函数没有参数。

返回值

参见

  • SolrCollapseFunction::setSize

SolrCollapseFunction::setField

Sets the field to collapse on

说明

public SolrCollapseFunction SolrCollapseFunction::setField ( string $fieldName )

The field name to collapse on. In order to collapse a result. The field type must be a single valued String, Int or Float.

参数

fieldName

返回值

SolrCollapseFunction

SolrCollapseFunction::setHint

Sets collapse hint

说明

public SolrCollapseFunction SolrCollapseFunction::setHint ( string $hint )

Sets collapse hint

参数

hint
Currently there is only one hint available "top_fc", which stands for top level FieldCache

返回值

SolrCollapseFunction

范例

示例 #1 SolrCollapseFunction::setHint example

<?php

/* ... */

?>

以上例程的输出类似于:

...

SolrCollapseFunction::setMax

Selects the group heads by the max value of a numeric field or function query

说明

public SolrCollapseFunction SolrCollapseFunction::setMax ( string $max )

Selects the group heads by the max value of a numeric field or function query.

参数

max

返回值

SolrCollapseFunction

范例

示例 #1 SolrCollapseFunction::setMax example

<?php

$func = new SolrCollapseFunction('field_name');

$func->setMax('sum(cscore(),field(some_field))');

$query = new SolrQuery('*:*');

$query->collapse($func);

?>

SolrCollapseFunction::setMin

Sets the initial size of the collapse data structures when collapsing on a numeric field only

说明

public SolrCollapseFunction SolrCollapseFunction::setMin ( string $min )

Sets the initial size of the collapse data structures when collapsing on a numeric field only

参数

min

返回值

SolrCollapseFunction

SolrCollapseFunction::setNullPolicy

Sets the NULL Policy

说明

public SolrCollapseFunction SolrCollapseFunction::setNullPolicy ( string $nullPolicy )

Sets the NULL Policy. One of the 3 policies defined as class constants shall be passed. Accepts ignore, expand, or collapse policies.

参数

nullPolicy

返回值

SolrCollapseFunction

SolrCollapseFunction::setSize

Sets the initial size of the collapse data structures when collapsing on a numeric field only

说明

public SolrCollapseFunction SolrCollapseFunction::setSize ( int $size )

Sets the initial size of the collapse data structures when collapsing on a numeric field only.

参数

size

返回值

SolrCollapseFunction

SolrCollapseFunction::__toString

Returns a string representing the constructed collapse function

说明

public string SolrCollapseFunction::__toString ( void )

Returns a string representing the constructed collapse function

参数

此函数没有参数。

返回值

简介

This is the base class for all exception thrown by the Solr extension classes.

类摘要

SolrException

class SolrException extends Exception {

/* 属性 */

protected integer $sourceline ;

protected string $sourcefile ;

protected string $zif_name ;

/* 继承的属性 */

protected string $message ;

protected int $code ;

protected string $file ;

protected int $line ;

/* 方法 */

public array getInternalInfo ( void )

/* 继承的方法 */

final public string Exception::getMessage ( void )

final public Throwable Exception::getPrevious ( void )

final public int Exception::getCode ( void )

final public string Exception::getFile ( void )

final public int Exception::getLine ( void )

final public array Exception::getTrace ( void )

final public string Exception::getTraceAsString ( void )

public string Exception::__toString ( void )

final private void Exception::__clone ( void )

}

属性

sourceline
The line in c-space source file where exception was generated

sourcefile
The c-space source file where exception was generated

zif_name
The c-space function where exception was generated

SolrException::getInternalInfo

Returns internal information where the Exception was thrown

说明

public array SolrException::getInternalInfo ( void )

Returns internal information where the Exception was thrown.

参数

此函数没有参数。

返回值

Returns an array containing internal information where the error was thrown. Used only for debugging by extension developers.

简介

An exception thrown when there is an error while making a request to the server from the client.

类摘要

SolrClientException

class SolrClientException extends SolrException {

/* 继承的属性 */

protected string $message ;

protected int $code ;

protected string $file ;

protected int $line ;

protected integer $sourceline ;

protected string $sourcefile ;

protected string $zif_name ;

/* 方法 */

public array getInternalInfo ( void )

/* 继承的方法 */

final public string Exception::getMessage ( void )

final public Throwable Exception::getPrevious ( void )

final public int Exception::getCode ( void )

final public string Exception::getFile ( void )

final public int Exception::getLine ( void )

final public array Exception::getTrace ( void )

final public string Exception::getTraceAsString ( void )

public string Exception::__toString ( void )

final private void Exception::__clone ( void )

public array SolrException::getInternalInfo ( void )

}

SolrClientException::getInternalInfo

Returns internal information where the Exception was thrown

说明

public array SolrClientException::getInternalInfo ( void )

Returns internal information where the Exception was thrown.

参数

此函数没有参数。

返回值

Returns an array containing internal information where the error was thrown. Used only for debugging by extension developers.

简介

An exception thrown when there is an error produced by the Solr Server itself.

类摘要

SolrServerException

class SolrServerException extends SolrException {

/* 继承的属性 */

protected string $message ;

protected int $code ;

protected string $file ;

protected int $line ;

protected integer $sourceline ;

protected string $sourcefile ;

protected string $zif_name ;

/* 方法 */

public array getInternalInfo ( void )

/* 继承的方法 */

final public string Exception::getMessage ( void )

final public Throwable Exception::getPrevious ( void )

final public int Exception::getCode ( void )

final public string Exception::getFile ( void )

final public int Exception::getLine ( void )

final public array Exception::getTrace ( void )

final public string Exception::getTraceAsString ( void )

public string Exception::__toString ( void )

final private void Exception::__clone ( void )

public array SolrException::getInternalInfo ( void )

}

SolrServerException::getInternalInfo

Returns internal information where the Exception was thrown

说明

public array SolrServerException::getInternalInfo ( void )

Returns internal information where the Exception was thrown.

参数

此函数没有参数。

返回值

Returns an array containing internal information where the error was thrown. Used only for debugging by extension developers.

简介

This object is thrown when an illegal or invalid argument is passed to a method.

类摘要

SolrIllegalArgumentException

class SolrIllegalArgumentException extends SolrException {

/* 继承的属性 */

protected string $message ;

protected int $code ;

protected string $file ;

protected int $line ;

protected integer $sourceline ;

protected string $sourcefile ;

protected string $zif_name ;

/* 方法 */

public array getInternalInfo ( void )

/* 继承的方法 */

final public string Exception::getMessage ( void )

final public Throwable Exception::getPrevious ( void )

final public int Exception::getCode ( void )

final public string Exception::getFile ( void )

final public int Exception::getLine ( void )

final public array Exception::getTrace ( void )

final public string Exception::getTraceAsString ( void )

public string Exception::__toString ( void )

final private void Exception::__clone ( void )

public array SolrException::getInternalInfo ( void )

}

SolrIllegalArgumentException::getInternalInfo

Returns internal information where the Exception was thrown

说明

public array SolrIllegalArgumentException::getInternalInfo ( void )

Returns internal information where the Exception was thrown.

Warning

本函数还未编写文档,仅有参数列表。

参数

此函数没有参数。

返回值

Returns an array containing internal information where the error was thrown. Used only for debugging by extension developers.

简介

This object is thrown when an illegal or unsupported operation is performed on an object.

类摘要

SolrIllegalOperationException

class SolrIllegalOperationException extends SolrException {

/* 继承的属性 */

protected string $message ;

protected int $code ;

protected string $file ;

protected int $line ;

protected integer $sourceline ;

protected string $sourcefile ;

protected string $zif_name ;

/* 方法 */

public array getInternalInfo ( void )

/* 继承的方法 */

final public string Exception::getMessage ( void )

final public Throwable Exception::getPrevious ( void )

final public int Exception::getCode ( void )

final public string Exception::getFile ( void )

final public int Exception::getLine ( void )

final public array Exception::getTrace ( void )

final public string Exception::getTraceAsString ( void )

public string Exception::__toString ( void )

final private void Exception::__clone ( void )

public array SolrException::getInternalInfo ( void )

}

SolrIllegalOperationException::getInternalInfo

Returns internal information where the Exception was thrown

说明

public array SolrIllegalOperationException::getInternalInfo ( void )

Returns internal information where the Exception was thrown.

Warning

本函数还未编写文档,仅有参数列表。

参数

此函数没有参数。

返回值

Returns an array containing internal information where the error was thrown. Used only for debugging by extension developers.

简介

类摘要

SolrMissingMandatoryParameterException

class SolrMissingMandatoryParameterException extends SolrException {

/* 继承的属性 */

protected string $message ;

protected int $code ;

protected string $file ;

protected int $line ;

protected integer $sourceline ;

protected string $sourcefile ;

protected string $zif_name ;

/* 继承的方法 */

final public string Exception::getMessage ( void )

final public Throwable Exception::getPrevious ( void )

final public int Exception::getCode ( void )

final public string Exception::getFile ( void )

final public int Exception::getLine ( void )

final public array Exception::getTrace ( void )

final public string Exception::getTraceAsString ( void )

public string Exception::__toString ( void )

final private void Exception::__clone ( void )

public array SolrException::getInternalInfo ( void )

}