Php 如何在zend lucene中搜索多个查询?

Php 如何在zend lucene中搜索多个查询?,php,zend-framework,Php,Zend Framework,我有3个字段,其中两个是数组,一个是名称字段。如何从zend lucene索引中搜索这些记录 code: $name = $_POST ['name']; $emails = $_POST ['email']; // this is a array $xId = $_POST ['xId']; // this also an array $index = new Zend_Search_Lucene ( 'test-index' ); 试试这个 $name = $_POST ['nam

我有3个字段,其中两个是数组,一个是名称字段。如何从zend lucene索引中搜索这些记录

code:

$name = $_POST ['name'];

$emails = $_POST ['email']; // this is a array

$xId = $_POST ['xId']; // this also an array

$index = new Zend_Search_Lucene ( 'test-index' );
试试这个

$name = $_POST ['name'];

$emails = $_POST ['email']; // this is a array

$xIds = $_POST ['xId']; // this also an array

// Making array as string
$emailIds = '';
foreach($emails as $email) {
    $emailIds .= $email . " ";
}

// Making array as string
$xIdsString = '';
foreach ($xIds as $xId) {
    $xIdsString .= $xId . " ";
}

// Create a new index object
$index = new Zend_Search_Lucene ( 'test-index' );

// Here we are going to search over multiple fields. 
// we are just creating the string for right now
$name_query     = "name:($lastName)";
$emails_query   = "emails:($emailIds)";
$xIds_query     = "xIds:($xIdsString)";

// Parse the query
$query = Zend_Search_Lucene_Search_QueryParser::parse("$name_query $emails_query $xIds_query");

$hits  = $index->find($query);
print_r($hits);

也许您可以添加一些您迄今为止尝试的内容。代码示例没有给出多少方向。您可以构建相当复杂的查询来搜索索引,这些查询本质上是布尔查询。