Search Symfony-lucene单独搜索字段

Search Symfony-lucene单独搜索字段,search,symfony1,lucene,Search,Symfony1,Lucene,我有4个字段的表要搜索。 我喜欢这样的索引字段: $doc->addField(Zend_Search_Lucene_Field::Keyword('pk', $this->getId())); $doc->addField(Zend_Search_Lucene_Field::UnStored('username', $this->getUsername(), 'utf-8')); $doc->addField(Zend_Search_Lucene_

我有4个字段的表要搜索。 我喜欢这样的索引字段:

$doc->addField(Zend_Search_Lucene_Field::Keyword('pk', $this->getId()));
    $doc->addField(Zend_Search_Lucene_Field::UnStored('username', $this->getUsername(), 'utf-8'));
    $doc->addField(Zend_Search_Lucene_Field::UnStored('firstName', $this->getFirstName(), 'utf-8'));
    $doc->addField(Zend_Search_Lucene_Field::UnStored('lastName', $this->getLastName(), 'utf-8'));
    $doc->addField(Zend_Search_Lucene_Field::UnStored('city', $this->getCity(), 'utf-8'));
我想使用表单选项对此字段进行单独搜索

<select name="contact[subject]" id="contact_subject">
  <option value="0">Username</option>
  <option value="1">First Name</option>
  <option value="2">Last Name</option>
  <option value="3">City</option>
</select>

用户名
名字
姓
城市
如何告诉Lucene只在我想要的人字段中搜索结果?
我读了很多问题和解释,但我不明白:(

你需要在搜索词前面加上字段名:

$results = $li->find('username:"foobar"');

其中,
$li
是您的lucene索引。

您需要在搜索词前面加上字段名称:

$results = $li->find('username:"foobar"');

其中,
$li
是您的lucene索引。

如果我认识正确,在我的情况下,事情需要如下所示。$query='username:“user5”;$this->query=doctor\u Core::getTable('sfGuardUser')->getAutocompleteQuery($query);如果我想用*sumbol搜索不完整的serach结果怎么办?我试过了,但没有扩展的结果。Zend_search_Lucene。是的,我读过这篇文章,但当我试过$results=$li->find('username:'foobar*');通配符不起作用。我还试过$results=$li->find('username:'foobar');和$results=$li->find('username:'foobar''));请详细说明“不工作”,这是不够的信息。如果我意识到正确,在我的情况下,事情应该是这样的。$query='username:“user5';$this->query=doctor\u Core::getTable('sfGuardUser')->getAutocompleteQuery($query);如果我想用*sumbol搜索不完整的serach结果怎么办?我试过了,但没有扩展的结果。Zend_search_Lucene。是的,我读过这篇文章,但当我试过$results=$li->find('username:'foobar*');通配符不起作用。我还试过$results=$li->find('username:'foobar');和$results=$li->find('username:'foobar''));请详细说明“不工作”,这是不够的信息来帮助。