2012-07-14 4 views
1

나는 검색하고 싶은 테이블 오순절 4 필드 마녀 있습니다. 이 같은 I 색인 필드 :심포니 lucene 별도의 검색 필드

$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에게 알리는 방법은 무엇입니까? 나는 많은 질문과 explenations을 읽을 수 있지만 내가 그것을

답변

1

당신은 필드의 이름이 검색어를 앞에 필요 :(얻을 해달라고 :. $li이 루씬 지수는

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

입니다

+0

만약 I 깨달았지만 내 경우에는 이렇게 보일 필요가있다. $ query = 'username : "user5"'; $ this-> query = Doctrine_Core :: getTable ('sfGuardUser') -> getAutocompleteQuery ($ query); 불완전한 수사 결과를 찾기 위해 * 수색을하고 싶습니까? 시도해 보았지만 결과는 놀랍지 않았습니다. – plamen

+0

Zend_Se arch_Lucene [와일드 카드 지원] (http://framework.zend.com/manual/en/zend.search.lucene.query-language.html#zend.search.lucene.query-language.wildcard). – Maerlyn

+0

예 내가 alredy 읽을 때,하지만 내가 $ 결과 = $ 리 -> 찾기 ('사용자 이름 : "foobar *"'); 와일드 카드 기호가 작동하지 않습니다. 나는 또한 $ results = $ li-> find ('username : "foobar"*');를 시도했다. $ results = $ li-> find ('username : "foobar"'. '*'); – plamen