SolrQuery 类

(PECL solr >= 0.9.2)

介绍

表示发送到 Solr 服务器的请求期间的一组名称-值对。

类概要

class SolrQuery extends SolrModifiableParams implements Serializable {
/* 常量 */
const int ORDER_ASC = 0;
const int ORDER_DESC = 1;
/* 属性 */
/* 方法 */
public __construct(string $q = ?)
public addExpandSortField(string $field, string $order = ?): SolrQuery
public addFacetDateField(string $dateField): SolrQuery
public addFacetDateOther(string $value, string $field_override = ?): SolrQuery
public addFacetQuery(string $facetQuery): SolrQuery
public addField(string $field): SolrQuery
public addGroupSortField(string $field, int $order = ?): SolrQuery
public addMltField(string $field): SolrQuery
public addMltQueryField(string $field, float $boost): SolrQuery
public addSortField(string $field, int $order = SolrQuery::ORDER_DESC): SolrQuery
public collapse(SolrCollapseFunction $collapseFunction): SolrQuery
public getExpand(): bool
public getExpandRows(): int
public getFacet(): bool
public getFacetDateEnd(string $field_override = ?): string
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 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 getFacetSort(string $field_override = ?): int
public getFields(): array
public getGroup(): bool
public getGroupLimit(): int
public getGroupMain(): bool
public getHighlight(): bool
public
public getHighlightFormatter(string $field_override = ?): string
public getHighlightFragmenter(string $field_override = ?): string
public getHighlightFragsize(string $field_override = ?): int
public getHighlightMaxAlternateFieldLength(string $field_override = ?): int
public getHighlightMergeContiguous(string $field_override = ?): bool
public getHighlightSimplePost(string $field_override = ?): string
public getHighlightSimplePre(string $field_override = ?): string
public getHighlightSnippets(string $field_override = ?): int
public getMlt(): bool
public getMltBoost(): bool
public getMltCount(): int
public getQuery(): string
public getRows(): int
public getStart(): int
public getStats(): bool
public getTerms(): bool
public getTermsLimit(): int
public getTermsSort(): int
public removeFacetDateOther(string $value, string $field_override = ?): SolrQuery
public removeField(string $field): SolrQuery
public removeMltQueryField(string $queryField): SolrQuery
public setExpand(bool $value): SolrQuery
public setExpandRows(int $value): 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 setGroupFacet(bool $value): SolrQuery
public setGroupLimit(int $value): SolrQuery
public setGroupMain(string $value): SolrQuery
public setGroupOffset(int $value): SolrQuery
public setHighlight(bool $flag): SolrQuery
public setHighlightAlternateField(string $field, string $field_override = ?): SolrQuery
public setHighlightFormatter(string $formatter, string $field_overridepublic setHighlightFragmenter(string $fragmenter, string $field_override = ?): SolrQuery
public setHighlightFragsize(int $size, string $field_override = ?): SolrQuery
public setHighlightMaxAlternateFieldLength(int $fieldLength, string $field_override = ?): SolrQuery
public setHighlightMergeContiguous(bool $flag, string $field_override = ?): 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 setMltMaxWordLength(int $maxWordLength): SolrQuery
public setMltMinDocFrequency(int $minDocFrequency): SolrQuery
public setMltMinTermFrequency(int $minTermFrequency): SolrQuery
public setMltMinWordLength(int $minWordLength): SolrQuery
public setQuery(string $query): SolrQuery
public setRows(int $rows): SolrQuery
public setStart(int $start): SolrQuery
public setStats(bool $flag): SolrQuery
public setTerms(bool $flag): SolrQuery
public setTermsField(string $fieldname): SolrQuery
public setTermsLimit(int $limit): SolrQuery
public setTermsLowerBound(string $lowerBound): SolrQuery
public setTermsMaxCount(int $frequency): SolrQuery
public setTermsMinCount(int $frequency): SolrQuery
public setTermsSort(int $sortType): SolrQuery
public setTermsUpperBound(string $upperBound): SolrQuery
public setTimeAllowed(int $timeAllowed): SolrQuery
public __destruct()
/* Inherited methods */
}

预定义常量

SolrQuery::ORDER_ASC

用于指定排序应为升序

SolrQuery::ORDER_DESC

用于指定排序应为降序

SolrQuery::FACET_SORT_INDEX

用于指定分面应按索引排序

SolrQuery::FACET_SORT_COUNT

用于指定分面应按计数排序

SolrQuery::TERMS_SORT_INDEX

用于 TermsComponent 中

SolrQuery::TERMS_SORT_COUNT

用于 TermsComponent 中

目录

添加注释

用户贡献注释 1 条注释

andy at borkedcoder dot com
12 年前
注意 - 如果使用 morelikethis,并且您的查询是对数字 ID 的查询,那么您将无法访问结果中的 moreLikeThis 对象...

当 q=id:3493 使用 mlt 搜索时,结果是

SolrObject 对象
(
...
[moreLikeThis] => SolrObject 对象
(
[3493] => SolrObject 对象
(
[numFound] => 6286
[start] => 0
[docs] => 数组
(
....等等

无法访问数字对象名称(上面为 3493)

既不能通过 $response->moreLikeThis->{3493} 访问,也不能通过 $response->moreLikeThis->{'3493'} 访问,没有任何方法...

唯一的方法是将 moreLikeThis 对象转换为数组,方法是
$response_array = (array) $response->moreLikeThis;

然后迭代该数组,因为数组键是已知的。
To Top