Forums / Extensions / eZ Find / How to exclude a term in search ?

How to exclude a term in search ?

Author Message

Nicolas Lescure

Thursday 26 November 2009 2:45:35 am

I'm trying to use ezfind, but I have a problem in my query.

In doc (http://ez.no/doc/extensions/ez_find/2_1/customization/template_fetch_functions#Filter), I can see :

Example:

 fetch( ezfind, search,
hash( query, 'eZ Systems',
filter, array( 'or',
array( 'and',
'article/body:hello',
'article/rating:[1 TO 10]' ),
array( 'and',
'article/body:goodbye',
'article/rating:[10 TO 20]' )))

 
Returns all articles containing the words “ez” and “systems”, either having both 'hello' present in the body and a rating comprised between 1 and 10, or having both 'goodbye' in the body and a rating comprised between 10 and 20.

Now, how can I do if I want articles WITHOUT "goodbye" in the body ?

In solr doc (http://wiki.apache.org/solr/SolrQuerySyntax#Differences_From_Lucene_Query_Parser), it says I should use a "-".

But it doesn't work (ezfind error) :

 ...
array( 'and',
'-article/body:goodbye',
'article/rating:[10 TO 20]' )))

The error I get :

 Got invalid result from search engine.<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<title>Error 400 </title>
</head>
<body><h2>HTTP ERROR: 400</h2><pre>org.apache.lucene.queryParser.ParseException: Cannot parse '( meta_contentclass_id_si:36 AND attr_myattribute_t:myvalue )
.....

 Encountered " ":" ": "" at line 1, column 0.

 Any idea ?