cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From giac...@apache.org
Subject svn commit: r603171 - in /cocoon/trunk/blocks: ./ cocoon-querybean/cocoon-querybean-impl/src/main/java/org/apache/cocoon/bean/query/
Date Tue, 11 Dec 2007 08:11:47 GMT
Author: giacomo
Date: Tue Dec 11 00:11:42 2007
New Revision: 603171

URL: http://svn.apache.org/viewvc?rev=603171&view=rev
Log:
fixed cocoon-querybean according to new Lucene API

Modified:
    cocoon/trunk/blocks/cocoon-querybean/cocoon-querybean-impl/src/main/java/org/apache/cocoon/bean/query/SimpleLuceneCriterionBean.java
    cocoon/trunk/blocks/cocoon-querybean/cocoon-querybean-impl/src/main/java/org/apache/cocoon/bean/query/SimpleLuceneQueryBean.java
    cocoon/trunk/blocks/pom.xml

Modified: cocoon/trunk/blocks/cocoon-querybean/cocoon-querybean-impl/src/main/java/org/apache/cocoon/bean/query/SimpleLuceneCriterionBean.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-querybean/cocoon-querybean-impl/src/main/java/org/apache/cocoon/bean/query/SimpleLuceneCriterionBean.java?rev=603171&r1=603170&r2=603171&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-querybean/cocoon-querybean-impl/src/main/java/org/apache/cocoon/bean/query/SimpleLuceneCriterionBean.java
(original)
+++ cocoon/trunk/blocks/cocoon-querybean/cocoon-querybean-impl/src/main/java/org/apache/cocoon/bean/query/SimpleLuceneCriterionBean.java
Tue Dec 11 00:11:42 2007
@@ -26,6 +26,7 @@
 import org.apache.lucene.analysis.Token;
 import org.apache.lucene.analysis.TokenStream;
 import org.apache.lucene.index.Term;
+import org.apache.lucene.search.BooleanClause;
 import org.apache.lucene.search.BooleanQuery;
 import org.apache.lucene.search.FuzzyQuery;
 import org.apache.lucene.search.PhraseQuery;
@@ -124,7 +125,7 @@
 			if (words.size() > 1) {
 				query = new BooleanQuery();
 				for (int i = 0; i < words.size(); i++) {
-					((BooleanQuery)query).add(new TermQuery(new Term(f, (String)words.elementAt(i))), false,
false);
+					((BooleanQuery)query).add(new TermQuery(new Term(f, (String)words.elementAt(i))), BooleanClause.Occur.SHOULD);
 				}
 			} else if (words.size() == 1) {
 				query = new TermQuery(new Term(f, (String)words.elementAt(0)));
@@ -135,7 +136,7 @@
 			if (words.size() > 1) {
 				query = new BooleanQuery();
 				for (int i = 0; i < words.size(); i++) {
-					((BooleanQuery)query).add(new TermQuery(new Term (f, (String)words.elementAt(i))), true,
false);
+					((BooleanQuery)query).add(new TermQuery(new Term (f, (String)words.elementAt(i))), BooleanClause.Occur.MUST);
 				}
 			} else if (words.size() == 1) {
 				query = new TermQuery(new Term(f, (String)words.elementAt(0)));
@@ -146,7 +147,7 @@
 			if (words.size() > 1) {
 				query = new BooleanQuery();
 				for (int i = 0; i < words.size(); i++) {
-					((BooleanQuery)query).add(new TermQuery(new Term(f, (String)words.elementAt(i))), true,
true);
+					((BooleanQuery)query).add(new TermQuery(new Term(f, (String)words.elementAt(i))), BooleanClause.Occur.MUST_NOT);
 				}
 			} else if (words.size() == 1) {
 				query = new TermQuery(new Term(f, (String)words.elementAt(0)));
@@ -157,7 +158,7 @@
 			if (words.size() > 1) {
 				query = new BooleanQuery();
 				for (int i = 0; i < words.size(); i++) {
-					((BooleanQuery)query).add(new FuzzyQuery(new Term(f, (String)words.elementAt(i))), false,
false);
+					((BooleanQuery)query).add(new FuzzyQuery(new Term(f, (String)words.elementAt(i))), BooleanClause.Occur.SHOULD);
 				}
 			} else if (words.size() == 1) {
 				query = new FuzzyQuery(new Term(f, (String)words.elementAt(0)));

Modified: cocoon/trunk/blocks/cocoon-querybean/cocoon-querybean-impl/src/main/java/org/apache/cocoon/bean/query/SimpleLuceneQueryBean.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-querybean/cocoon-querybean-impl/src/main/java/org/apache/cocoon/bean/query/SimpleLuceneQueryBean.java?rev=603171&r1=603170&r2=603171&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-querybean/cocoon-querybean-impl/src/main/java/org/apache/cocoon/bean/query/SimpleLuceneQueryBean.java
(original)
+++ cocoon/trunk/blocks/cocoon-querybean/cocoon-querybean-impl/src/main/java/org/apache/cocoon/bean/query/SimpleLuceneQueryBean.java
Tue Dec 11 00:11:42 2007
@@ -30,6 +30,7 @@
 import org.apache.lucene.document.Field;
 import org.apache.lucene.search.Hits;
 import org.apache.lucene.search.Query;
+import org.apache.lucene.search.BooleanClause;
 import org.apache.lucene.search.BooleanQuery;
 import org.apache.cocoon.components.search.LuceneCocoonSearcher;
 import org.apache.cocoon.ProcessingException;
@@ -184,7 +185,15 @@
 		while (it.hasNext()) {
 			SimpleLuceneCriterion criterion = (SimpleLuceneCriterion)it.next();
 			Query subquery = criterion.getQuery (searcher.getAnalyzer());
-			query.add(subquery, required, criterion.isProhibited());
+			if(!required) {
+				if(criterion.isProhibited()) {
+					query.add(subquery, BooleanClause.Occur.MUST_NOT);
+				} else {
+					query.add(subquery, BooleanClause.Occur.SHOULD);
+				}
+			} else {
+				query.add(subquery, BooleanClause.Occur.MUST);
+			}
 		}
 		Hits hits = searcher.search(query);
 		this.total = new Long (hits.length());

Modified: cocoon/trunk/blocks/pom.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/pom.xml?rev=603171&r1=603170&r2=603171&view=diff
==============================================================================
--- cocoon/trunk/blocks/pom.xml (original)
+++ cocoon/trunk/blocks/pom.xml Tue Dec 11 00:11:42 2007
@@ -200,10 +200,8 @@
         <module>cocoon-python/cocoon-python-mocks</module>
         <module>cocoon-qdox/cocoon-qdox-impl</module>
         <module>cocoon-qdox/cocoon-qdox-sample</module>
-<!-- 
         <module>cocoon-querybean/cocoon-querybean-impl</module>
         <module>cocoon-querybean/cocoon-querybean-sample</module>
- -->
         <module>cocoon-repository/cocoon-repository-impl</module>
         <module>cocoon-scratchpad/cocoon-scratchpad-impl</module>
         <module>cocoon-scratchpad/cocoon-scratchpad-sample</module>



Mime
View raw message