Reputation: 304
I have table whit 4 field witch i want to search. I indexing field like this:
$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'));
I want to separate search on this fields whith form Options.
<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>
How to tell Lucene to search result only in field who i want ? I read many questions and explenations , but i dont get it :(
Upvotes: 1
Views: 141
Reputation: 34125
You need to prefix your search term with the field's name:
$results = $li->find('username:"foobar"');
where $li
is your lucene index.
Upvotes: 1