我正在使用一个名为 solr-php-client (http://code.google.com/p/solr-php-client/) 的 PHP 库与我的 Solr 服务器进行交互。我可以从文档中提取数据、存储它并在其上搜索,但我似乎无法让它允许我将自己的数据添加到索引参数中:
$aParams = array
(
"literal.ClassName_ms" => "File",
"literal.SS_ID_i" => 73,
"literal.Name_ms" => "OverviewOfBenefits.pdf",
"literal.title" => "Overview Of Benefits",
"literal.Created_dt" => "2011-09-19T13:50:30Z",
"literal.last_modified_dt" => "2011-10-12T19:33:59Z",
"literal.SS_Stage_ms" => "Live",
"literal.ClassNameHierarchy_ms" => array("Object","ViewableData","DataObject","File"),
"literal.id" => "File_73_Live",
"fmap.content" => "text",
);
try {
$oResponse = $oSOLR->extract($sFilePath, $aParams);
$oSOLR->commit();
$oSOLR->optimize();
}
catch(Exception $e) {
var_dump($e);
}
我可以查询“文本”并获得结果:
<?xml version="1.0" encoding="UTF-8"?>
<response>
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">0</int>
<lst name="params">
<str name="indent">on</str>
<str name="start">0</str>
<str name="q">text:Overview</str>
<str name="rows">10</str>
<str name="version">2.2</str>
</lst>
</lst>
<result name="response" numFound="1" start="0">
<doc>
<arr name="content_type"><str>application/pdf</str></arr>
<str name="id">File_73_Live</str>
<date name="last_modified">2011-02-07T16:21:10Z</date>
</doc>
</result>
</response>
但我无法查询任何动态字段,即“SS_Stage_ms”:
<?xml version="1.0" encoding="UTF-8"?>
<response>
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">0</int>
<lst name="params">
<str name="indent">on</str>
<str name="start">0</str>
<str name="q">SS_Stage_ms:Live</str>
<str name="rows">10</str>
<str name="version">2.2</str>
</lst>
</lst>
<result name="response" numFound="0" start="0"/>
</response>
以下是适用的架构定义:
<field name="id" type="string" indexed="true" stored="true" required="true" />
<field name="title" type="text" indexed="true" stored="true" multiValued="true"/>
<field name="text" type="text" indexed="true" stored="false" multiValued="true"/>
<dynamicField name="*_i" type="int" indexed="true" stored="false"/>
<dynamicField name="*_ms" type="string" indexed="true" stored="false" multiValued="true"/>
<dynamicField name="*_dt" type="date" indexed="true" stored="false"/>