略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: SolrClient::getById

2024-12-22

SolrClient::getById

(PECL solr >= 2.2.0)

SolrClient::getByIdGet Document By Id. Utilizes Solr Realtime Get (RTG)

说明

public SolrClient::getById(string $id): SolrQueryResponse

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
        )

)

参见

add a noteadd a note

User Contributed Notes

There are no user contributed notes for this page.

官方地址:https://www.php.net/manual/en/solrclient.getbyid.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3