Finally solved, thank you MSchraeder for your great advices. I've changed the field type of 'categories_url' from 'keyword' to 'text', then I stored its data without hyphens. I've also removed commas, all terms are separated by a space. And it is working! Thank you
Sergio Rinaudo Date: Tue, 21 Apr 2009 14:26:21 -0500 From: [email protected] To: [email protected] Subject: RE: [fw-general] Zend_Search_Lucene_Search_Query_Wildcard working with zf 1.7.0 but not with 1.7.7+ You said in your last reply that you had the following field categories_url => audiovideo-PC-telefonia , varie-regali , compro-vendo Does this mean that for a single document, you could have all three of those possible categories, and that the data stored would be exactly "audiovideo-PC-telefonia , varie-regali , compro-vendo"? If so, keyword is not what you want to use. Keyword stores EXACTLY what is in that field as a single huge term. If you want to include multiple terms per document, then you want to use a standard Indexed field. I would recommend changing this to an indexed field, and instead of your current data simply fill the field with each term separated by a space. I would also recommend removing the hyphens, as I am pretty sure it will split "varie-regali" into two separate terms. So instead of your current field, it should consist of "audiovideoPCtelefonia varieregali comprovendo" and when you display the data back to the user, replace the hyphens. You don't need commas or other separator, because a space is more than enough. This will allow you to search for "comprovendo" and come up with the documents you expect. >>> Sergio Rinaudo <[email protected]> 4/21/2009 10:54:22 AM >>> Luke is really an awesome tool! After I selected my search index I've got everything as expected. Also the 'categories_url' field is I-S--------, Indexed and Stored hopefully like I've specified in My_Search_Lucene_Document class: $this->addField(Zend_Search_Lucene_Field::Keyword( 'categories_url', $categories_url,'utf-8')); 'Keyword', so it will be able to be searchable and displayable ( correct me if I mistake ) So I tried to do a search with Luke ( tab Search, default field: categories_url ), looking for term 'biglietti' ( categories_url:biglietti ) . Inside a document I've got this value => biglietti , compro-vendo <= as categories_url, so one result is expected. However I got nothing, like on my project. It is normal? Maybe the '-' inside fields causes this bad behaviour? I've also tried the wildcard search ( categories_url:biglietti* ) after checking the 'Allow leading * in wildcard queries' box ( categories_url:biglietti* ), and I finally got the result I expected. But still there is the problem. In fact, if I search for 'compro-vendo' I got nothing, this because ( I suppose ) 'compro-vendo' is at the end of the indexed string. Tha final try, look for a two wildcard string ( *compro-vendo* ), and I get what expected, yes in Luke, but NOT in ZF 1.7.7, it was working in 1.7.0. In zf 1.7.7 I get an exception: categories_url:*compro-vendo* exception 'Zend_Search_Lucene_Exception' with message 'At least 3 non-wildcard terms are required.' in [..] Same if the query search is categories_url:*biglietti* It is a bug or I missing something? Sergio Rinaudo Date: Tue, 21 Apr 2009 09:56:50 -0500 From: [email protected] To: [email protected]; [email protected] Subject: Re: FW: [fw-general] Zend_Search_Lucene_Search_Query_Wildcard working with zf 1.7.0 but not with 1.7.7+ Then your best bet would be to actually check what is in the index itself. There's a chance your tokenizer could be messing up because of the hyphens in your search terms. If you run Luke, the Lucene Index Toolbox, you'll be able to look at exactly what is in each field, top terms in each field, and do some test queries. http://www.getopt.org/luke/ Open up your index in that program, and in the main tab click on the "categories_url" field. Then click top terms. First thing is to make sure it actually has terms, then make sure that the terms are what you're expecting. Your searches look fine to me, but it is possible that your index isn't built quite right yet. It took me several tries to make sure all of my fields were being indexed the way I intended. >>> Sergio Rinaudo <[email protected]> 4/20/2009 12:49:35 PM >>> Thank you MSchraeder for your reply! However I tried like you said but it is not working ( or maybe I'm mistaking something.. ), I'll post here a full example: I have a Lucene field, named 'categories_url' where I store all the categories for a certain page, eg. categories_url => audiovideo-PC-telefonia , varie-regali , compro-vendo I do a search, looking for 'compro-vendo' $term = new Zend_Search_Lucene_Index_Term($c, 'categories_url'); $query = new Zend_Search_Lucene_Search_Query_Term($term); $results = $index->find($query,'dateCreated',SORT_REGULAR,SORT_DESC); where $c is obviously compro-vendo If I do an 'echo' of the $query variable I get categories_url:compro-vendo $results array is empty, if I do Zend_Debug::dump($results); I get array(0) { }All this block is inside a try..catch statement. I've also tried to remove the 'dateCreated',SORT_REGULAR,SORT_DESC' arguments, same result. Any advices? Thank you Sergio Rinaudo Date: Mon, 20 Apr 2009 08:20:18 -0500 From: [email protected] To: [email protected]; [email protected] Subject: RE: [fw-general] Zend_Search_Lucene_Search_Query_Wildcard working with zf 1.7.0 but not with 1.7.7+ It looks like wildcards preceeding the term are even more broken than wildcards after the term. Vote up the wildcard issues I linked, and include more information about the errors you're seeing. Hopefully it'll be fixed in the next version or two. If you want to search if a full term is included, you only have to search for the term. Wildcards are used for partial terms, such as searching for ha*y returning both harry and happy as search terms. If you want to search for the term happy, just do a search for happy. The only time that will not work is in a keyword field, where it searches the entire field as if it is one term. >>> Sergio Rinaudo <[email protected]> 4/18/2009 4:11:59 AM >>> Thanks for the reply, I didn't know about those issues page. However the query I've done is still not working bacause I use two '*', before and after the term, as I want to search if the term is 'included' in a certain field of the Lucene index. Correct me if I mistake, but I think that using only one at the end of the term is like search a sentence that starts with the term. So my question is, what do I have to do if I want to search if the term is 'included' in 1.7.8? Thank you Sergio Rinaudo Date: Fri, 17 Apr 2009 08:14:45 -0500 From: [email protected] To: [email protected] Subject: Re: [fw-general] Zend_Search_Lucene_Search_Query_Wildcard working with zf 1.7.0 but not with 1.7.7+ I had the same problem when upgrading from 1.6.8 to 1.7.8. Each term needs to have at least 3 characters alongside the wild card in order to work. So the search "ha*" will fail, but "har*" works fine. The easiest work around is to just make sure each term with a wildcard in it has at least 3 characters. There are a few bug reports in the issue tracker already related to this: http://framework.zend.com/issues/browse/ZF-6290 http://framework.zend.com/issues/browse/ZF-4653 >>> Sergio Rinaudo <[email protected]> 4/15/2009 3:10:16 PM >>> Hello, hope anybody could help with the Search Lucene component. This code: $request = $this->getRequest(); $params = $request->getParams(); $c = isset($params['c']) ? $params['c'] : ''; $term = new Zend_Search_Lucene_Index_Term('*'.$c.'*','categories_url'); $query = new Zend_Search_Lucene_Search_Query_Wildcard($term); $results = $index->find($query,'dateCreated',SORT_REGULAR,SORT_DESC); works with zf 1.7.0 but NOT with zf 1.7.7 and 1.7.8, andI get this exception: exception 'Zend_Search_Lucene_Exception' with message 'At least 3 non-wildcard terms are required.' I've read the documentation http://framework.zend.com/manual/en/zend.search.lucene.query-api.html but I were unable to find where is specified about the 3 non-wildcard terms required. I appreciate any suggestion. Thanks. Sergio Rinaudo Il remix esclusivo di Messenger. Scaricalo gratis! Dillo con le Emoticon! Scarica il nuovo Messenger 2009 Il remix esclusivo di Messenger. Scaricalo gratis! 25 GB di spazio gratuito su Internet! Prova SkyDrive 25 GB di spazio gratuito su Internet! Prova SkyDrive Dillo con le Emoticon! Scarica il nuovo Messenger 2009 _________________________________________________________________ Chiama gratis dal tuo PC! Parla su Messenger http://clk.atdmt.com/GBL/go/140630369/direct/01/
