The SolrQuery class

(PECL solr >= 0.9.2)

Introduction

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

Class synopsis

SolrQuery extends SolrModifiableParams implements Serializable {
/* Constants */
const integer ORDER_ASC = 0 ;
const integer ORDER_DESC = 1 ;
const integer FACET_SORT_INDEX = 0 ;
const integer FACET_SORT_COUNT = 1 ;
const integer TERMS_SORT_INDEX = 0 ;
const integer TERMS_SORT_COUNT = 1 ;
/* Properties */
/* Methods */
public addExpandFilterQuery ( string $fq ) : SolrQuery
public addExpandSortField ( string $field [, string $order ] ) : SolrQuery
public addFacetDateField ( string $dateField ) : SolrQuery
public addFacetDateOther ( string $value [, string $field_override ] ) : SolrQuery
public addFacetField ( string $field ) : SolrQuery
public addFacetQuery ( string $facetQuery ) : SolrQuery
public addField ( string $field ) : SolrQuery
public addFilterQuery ( string $fq ) : SolrQuery
public addGroupField ( string $value ) : SolrQuery
public addGroupFunction ( string $value ) : SolrQuery
public addGroupQuery ( string $value ) : SolrQuery
public addGroupSortField ( string $field [, int $order ] ) : SolrQuery
public addHighlightField ( string $field ) : SolrQuery
public addMltField ( string $field ) : SolrQuery
public addMltQueryField ( string $field , float $boost ) : SolrQuery
public addSortField ( string $field [, int $order = SolrQuery::ORDER_DESC ] ) : SolrQuery
public addStatsFacet ( string $field ) : SolrQuery
public addStatsField ( string $field ) : SolrQuery
public collapse ( SolrCollapseFunction $collapseFunction ) : SolrQuery
public __construct ([ string $q ] )
public __destruct ( void ) : void
public getExpand ( void ) : bool
public getExpandFilterQueries ( void ) : array
public getExpandQuery ( void ) : array
public getExpandRows ( void ) : int
public getExpandSortFields ( void ) : array
public getFacet ( void ) : bool
public getFacetDateEnd ([ string $field_override ] ) : string
public getFacetDateFields ( void ) : array
public getFacetDateGap ([ string $field_override ] ) : string
public getFacetDateHardEnd ([ string $field_override ] ) : string
public getFacetDateOther ([ string $field_override ] ) : array
public getFacetDateStart ([ string $field_override ] ) : string
public getFacetFields ( void ) : array
public getFacetLimit ([ string $field_override ] ) : int
public getFacetMethod ([ string $field_override ] ) : string
public getFacetMinCount ([ string $field_override ] ) : int
public getFacetMissing ([ string $field_override ] ) : bool
public getFacetOffset ([ string $field_override ] ) : int
public getFacetPrefix ([ string $field_override ] ) : string
public getFacetQueries ( void ) : array
public getFacetSort ([ string $field_override ] ) : int
public getFields ( void ) : array
public getFilterQueries ( void ) : array
public getGroup ( void ) : bool
public getGroupCachePercent ( void ) : int
public getGroupFacet ( void ) : bool
public getGroupFields ( void ) : array
public getGroupFormat ( void ) : string
public getGroupFunctions ( void ) : array
public getGroupLimit ( void ) : int
public getGroupMain ( void ) : bool
public getGroupNGroups ( void ) : bool
public getGroupOffset ( void ) : int
public getGroupQueries ( void ) : array
public getGroupSortFields ( void ) : array
public getGroupTruncate ( void ) : bool
public getHighlight ( void ) : bool
public getHighlightAlternateField ([ string $field_override ] ) : string
public getHighlightFields ( void ) : array
public getHighlightFormatter ([ string $field_override ] ) : string
public getHighlightFragmenter ([ string $field_override ] ) : string
public getHighlightFragsize ([ string $field_override ] ) : int
public getHighlightHighlightMultiTerm ( void ) : bool
public getHighlightMaxAlternateFieldLength ([ string $field_override ] ) : int
public getHighlightMaxAnalyzedChars ( void ) : int
public getHighlightMergeContiguous ([ string $field_override ] ) : bool
public getHighlightRegexMaxAnalyzedChars ( void ) : int
public getHighlightRegexPattern ( void ) : string
public getHighlightRegexSlop ( void ) : float
public getHighlightRequireFieldMatch ( void ) : bool
public getHighlightSimplePost ([ string $field_override ] ) : string
public getHighlightSimplePre ([ string $field_override ] ) : string
public getHighlightSnippets ([ string $field_override ] ) : int
public getHighlightUsePhraseHighlighter ( void ) : bool
public getMlt ( void ) : bool
public getMltBoost ( void ) : bool
public getMltCount ( void ) : int
public getMltFields ( void ) : array
public getMltMaxNumQueryTerms ( void ) : int
public getMltMaxNumTokens ( void ) : int
public getMltMaxWordLength ( void ) : int
public getMltMinDocFrequency ( void ) : int
public getMltMinTermFrequency ( void ) : int
public getMltMinWordLength ( void ) : int
public getMltQueryFields ( void ) : array
public getQuery ( void ) : string
public getRows ( void ) : int
public getSortFields ( void ) : array
public getStart ( void ) : int
public getStats ( void ) : bool
public getStatsFacets ( void ) : array
public getStatsFields ( void ) : array
public getTerms ( void ) : bool
public getTermsField ( void ) : string
public getTermsIncludeLowerBound ( void ) : bool
public getTermsIncludeUpperBound ( void ) : bool
public getTermsLimit ( void ) : int
public getTermsLowerBound ( void ) : string
public getTermsMaxCount ( void ) : int
public getTermsMinCount ( void ) : int
public getTermsPrefix ( void ) : string
public getTermsReturnRaw ( void ) : bool
public getTermsSort ( void ) : int
public getTermsUpperBound ( void ) : string
public getTimeAllowed ( void ) : int
public removeExpandFilterQuery ( string $fq ) : SolrQuery
public removeExpandSortField ( string $field ) : SolrQuery
public removeFacetDateField ( string $field ) : SolrQuery
public removeFacetDateOther ( string $value [, string $field_override ] ) : SolrQuery
public removeFacetField ( string $field ) : SolrQuery
public removeFacetQuery ( string $value ) : SolrQuery
public removeField ( string $field ) : SolrQuery
public removeFilterQuery ( string $fq ) : SolrQuery
public removeHighlightField ( string $field ) : SolrQuery
public removeMltField ( string $field ) : SolrQuery
public removeMltQueryField ( string $queryField ) : SolrQuery
public removeSortField ( string $field ) : SolrQuery
public removeStatsFacet ( string $value ) : SolrQuery
public removeStatsField ( string $field ) : SolrQuery
public setEchoHandler ( bool $flag ) : SolrQuery
public setEchoParams ( string $type ) : SolrQuery
public setExpand ( bool $value ) : SolrQuery
public setExpandQuery ( string $q ) : SolrQuery
public setExpandRows ( int $value ) : SolrQuery
public setExplainOther ( string $query ) : SolrQuery
public setFacet ( bool $flag ) : SolrQuery
public setFacetDateEnd ( string $value [, string $field_override ] ) : SolrQuery
public setFacetDateGap ( string $value [, string $field_override ] ) : SolrQuery
public setFacetDateHardEnd ( bool $value [, string $field_override ] ) : SolrQuery
public setFacetDateStart ( string $value [, string $field_override ] ) : SolrQuery
public setFacetEnumCacheMinDefaultFrequency ( int $frequency [, string $field_override ] ) : SolrQuery
public setFacetLimit ( int $limit [, string $field_override ] ) : SolrQuery
public setFacetMethod ( string $method [, string $field_override ] ) : SolrQuery
public setFacetMinCount ( int $mincount [, string $field_override ] ) : SolrQuery
public setFacetMissing ( bool $flag [, string $field_override ] ) : SolrQuery
public setFacetOffset ( int $offset [, string $field_override ] ) : SolrQuery
public setFacetPrefix ( string $prefix [, string $field_override ] ) : SolrQuery
public setFacetSort ( int $facetSort [, string $field_override ] ) : SolrQuery
public setGroup ( bool $value ) : SolrQuery
public setGroupCachePercent ( int $percent ) : SolrQuery
public setGroupFacet ( bool $value ) : SolrQuery
public setGroupFormat ( string $value ) : SolrQuery
public setGroupLimit ( int $value ) : SolrQuery
public setGroupMain ( string $value ) : SolrQuery
public setGroupNGroups ( bool $value ) : SolrQuery
public setGroupOffset ( int $value ) : SolrQuery
public setGroupTruncate ( bool $value ) : SolrQuery
public setHighlight ( bool $flag ) : SolrQuery
public setHighlightAlternateField ( string $field [, string $field_override ] ) : SolrQuery
public setHighlightFormatter ( string $formatter [, string $field_override ] ) : SolrQuery
public setHighlightFragmenter ( string $fragmenter [, string $field_override ] ) : SolrQuery
public setHighlightFragsize ( int $size [, string $field_override ] ) : SolrQuery
public setHighlightHighlightMultiTerm ( bool $flag ) : SolrQuery
public setHighlightMaxAlternateFieldLength ( int $fieldLength [, string $field_override ] ) : SolrQuery
public setHighlightMaxAnalyzedChars ( int $value ) : SolrQuery
public setHighlightMergeContiguous ( bool $flag [, string $field_override ] ) : SolrQuery
public setHighlightRegexMaxAnalyzedChars ( int $maxAnalyzedChars ) : SolrQuery
public setHighlightRegexPattern ( string $value ) : SolrQuery
public setHighlightRegexSlop ( float $factor ) : SolrQuery
public setHighlightRequireFieldMatch ( bool $flag ) : SolrQuery
public setHighlightSimplePost ( string $simplePost [, string $field_override ] ) : SolrQuery
public setHighlightSimplePre ( string $simplePre [, string $field_override ] ) : SolrQuery
public setHighlightSnippets ( int $value [, string $field_override ] ) : SolrQuery
public setMlt ( bool $flag ) : SolrQuery
public setMltBoost ( bool $flag ) : SolrQuery
public setMltCount ( int $count ) : SolrQuery
public setMltMaxNumQueryTerms ( int $value ) : SolrQuery
public setMltMaxNumTokens ( int $value ) : SolrQuery
public setMltMaxWordLength ( int $maxWordLength ) : SolrQuery
public setMltMinDocFrequency ( int $minDocFrequency ) : SolrQuery
public setMltMinTermFrequency ( int $minTermFrequency ) : SolrQuery
public setMltMinWordLength ( int $minWordLength ) : SolrQuery
public setOmitHeader ( bool $flag ) : SolrQuery
public setQuery ( string $query ) : SolrQuery
public setRows ( int $rows ) : SolrQuery
public setShowDebugInfo ( bool $flag ) : SolrQuery
public setStart ( int $start ) : SolrQuery
public setStats ( bool $flag ) : SolrQuery
public setTerms ( bool $flag ) : SolrQuery
public setTermsField ( string $fieldname ) : SolrQuery
public setTermsIncludeLowerBound ( bool $flag ) : SolrQuery
public setTermsIncludeUpperBound ( bool $flag ) : SolrQuery
public setTermsLimit ( int $limit ) : SolrQuery
public setTermsLowerBound ( string $lowerBound ) : SolrQuery
public setTermsMaxCount ( int $frequency ) : SolrQuery
public setTermsMinCount ( int $frequency ) : SolrQuery
public setTermsPrefix ( string $prefix ) : SolrQuery
public setTermsReturnRaw ( bool $flag ) : SolrQuery
public setTermsSort ( int $sortType ) : SolrQuery
public setTermsUpperBound ( string $upperBound ) : SolrQuery
public setTimeAllowed ( int $timeAllowed ) : SolrQuery
/* Inherited methods */
public SolrModifiableParams::__destruct ( void ) : void
}

Predefined Constants

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

Table of Contents

add a note add a note

User Contributed Notes 1 note

up
2
andy at borkedcoder dot com
6 years ago
Note - if using morelikethis, and your query is on a numeric ID, then you will not be able to access the moreLikeThis object in the results...

when q=id:3493 searching with mlt, result is:

SolrObject Object
(
...
    [moreLikeThis] => SolrObject Object
        (
            [3493] => SolrObject Object
                (
                    [numFound] => 6286
                    [start] => 0
                    [docs] => Array
                        (
....etc

the numeric object name (3493 above) is impossible to access

not by $response->moreLikeThis->{3493} nor $response->moreLikeThis->{'3493'}, nothing...

only way is to convert the moreLikeThis object into an array with:
$response_array = (array) $response->moreLikeThis;

then iterate the array as the array key is known.
To Top