我试图通过php在我的solr实例中找到我的文档。当我去我的solr管理员并进行搜索时,我得到以下内容:
<response>
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">443</int><lst name="params">
<str name="indent">on</str><str name="start">0</str>
<str name="q">*:*</str><str name="rows">10</str>
<str name="version">2.2</str></lst></lst>
<result name="response" numFound="4" start="0">
<doc>
<str name="description">An Aweomse dish</str>
<arr name="ingredients"><str>Radish</str><str>Beans</str><str>Curry</str></arr>
<str name="name">Alfredo Chehse</str>
<str name="recipe_id">10</str><str name="thumbnail">123343f342</str>
</doc>
<doc>
<str name="description">An Aweomse dish</str>
<arr name="ingredients"><str>Radish</str><str>Beans</str>
<str>Curry</str></arr><str name="name">Alfredo Chehse</str>
<str name="recipe_id">11</str><str name="thumbnail">123343f342</str>
</doc>
</result>
</response>
所以我知道数据就在那里。现在在我的PHP中我有这个:
$query = new SolrQuery();
$query->setQuery('Radish');
$query->setStart(0);
$query->setRows(50);
$query->addField('ingredients') -> addField('name');
$query_response = $client->query($query);
$query_response->setParseMode(SolrQueryResponse::PARSE_SOLR_DOC);
$response = $query_response->getResponse();
print_r($response);
但我总是得到一个空的结果集:
SolrObject对象 (
[responseHeader] => SolrObject Object
(
[status] => 0
[QTime] => 1
[params] => SolrObject Object
(
[fl] => ingredients,name
[indent] => on
[start] => 0
[q] => radish
[wt] => xml
[rows] => 50
[version] => 2.2
)
)
[response] => SolrObject Object
(
[numFound] => 0
[start] => 0
[docs] =>
)
我的问题是,无论我搜索什么,为什么我的结果总是空的?
答案 0 :(得分:2)
成分是一个索引字段?
您是否对每个文档都有不区分大小写的全文索引字段?
试试这个
$query->setQuery('ingredients:*Radish*');