I''m not sure whether this is a bug or whether I''m simply expecting Ferret queries to work in a way other than they''re intended. I notice that if use a query like: (other_text:"Collaborative tools") AND NOT other_text:podcasts I''ll get correct search results. However, if I put parentheses around the second part, like: (other_text:"Collaborative tools") AND (NOT other_text:podcasts) I won''t get any search resuts. This seems to only be an issue when NOT (or a preceding -) are used. For example, both of these work: (other_text:"Collaborative tools") AND other_text:podcasts (other_text:"Collaborative tools") AND (other_text:podcasts) My use of parentheses is for precedence (I assume they work that way). I quickly looked at query_parser.y, but as I''ve never used racc (or yacc), it''s not apparent to me what should be happening. Thanks! Jen
Note: I''m familiar with Lucene but just keeping an eye on Ferret progress. You need to be careful with the construction of your queries. I don''t know if you can do it in Ferret but you really should check the QueryParser''s output to see how it interprets your queries. Parentheses are used to create groups of expressions, so wrapping them around a single expression actually does nothing. That''s why both your last queries work - they''re the same: other_text:"Collaborative tools" AND other_text:podcasts Your first query is basic and needs no () other_text:"Collaborative tools" AND NOT other_text:podcasts or +other_text:"Collaborative tools" -other_text:podcasts Examples of parenthese use: (other_text:"Collaborative tools" OR other_text:Feeds) AND NOT other_text:podcasts (other_text:Feeds AND NOT other_text:RSS) OR (other_text:"Collaborative tools" AND NOT other_text:podcasts) Regards, --Leto (please excuse the email footer...) -----Original Message----- From: jennyw I''m not sure whether this is a bug or whether I''m simply expecting Ferret queries to work in a way other than they''re intended. I notice that if use a query like: (other_text:"Collaborative tools") AND NOT other_text:podcasts I''ll get correct search results. However, if I put parentheses around the second part, like: (other_text:"Collaborative tools") AND (NOT other_text:podcasts) I won''t get any search resuts. This seems to only be an issue when NOT (or a preceding -) are used. For example, both of these work: (other_text:"Collaborative tools") AND other_text:podcasts (other_text:"Collaborative tools") AND (other_text:podcasts) My use of parentheses is for precedence (I assume they work that way). I quickly looked at query_parser.y, but as I''ve never used racc (or yacc), it''s not apparent to me what should be happening. Thanks! Jen Tasmania Together 5 Year Review: Have your say : www.tasmaniatogether.tas.gov.au CONFIDENTIALITY NOTICE AND DISCLAIMER Information in this transmission is intended only for the person(s) to whom it is addressed and may contain privileged and/or confidential information. If you are not the intended recipient, any disclosure, copying or dissemination of the information is unauthorised and you should delete/destroy all copies and notify the sender. No liability is accepted for any unauthorised use of the information contained in this transmission. This disclaimer has been automatically added.
Hi Jenny, The following two queries are different. (other_text:"Collaborative tools") AND NOT other_text:podcasts (other_text:"Collaborative tools") AND (NOT other_text:podcasts) You can check how the query parser parses these queries like this; $ ruby lib/ferret/query_parser/query_parser.tab.rb (other_text:"Collaborative tools") AND NOT other_text:podcasts Ferret::Search::BooleanQuery +other_text:"collaborative tools" -other_text:podcasts (other_text:"Collaborative tools") AND (NOT other_text:podcasts) Ferret::Search::BooleanQuery +other_text:"collaborative tools" +(-other_text:podcasts) Let me explain. The first I think you understand already. The second query you are taking the conjunction ("AND") of two queries. The first one, other_text:"collaborative tools", is obviously returning results. The second one, -other_text:podcasts contains no positive queries, ie. nothing to look for so it returns nothing. The conjunction of something and nothing is obviously nothing. Now I guess this could be interpreted differently. Boolean queries with only exclusive ("NOT") clauses could return everything but documents containing these results. But every boolean query requires an optional or required clause. The reason being, if you did a search for a every document that didn''t contain a rare word and you have a large index, you could be getting hundreds of thousands of results back. Lucene handles this query the same way. While the brackets do set precedence, it''s worthwhile to remember that every time you put brackets like that you are creating a boolean query. As you can see from the output above, single term boolean queries are optimized into term queries, (ie the brackets are removed). Hope that helps, Dave On 12/19/05, jennyw <jennyw at dangerousideas.com> wrote:> I''m not sure whether this is a bug or whether I''m simply expecting > Ferret queries to work in a way other than they''re intended. > > I notice that if use a query like: > > (other_text:"Collaborative tools") AND NOT other_text:podcasts > > I''ll get correct search results. However, if I put parentheses around > the second part, like: > > (other_text:"Collaborative tools") AND (NOT other_text:podcasts) > > I won''t get any search resuts. This seems to only be an issue when NOT > (or a preceding -) are used. For example, both of these work: > > (other_text:"Collaborative tools") AND other_text:podcasts > (other_text:"Collaborative tools") AND (other_text:podcasts) > > My use of parentheses is for precedence (I assume they work that way). I > quickly looked at query_parser.y, but as I''ve never used racc (or yacc), > it''s not apparent to me what should be happening. > > Thanks! > > Jen > > _______________________________________________ > Ferret-talk mailing list > Ferret-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/ferret-talk >