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 ?

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 02:53:39
Script start
Timing: Jan 18 2025 02:53:39
Module start 'layout'
Timing: Jan 18 2025 02:53:39
Module start 'content'
Timing: Jan 18 2025 02:53:39
Module end 'content'
Timing: Jan 18 2025 02:53:39
Script end

Main resources:

Total runtime0.3659 sec
Peak memory usage4,096.0000 KB
Database Queries48

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0040 589.1875152.6406
Module start 'layout' 0.00400.0033 741.828139.4766
Module start 'content' 0.00730.3575 781.3047447.0234
Module end 'content' 0.36470.0012 1,228.32818.1328
Script end 0.3659  1,236.4609 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00270.7278160.0002
Check MTime0.00110.3052160.0001
Mysql Total
Database connection0.00050.136410.0005
Mysqli_queries0.323488.3683480.0067
Looping result0.00030.0802460.0000
Template Total0.340693.120.1703
Template load0.00170.459920.0008
Template processing0.338992.606520.1694
Template load and register function0.00020.068310.0002
states
state_id_array0.00070.203310.0007
state_identifier_array0.00070.194020.0004
Override
Cache load0.00150.4215170.0001
Sytem overhead
Fetch class attribute can translate value0.00060.171910.0006
Fetch class attribute name0.00060.174920.0003
XML
Image XML parsing0.00330.897710.0033
class_abstraction
Instantiating content class attribute0.00000.001420.0000
General
dbfile0.00531.4355160.0003
String conversion0.00000.001540.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
4content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 12
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs