SolrQuery::collapse
(Информация о версии неизвестна, возможно, только в SVN)
SolrQuery::collapse — Collapses the result set to a single document per group
Описание
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 ) ) ) )
- PHP Руководство
- Функции по категориям
- Индекс функций
- Справочник функций
- Расширения для работы с поисковыми системами
- Apache Solr
- SolrQuery::addExpandFilterQuery
- SolrQuery::addExpandSortField
- Функция SolrQuery::addFacetDateField() - Maps to facet.date
- Функция SolrQuery::addFacetDateOther() - Adds another facet.date.other parameter
- Функция SolrQuery::addFacetField() - Adds another field to the facet
- Функция SolrQuery::addFacetQuery() - Adds a facet query
- Функция SolrQuery::addField() - Specifies which fields to return in the result
- Функция SolrQuery::addFilterQuery() - Specifies a filter query
- SolrQuery::addGroupField
- SolrQuery::addGroupFunction
- SolrQuery::addGroupQuery
- SolrQuery::addGroupSortField
- Функция SolrQuery::addHighlightField() - Maps to hl.fl
- Функция SolrQuery::addMltField() - Sets a field to use for similarity
- Функция SolrQuery::addMltQueryField() - Maps to mlt.qf
- Функция SolrQuery::addSortField() - Used to control how the results should be sorted
- Функция SolrQuery::addStatsFacet() - Requests a return of sub results for values within the given facet
- Функция SolrQuery::addStatsField() - Maps to stats.field parameter
- SolrQuery::collapse
- Функция SolrQuery::__construct() - Constructor
- Функция SolrQuery::__destruct() - Destructor
- SolrQuery::getExpand
- SolrQuery::getExpandFilterQueries
- SolrQuery::getExpandQuery
- SolrQuery::getExpandRows
- SolrQuery::getExpandSortFields
- Функция SolrQuery::getFacet() - Returns the value of the facet parameter
- Функция SolrQuery::getFacetDateEnd() - Returns the value for the facet.date.end parameter
- Функция SolrQuery::getFacetDateFields() - Returns all the facet.date fields
- Функция SolrQuery::getFacetDateGap() - Returns the value of the facet.date.gap parameter
- Функция SolrQuery::getFacetDateHardEnd() - Returns the value of the facet.date.hardend parameter
- Функция SolrQuery::getFacetDateOther() - Returns the value for the facet.date.other parameter
- Функция SolrQuery::getFacetDateStart() - Returns the lower bound for the first date range for all date faceting on this field
- Функция SolrQuery::getFacetFields() - Returns all the facet fields
- Функция SolrQuery::getFacetLimit() - Returns the maximum number of constraint counts that should be returned for the facet fields
- Функция SolrQuery::getFacetMethod() - Returns the value of the facet.method parameter
- Функция SolrQuery::getFacetMinCount() - Returns the minimum counts for facet fields should be included in the response
- Функция SolrQuery::getFacetMissing() - Returns the current state of the facet.missing parameter
- Функция SolrQuery::getFacetOffset() - Returns an offset into the list of constraints to be used for pagination
- Функция SolrQuery::getFacetPrefix() - Returns the facet prefix
- Функция SolrQuery::getFacetQueries() - Returns all the facet queries
- Функция SolrQuery::getFacetSort() - Returns the facet sort type
- Функция SolrQuery::getFields() - Returns the list of fields that will be returned in the response
- Функция SolrQuery::getFilterQueries() - Returns an array of filter queries
- SolrQuery::getGroup
- SolrQuery::getGroupCachePercent
- SolrQuery::getGroupFacet
- SolrQuery::getGroupFields
- SolrQuery::getGroupFormat
- SolrQuery::getGroupFunctions
- SolrQuery::getGroupLimit
- SolrQuery::getGroupMain
- SolrQuery::getGroupNGroups
- SolrQuery::getGroupOffset
- SolrQuery::getGroupQueries
- SolrQuery::getGroupSortFields
- SolrQuery::getGroupTruncate
- Функция SolrQuery::getHighlight() - Returns the state of the hl parameter
- Функция SolrQuery::getHighlightAlternateField() - Returns the highlight field to use as backup or default
- Функция SolrQuery::getHighlightFields() - Returns all the fields that Solr should generate highlighted snippets for
- Функция SolrQuery::getHighlightFormatter() - Returns the formatter for the highlighted output
- Функция SolrQuery::getHighlightFragmenter() - Returns the text snippet generator for highlighted text
- Функция SolrQuery::getHighlightFragsize() - Returns the number of characters of fragments to consider for highlighting
- Функция SolrQuery::getHighlightHighlightMultiTerm() - Returns whether or not to enable highlighting for range/wildcard/fuzzy/prefix queries
- Функция SolrQuery::getHighlightMaxAlternateFieldLength() - Returns the maximum number of characters of the field to return
- Функция SolrQuery::getHighlightMaxAnalyzedChars() - Returns the maximum number of characters into a document to look for suitable snippets
- Функция SolrQuery::getHighlightMergeContiguous() - Returns whether or not the collapse contiguous fragments into a single fragment
- Функция SolrQuery::getHighlightRegexMaxAnalyzedChars() - Returns the maximum number of characters from a field when using the regex fragmenter
- Функция SolrQuery::getHighlightRegexPattern() - Returns the regular expression for fragmenting
- Функция SolrQuery::getHighlightRegexSlop() - Returns the deviation factor from the ideal fragment size
- Функция SolrQuery::getHighlightRequireFieldMatch() - Returns if a field will only be highlighted if the query matched in this particular field
- Функция SolrQuery::getHighlightSimplePost() - Returns the text which appears after a highlighted term
- Функция SolrQuery::getHighlightSimplePre() - Returns the text which appears before a highlighted term
- Функция SolrQuery::getHighlightSnippets() - Returns the maximum number of highlighted snippets to generate per field
- Функция SolrQuery::getHighlightUsePhraseHighlighter() - Returns the state of the hl.usePhraseHighlighter parameter
- Функция SolrQuery::getMlt() - Returns whether or not MoreLikeThis results should be enabled
- Функция SolrQuery::getMltBoost() - Returns whether or not the query will be boosted by the interesting term relevance
- Функция SolrQuery::getMltCount() - Returns the number of similar documents to return for each result
- Функция SolrQuery::getMltFields() - Returns all the fields to use for similarity
- Функция SolrQuery::getMltMaxNumQueryTerms() - Returns the maximum number of query terms that will be included in any generated query
- Функция SolrQuery::getMltMaxNumTokens() - Returns the maximum number of tokens to parse in each document field that is not stored with TermVector support
- Функция SolrQuery::getMltMaxWordLength() - Returns the maximum word length above which words will be ignored
- Функция SolrQuery::getMltMinDocFrequency() - Returns the treshold frequency at which words will be ignored which do not occur in at least this many docs
- Функция SolrQuery::getMltMinTermFrequency() - Returns the frequency below which terms will be ignored in the source document
- Функция SolrQuery::getMltMinWordLength() - Returns the minimum word length below which words will be ignored
- Функция SolrQuery::getMltQueryFields() - Returns the query fields and their boosts
- Функция SolrQuery::getQuery() - Returns the main query
- Функция SolrQuery::getRows() - Returns the maximum number of documents
- Функция SolrQuery::getSortFields() - Returns all the sort fields
- Функция SolrQuery::getStart() - Returns the offset in the complete result set
- Функция SolrQuery::getStats() - Returns whether or not stats is enabled
- Функция SolrQuery::getStatsFacets() - Returns all the stats facets that were set
- Функция SolrQuery::getStatsFields() - Returns all the statistics fields
- Функция SolrQuery::getTerms() - Returns whether or not the TermsComponent is enabled
- Функция SolrQuery::getTermsField() - Returns the field from which the terms are retrieved
- Функция SolrQuery::getTermsIncludeLowerBound() - Returns whether or not to include the lower bound in the result set
- Функция SolrQuery::getTermsIncludeUpperBound() - Returns whether or not to include the upper bound term in the result set
- Функция SolrQuery::getTermsLimit() - Returns the maximum number of terms Solr should return
- Функция SolrQuery::getTermsLowerBound() - Returns the term to start at
- Функция SolrQuery::getTermsMaxCount() - Returns the maximum document frequency
- Функция SolrQuery::getTermsMinCount() - Returns the minimum document frequency to return in order to be included
- Функция SolrQuery::getTermsPrefix() - Returns the term prefix
- Функция SolrQuery::getTermsReturnRaw() - Whether or not to return raw characters
- Функция SolrQuery::getTermsSort() - Returns an integer indicating how terms are sorted
- Функция SolrQuery::getTermsUpperBound() - Returns the term to stop at
- Функция SolrQuery::getTimeAllowed() - Returns the time in milliseconds allowed for the query to finish
- SolrQuery::removeExpandFilterQuery
- SolrQuery::removeExpandSortField
- Функция SolrQuery::removeFacetDateField() - Removes one of the facet date fields
- Функция SolrQuery::removeFacetDateOther() - Removes one of the facet.date.other parameters
- Функция SolrQuery::removeFacetField() - Removes one of the facet.date parameters
- Функция SolrQuery::removeFacetQuery() - Removes one of the facet.query parameters
- Функция SolrQuery::removeField() - Removes a field from the list of fields
- Функция SolrQuery::removeFilterQuery() - Removes a filter query
- Функция SolrQuery::removeHighlightField() - Removes one of the fields used for highlighting
- Функция SolrQuery::removeMltField() - Removes one of the moreLikeThis fields
- Функция SolrQuery::removeMltQueryField() - Removes one of the moreLikeThis query fields
- Функция SolrQuery::removeSortField() - Removes one of the sort fields
- Функция SolrQuery::removeStatsFacet() - Removes one of the stats.facet parameters
- Функция SolrQuery::removeStatsField() - Removes one of the stats.field parameters
- Функция SolrQuery::setEchoHandler() - Toggles the echoHandler parameter
- Функция SolrQuery::setEchoParams() - Determines what kind of parameters to include in the response
- SolrQuery::setExpand
- SolrQuery::setExpandQuery
- SolrQuery::setExpandRows
- Функция SolrQuery::setExplainOther() - Sets the explainOther common query parameter
- Функция SolrQuery::setFacet() - Maps to the facet parameter. Enables or disables facetting
- Функция SolrQuery::setFacetDateEnd() - Maps to facet.date.end
- Функция SolrQuery::setFacetDateGap() - Maps to facet.date.gap
- Функция SolrQuery::setFacetDateHardEnd() - Maps to facet.date.hardend
- Функция SolrQuery::setFacetDateStart() - Maps to facet.date.start
- Функция SolrQuery::setFacetEnumCacheMinDefaultFrequency() - Sets the minimum document frequency used for determining term count
- Функция SolrQuery::setFacetLimit() - Maps to facet.limit
- Функция SolrQuery::setFacetMethod() - Specifies the type of algorithm to use when faceting a field
- Функция SolrQuery::setFacetMinCount() - Maps to facet.mincount
- Функция SolrQuery::setFacetMissing() - Maps to facet.missing
- Функция SolrQuery::setFacetOffset() - Sets the offset into the list of constraints to allow for pagination
- Функция SolrQuery::setFacetPrefix() - Specifies a string prefix with which to limits the terms on which to facet
- Функция SolrQuery::setFacetSort() - Determines the ordering of the facet field constraints
- SolrQuery::setGroup
- SolrQuery::setGroupCachePercent
- SolrQuery::setGroupFacet
- SolrQuery::setGroupFormat
- SolrQuery::setGroupLimit
- SolrQuery::setGroupMain
- SolrQuery::setGroupNGroups
- SolrQuery::setGroupOffset
- SolrQuery::setGroupTruncate
- Функция SolrQuery::setHighlight() - Enables or disables highlighting
- Функция SolrQuery::setHighlightAlternateField() - Specifies the backup field to use
- Функция SolrQuery::setHighlightFormatter() - Specify a formatter for the highlight output
- Функция SolrQuery::setHighlightFragmenter() - Sets a text snippet generator for highlighted text
- Функция SolrQuery::setHighlightFragsize() - The size of fragments to consider for highlighting
- Функция SolrQuery::setHighlightHighlightMultiTerm() - Use SpanScorer to highlight phrase terms
- Функция SolrQuery::setHighlightMaxAlternateFieldLength() - Sets the maximum number of characters of the field to return
- Функция SolrQuery::setHighlightMaxAnalyzedChars() - Specifies the number of characters into a document to look for suitable snippets
- Функция SolrQuery::setHighlightMergeContiguous() - Whether or not to collapse contiguous fragments into a single fragment
- Функция SolrQuery::setHighlightRegexMaxAnalyzedChars() - Specify the maximum number of characters to analyze
- Функция SolrQuery::setHighlightRegexPattern() - Specify the regular expression for fragmenting
- Функция SolrQuery::setHighlightRegexSlop() - Sets the factor by which the regex fragmenter can stray from the ideal fragment size
- Функция SolrQuery::setHighlightRequireFieldMatch() - Require field matching during highlighting
- Функция SolrQuery::setHighlightSimplePost() - Sets the text which appears after a highlighted term
- Функция SolrQuery::setHighlightSimplePre() - Sets the text which appears before a highlighted term
- Функция SolrQuery::setHighlightSnippets() - Sets the maximum number of highlighted snippets to generate per field
- Функция SolrQuery::setHighlightUsePhraseHighlighter() - Whether to highlight phrase terms only when they appear within the query phrase
- Функция SolrQuery::setMlt() - Enables or disables moreLikeThis
- Функция SolrQuery::setMltBoost() - Set if the query will be boosted by the interesting term relevance
- Функция SolrQuery::setMltCount() - Set the number of similar documents to return for each result
- Функция SolrQuery::setMltMaxNumQueryTerms() - Sets the maximum number of query terms included
- Функция SolrQuery::setMltMaxNumTokens() - Specifies the maximum number of tokens to parse
- Функция SolrQuery::setMltMaxWordLength() - Sets the maximum word length
- Функция SolrQuery::setMltMinDocFrequency() - Sets the mltMinDoc frequency
- Функция SolrQuery::setMltMinTermFrequency() - Sets the frequency below which terms will be ignored in the source docs
- Функция SolrQuery::setMltMinWordLength() - Sets the minimum word length
- Функция SolrQuery::setOmitHeader() - Exclude the header from the returned results
- Функция SolrQuery::setQuery() - Sets the search query
- Функция SolrQuery::setRows() - Specifies the maximum number of rows to return in the result
- Функция SolrQuery::setShowDebugInfo() - Flag to show debug information
- Функция SolrQuery::setStart() - Specifies the number of rows to skip
- Функция SolrQuery::setStats() - Enables or disables the Stats component
- Функция SolrQuery::setTerms() - Enables or disables the TermsComponent
- Функция SolrQuery::setTermsField() - Sets the name of the field to get the Terms from
- Функция SolrQuery::setTermsIncludeLowerBound() - Include the lower bound term in the result set
- Функция SolrQuery::setTermsIncludeUpperBound() - Include the upper bound term in the result set
- Функция SolrQuery::setTermsLimit() - Sets the maximum number of terms to return
- Функция SolrQuery::setTermsLowerBound() - Specifies the Term to start from
- Функция SolrQuery::setTermsMaxCount() - Sets the maximum document frequency
- Функция SolrQuery::setTermsMinCount() - Sets the minimum document frequency
- Функция SolrQuery::setTermsPrefix() - Restrict matches to terms that start with the prefix
- Функция SolrQuery::setTermsReturnRaw() - Return the raw characters of the indexed term
- Функция SolrQuery::setTermsSort() - Specifies how to sort the returned terms
- Функция SolrQuery::setTermsUpperBound() - Sets the term to stop at
- Функция SolrQuery::setTimeAllowed() - The time allowed for search to finish
Коментарии
404 Not Found