PHP Conference Japan 2024

SolrQuery 类

(PECL solr >= 0.9.2)

简介

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

类概要

SolrQuery 扩展 SolrModifiableParams 实现 Serializable {
/* 常量 */
常量 int ORDER_ASC = 0;
常量 int ORDER_DESC = 1;
常量 int FACET_SORT_INDEX = 0;
常量 int FACET_SORT_COUNT = 1;
常量 int TERMS_SORT_INDEX = 0;
常量 int TERMS_SORT_COUNT = 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 getFacetDateEnd(字符串 $field_override = ?): 字符串
public getFacetDateGap(字符串 $field_override = ?): 字符串
public getFacetDateHardEnd(字符串 $field_override = ?): 字符串
public getFacetDateOther(字符串 $field_override = ?): 数组
public getFacetDateStart(字符串 $field_override = ?): 字符串
public getFacetLimit(字符串 $field_override = ?): 整数
public getFacetMethod(字符串 $field_override = ?): 字符串
public getFacetMinCount(字符串 $field_override = ?): 整数
public getFacetMissing(字符串 $field_override = ?): 布尔值
public getFacetOffset(字符串 $field_override = ?): 整数
public getFacetPrefix(字符串 $field_override = ?): 字符串
public getFacetSort(字符串 $field_override = ?): 整数
public getFields(): 数组
public getHighlightAlternateField(字符串 $field_override = ?): 字符串
public getHighlightFormatter(字符串 $field_override = ?): 字符串
public getHighlightFragmenter(字符串 $field_override = ?): 字符串
public getHighlightFragsize(字符串 $field_override = ?): 整数
public getHighlightMergeContiguous(字符串 $field_override = ?): 布尔值
public getHighlightSimplePost(字符串 $field_override = ?): 字符串
public getHighlightSimplePre(字符串 $field_override = ?): 字符串
public getHighlightSnippets(字符串 $field_override = ?): 整数
public getMlt(): 布尔值
public getRows(): 整数
public getStart(): 整数
public removeFacetDateOther(字符串 $value, 字符串 $field_override = ?): SolrQuery
public setExpand(布尔值 $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_override = ?): SolrQuery
public 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(字符串 $simplePost, 字符串 $field_override = ?): SolrQuery
public setHighlightSimplePre(字符串 $simplePre, 字符串 $field_override = ?): SolrQuery
public setHighlightSnippets(整数 $value, 字符串 $field_override = ?): SolrQuery
public setMlt(布尔值 $flag): SolrQuery
public setMltCount(整数 $count): SolrQuery
public setMltMaxWordLength(整数 $maxWordLength): SolrQuery
public setMltMinDocFrequency(整数 $minDocFrequency): SolrQuery
public setMltMinTermFrequency(整数 $minTermFrequency): SolrQuery
public setMltMinWordLength(整数 $minWordLength): SolrQuery
public setQuery(字符串 $query): SolrQuery
public setRows(整数 $rows): SolrQuery
public setStart(整数 $start): SolrQuery
public setTermsField(字符串 $fieldname): SolrQuery
public setTermsMaxCount(整数 $frequency): SolrQuery
public setTermsMinCount(整数 $frequency): SolrQuery
public setTermsSort(整数 $sortType): SolrQuery
public setTimeAllowed(整数 $timeAllowed): SolrQuery
public __destruct()
/* 继承的方法 */
}

预定义常量

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