首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

SolrClient::getById

(PECL solr >= 2.2.0)

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

Description

代码语言:javascript
复制
public SolrQueryResponse SolrClient::getById ( string $id )

Get Document By Id. Utilizes Solr Realtime Get (RTG).

Parameters

id

Document ID

Return Values

SolrQueryResponse

Examples

Example #1 SolrClient::getById() example

代码语言:javascript
复制
<?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());

?>

The above example will output something similar to:

代码语言:javascript
复制
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
        )

)

See Also

  • SolrClient::getByIds() - Get Documents by their Ids. Utilizes Solr Realtime Get (RTG).

← SolrClient::__destruct

SolrClient::getByIds →

代码语言:txt
复制
 ? 1997–2017 The PHP Documentation Group

Licensed under the Creative Commons Attribution License v3.0 or later.

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com