luetzkendorf    2004/10/25 00:52:30

  Modified:    src/stores/org/apache/slide/index/lucene
                        IndexConfiguration.java
                        LuceneExpressionFactory.java properties.xml
               src/stores/org/apache/slide/index/lucene/expressions
                        AbstractExpression.java BetweenExpression.java
                        EqExpression.java GtExpression.java
                        IsDefinedExpression.java MergeExpression.java
                        PropertyContainsExpression.java
  Log:
  continued
  
  Revision  Changes    Path
  1.3       +19 -3     
jakarta-slide/src/stores/org/apache/slide/index/lucene/IndexConfiguration.java
  
  Index: IndexConfiguration.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/stores/org/apache/slide/index/lucene/IndexConfiguration.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- IndexConfiguration.java   22 Oct 2004 15:14:45 -0000      1.2
  +++ IndexConfiguration.java   25 Oct 2004 07:52:30 -0000      1.3
  @@ -115,6 +115,19 @@
           return this.indexedProperties.contains(namespace + name);
       }
       
  +    /**
  +     * Tests whether ops <code>eq</code>, <code>lt</code>, <code>ge</code>,etc
  +     * @param namespace
  +     * @param name
  +     * @return
  +     */
  +    public boolean isComparableProperty(String namespace, String name) {
  +        String key = namespace + name;
  +        return this.stringProperties.contains(key) ||
  +               this.intProperties.contains(key) ||
  +               this.dateProperties.contains(key);
  +    }
  +    
       
       public int getOptimizeThreshold() {
           return this.optimizeThreshold;
  @@ -156,14 +169,17 @@
                   child = e.getChild("string");
                   if (child != null) {
                       addStringProperty(ns, n);
  +                    addSupportsIsdefinedProperty(ns, n);
                   }
                   child = e.getChild("integer"); 
                   if (child != null) {
                       addIntProperty(ns, n);
  +                    addSupportsIsdefinedProperty(ns, n);
                   }
                   child = e.getChild("date");
                   if (child != null) {
                       addDateProperty(ns, n);
  +                    addSupportsIsdefinedProperty(ns, n);
                   }
                   child = e.getChild("text");
                   if (child != null) {
  
  
  
  1.3       +130 -52   
jakarta-slide/src/stores/org/apache/slide/index/lucene/LuceneExpressionFactory.java
  
  Index: LuceneExpressionFactory.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/stores/org/apache/slide/index/lucene/LuceneExpressionFactory.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- LuceneExpressionFactory.java      22 Oct 2004 15:14:45 -0000      1.2
  +++ LuceneExpressionFactory.java      25 Oct 2004 07:52:30 -0000      1.3
  @@ -22,7 +22,10 @@
    */
   package org.apache.slide.index.lucene;
   
  +import java.util.ArrayList;
   import java.util.Collection;
  +import java.util.Iterator;
  +import java.util.List;
   
   import org.apache.slide.content.NodeProperty;
   import org.apache.slide.index.lucene.expressions.AbstractExpression;
  @@ -40,6 +43,7 @@
   import org.apache.slide.search.BadQueryException;
   import org.apache.slide.search.PropertyProvider;
   import org.apache.slide.search.basic.BasicExpressionFactory;
  +import org.apache.slide.search.basic.ComparableResourcesPool;
   import org.apache.slide.search.basic.IBasicExpression;
   import org.apache.slide.search.basic.IBasicQuery;
   import org.apache.slide.search.basic.Literals;
  @@ -66,23 +70,58 @@
       {
           IBasicExpression result = null;
           
  -        // TODO what if expressionsToMerge contains non lucene expressions
  +        if (expressionsToMerge.size() == 0) return null; // TOCHECK
  +
  +        List luceneExpressions = new ArrayList(expressionsToMerge.size());
  +        List basicExpressions = new ArrayList(expressionsToMerge.size());
  +        for(Iterator i = expressionsToMerge.iterator(); i.hasNext();) {
  +            Object o = i.next();
  +            if (o instanceof AbstractExpression) {
  +                luceneExpressions.add(o);
  +            } else {
  +                basicExpressions.add(o);
  +            }
  +        }
           
           if (namespace.equals (NodeProperty.NamespaceCache.DEFAULT_URI)) {
               if (mergeOperator.equals(Literals.OR)) {
  -                result = new MergeExpression(this.index, false, expressionsToMerge);
  +                if (basicExpressions.size() > 0 && luceneExpressions.size() > 0) {
  +                    // a mixture
  +                    IBasicExpression e1 = new MergeExpression(this.index, false, 
luceneExpressions);
  +                    basicExpressions.add(0, e1);
  +                    result =  super.createMergeExpression(Literals.OR, namespace, 
basicExpressions);
  +                } else if (luceneExpressions.size() > 0) {
  +                    // lucene expressions only
  +                    result = new MergeExpression(this.index, false, 
expressionsToMerge);
  +                } else {
  +                    // no lucene expression
  +                    result = super.createMergeExpression(mergeOperator, 
  +                            namespace, expressionsToMerge);
  +                }
               } 
               else if (mergeOperator.equals(Literals.AND)) {
  -                result = new MergeExpression(this.index, true, expressionsToMerge);
  +                if (basicExpressions.size() > 0 && luceneExpressions.size() > 0) {
  +                    // a mixture
  +                    // TODO this could be optimized
  +                    IBasicExpression e1 = new MergeExpression(this.index, true, 
luceneExpressions);
  +                    basicExpressions.add(0, e1);
  +                    result =  super.createMergeExpression(Literals.AND, namespace, 
basicExpressions);
  +                } else if (luceneExpressions.size() > 0) {
  +                    // lucene expressions only
  +                    result = new MergeExpression(this.index, true, 
expressionsToMerge);
  +                } else {
  +                    result = super.createMergeExpression(mergeOperator, 
  +                            namespace, expressionsToMerge);
  +                }
               }
               else {
  -                // TODO
  +                super.createMergeExpression(mergeOperator, namespace, 
expressionsToMerge);
               }
           }
           if (result != null) {
               result.setFactory(this);
           }
  -        // TODO 
  +
           return result;
       }
   
  @@ -91,12 +130,9 @@
       {
           IBasicExpression result = null;
   
  -        if (element == null)
  -        {
  -            throw new BadQueryException ("expected a where criteria");
  -        }
  -        else
  -        {
  +        if (element == null) {
  +            return super.createExpression(element);
  +        } else {
               String namespace = element.getNamespace().getURI();
               if (namespace.equals (NodeProperty.NamespaceCache.DEFAULT_URI)) {
                   result = createDAVExpression(element);
  @@ -118,72 +154,106 @@
       private IBasicExpression createDAVExpression (Element e) 
           throws BadQueryException
       {
  -        String name = e.getName();
  -
  -        if (name.equals(Literals.EQ)) {
  -            return new EqExpression(this.index, e, false);
  -        } 
  -        else if (name.equals(Literals.NOT_EQ)) {
  -            return new EqExpression(this.index, e, true);
  +        String operator = e.getName();
  +        
  +        if (operator.equals(Literals.ISCOLLECTION)) {
  +            return new IsCollectionExpression(this.index, false);
           } 
  -        else if (name.equals(Literals.LT) || name.equals(Literals.NOT_GTE)) {
  -            return new LtExpression(this.index, e, false);
  -        }
  -        else if (name.equals(Literals.LTE) || name.equals(Literals.NOT_GT)) {
  -            return new LtExpression(this.index, e, true);
  +        if (operator.equals(Literals.NOT_ISCOLLECTION)) {
  +            return new IsCollectionExpression(this.index, true);
           }
  -        else if (name.equals(Literals.GT) || name.equals(Literals.NOT_LTE)) {
  -            return new GtExpression(this.index, e, false);
  +        
  +        Element property = AbstractExpression.getPropertyElement(e);
  +        String namespace = property.getNamespaceURI();
  +        String name = property.getName();
  +        IndexConfiguration configuration = index.getConfiguration();
  +        
  +        if (operator.equals(Literals.EQ)) {
  +            if (configuration.isComparableProperty(namespace, name)) {
  +                return new EqExpression(this.index, e, false);
  +            }
  +        } 
  +        else if (operator.equals(Literals.NOT_EQ)) {
  +            if (configuration.isComparableProperty(namespace, name)) {
  +                return new EqExpression(this.index, e, true);
  +            }
  +        } 
  +        else if (operator.equals(Literals.LT) || operator.equals(Literals.NOT_GTE)) 
{
  +            if (configuration.isComparableProperty(namespace, name)) {
  +                return new LtExpression(this.index, e, false);
  +            }
           }
  -        else if (name.equals(Literals.GTE) || name.equals(Literals.NOT_LT)) {
  -            return new GtExpression(this.index, e, true);
  +        else if (operator.equals(Literals.LTE) || operator.equals(Literals.NOT_GT)) 
{
  +            if (configuration.isComparableProperty(namespace, name)) {
  +                return new LtExpression(this.index, e, true);
  +            }
           }
  -        else if (name.equals(Literals.ISCOLLECTION)) {
  -            return new IsCollectionExpression(this.index, false);
  +        else if (operator.equals(Literals.GT) || operator.equals(Literals.NOT_LTE)) 
{
  +            if (configuration.isComparableProperty(namespace, name)) {
  +                return new GtExpression(this.index, e, false);
  +            }
           }
  -        else if (name.equals(Literals.NOT_ISCOLLECTION)) {
  -            return new IsCollectionExpression(this.index, true);
  +        else if (operator.equals(Literals.GTE) || operator.equals(Literals.NOT_LT)) 
{
  +            if (configuration.isComparableProperty(namespace, name)) {
  +                return new GtExpression(this.index, e, true);
  +            }
           }
  -        else if (name.equals(Literals.LIKE)) {
  -            return new LikeExpression(this.index, e);
  +        else if (operator.equals(Literals.LIKE)) {
  +            if (configuration.isStringProperty(namespace, name)) {
  +                return new LikeExpression(this.index, e);
  +            }
           }
  -        else if (name.equals(Literals.ISDEFINED)) {
  -            Element property = AbstractExpression.getPropertyElement(e);
  -            if 
(index.getConfiguration().supportsIsDefined(property.getNamespaceURI(), 
property.getName())) {
  +        else if (operator.equals(Literals.ISDEFINED)) {
  +            if (configuration.supportsIsDefined(namespace, name)) {
                   return new IsDefinedExpression(this.index, e, false);
               }
           }
  -        else if (name.equals(Literals.NOT_ISDEFINED)) {
  -            Element property = AbstractExpression.getPropertyElement(e);
  -            if 
(index.getConfiguration().supportsIsDefined(property.getNamespaceURI(), 
property.getName())) {
  +        else if (operator.equals(Literals.NOT_ISDEFINED)) {
  +            if (configuration.supportsIsDefined(namespace, name)) {
                   return new IsDefinedExpression(this.index, e, true);
               }
           }
  +        
  +        // fallback: if we don't know the operator or the property is not 
  +        // supported with the given operator
           return super.createExpression(e);
       }
       
       private IBasicExpression createSlideExpression(Element e) 
           throws BadQueryException
       {
  -        String name = e.getName();
  +        String operator = e.getName();
           
  -        if (name.equals(Literals.ISPRINCIPAL)) {
  +        if (operator.equals(Literals.ISPRINCIPAL)) {
               return new IsPrincipalExpression(this.index, false);
           }
  -        if (name.equals(Literals.NOT_ISPRINCIPAL)) {
  +        if (operator.equals(Literals.NOT_ISPRINCIPAL)) {
               return new IsPrincipalExpression(this.index, true);
           }
  -        if (name.equals(Literals.PROPCONTAINS)) {
  +        if (operator.equals(Literals.PROPCONTAINS)) {
               return new PropcontainsExpression(this.index, e);
           }
  -        if (name.equals("between")) {
  -            return new BetweenExpression(this.index, e, false);
  +        
  +        Element property = AbstractExpression.getPropertyElement(e);
  +        String namespace = property.getNamespaceURI();
  +        String name = property.getName();
  +        IndexConfiguration configuration = index.getConfiguration();
  +
  +        // TODO not-between
  +        if (operator.equals("between")) {
  +            if (configuration.isComparableProperty(namespace, name)) {
  +                return new BetweenExpression(this.index, e, false);
  +            }
           }
  -        if (name.equals("between-inclusive")) {
  -            return new BetweenExpression(this.index, e, true);
  +        if (operator.equals("between-inclusive")) {
  +            if (configuration.isComparableProperty(namespace, name)) {
  +                return new BetweenExpression(this.index, e, true);
  +            }
           }
  -        if (name.equals("property-contains")) {
  -            return new PropertyContainsExpression(this.index, e);
  +        if (operator.equals("property-contains")) {
  +            if (configuration.isTextProperty(namespace, name)) {
  +                return new PropertyContainsExpression(this.index, e);
  +            }
           }
           return super.createExpression(e);
       }
  @@ -202,5 +272,13 @@
       {
           this.query = (IBasicQuery) query;
           this.propertyProvider = propertyProvider;
  +    }
  +
  +
  +    protected ComparableResourcesPool getRequestedResourcePool()
  +            throws BadQueryException
  +    {
  +        // TODO Auto-generated method stub
  +        return super.getRequestedResourcePool();
       }
   }
  
  
  
  1.2       +8 -5      
jakarta-slide/src/stores/org/apache/slide/index/lucene/properties.xml
  
  Index: properties.xml
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/stores/org/apache/slide/index/lucene/properties.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- properties.xml    22 Oct 2004 15:14:45 -0000      1.1
  +++ properties.xml    25 Oct 2004 07:52:30 -0000      1.2
  @@ -18,25 +18,28 @@
     <d:creationdate>
       <date/>
     </d:creationdate>
  -  <d:modificationdate>
  -    <date/>
  -  </d:modificationdate>
  -  
   
     <d:owner>
       <string/><is-defined/>
     </d:owner>
  +
  +  <!-- they are updated quite often, e.g. for each collection where a member
  +       is added ore removed
  +  <d:modificationdate>
  +    <date/>
  +  </d:modificationdate>
     <d:modificationuser>
       <string/><is-defined/>
     </d:modificationuser>
  +  -->
   
  +  <!-- TODO what about href properties -->
     <d:checked-in>
       <string/><is-defined/>
     </d:checked-in>
     <d:checked-out>
       <string/><is-defined/>
     </d:checked-out>
  -
   
   </indexed-properties>
   
  
  
  
  1.2       +65 -20    
jakarta-slide/src/stores/org/apache/slide/index/lucene/expressions/AbstractExpression.java
  
  Index: AbstractExpression.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/stores/org/apache/slide/index/lucene/expressions/AbstractExpression.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AbstractExpression.java   18 Oct 2004 09:27:36 -0000      1.1
  +++ AbstractExpression.java   25 Oct 2004 07:52:30 -0000      1.2
  @@ -23,7 +23,9 @@
   package org.apache.slide.index.lucene.expressions;
   
   import java.io.IOException;
  +import java.util.Iterator;
   import java.util.List;
  +import java.util.Set;
   
   import org.apache.lucene.document.Document;
   import org.apache.lucene.index.Term;
  @@ -36,12 +38,16 @@
   import org.apache.slide.common.SlideException;
   import org.apache.slide.content.NodeProperty;
   import org.apache.slide.index.lucene.Index;
  +import org.apache.slide.index.lucene.LuceneExpressionFactory;
   import org.apache.slide.search.BadQueryException;
  +import org.apache.slide.search.InvalidQueryException;
   import org.apache.slide.search.InvalidScopeException;
  +import org.apache.slide.search.QueryScope;
   import org.apache.slide.search.RequestedResource;
   import org.apache.slide.search.SearchException;
   import org.apache.slide.search.basic.BasicResultSetImpl;
   import org.apache.slide.search.basic.ComparableResourceImpl;
  +import org.apache.slide.search.basic.ComparableResourcesPool;
   import org.apache.slide.search.basic.IBasicExpression;
   import org.apache.slide.search.basic.IBasicExpressionFactory;
   import org.apache.slide.search.basic.IBasicQuery;
  @@ -53,15 +59,16 @@
   
   
   /**
  - * @author Stefan L�tzkendorf
  + * 
    */
  -public abstract class AbstractExpression implements IBasicExpression
  +public abstract class AbstractExpression implements IBasicExpression, 
ComparableResourcesPool
   {
   
       static final String LOG_CHANNEL = "org.apache.slide.index.lucene.expressions";
       
  -    protected IBasicExpressionFactory factory;
  +    protected LuceneExpressionFactory factory;
       protected Index index;
  +    private IBasicResultSet resultSet = null;
       
       private Query query;
       
  @@ -83,28 +90,36 @@
   
       public void setFactory(IBasicExpressionFactory factory)
       {
  -        this.factory = factory;
  +        this.factory = (LuceneExpressionFactory)factory;
       }
   
       
       public IBasicResultSet execute() throws SearchException
       {
  +        if (this.resultSet != null) {
  +            return this.resultSet;
  +        }
  +        
           Query luceneQuery = this.getQuery();
           
           IBasicQuery q = factory.getQuery();
  -        String scope = 
q.getSearchToken().getSlideContext().getSlidePath(q.getScope().getHref());
  -
  -        if (!scope.equals("/")) {
  -            // add a scope restriction
  -            BooleanQuery booleanQuery = new BooleanQuery();
  -            booleanQuery.add(luceneQuery, true, false);
  -            booleanQuery.add(new TermQuery(new Term(Index.SCOPE_FIELD_NAME, 
scope)), true, false);
  -            luceneQuery = booleanQuery;
  +        String scope = q.getSearchToken().getSlideContext().getSlidePath(
  +                q.getScope().getHref());
  +        if (scope.endsWith("/") && scope.length() > 1) {
  +            scope = scope.substring(0, scope.length()-1);
           }
   
  +        // add a scope restriction, this allows negated queries too
  +        BooleanQuery booleanQuery = new BooleanQuery();
  +        booleanQuery.add(new TermQuery(new Term(Index.SCOPE_FIELD_NAME, scope)), 
  +                true, false);
  +        booleanQuery.add(luceneQuery, true, false);
  +        luceneQuery = booleanQuery;
  +
           IndexSearcher searcher = null;
           try {
  -            index.getLogger().log("start query execution: " + 
luceneQuery.toString(), LOG_CHANNEL, Logger.DEBUG);
  +            index.getLogger().log("start query execution: " + 
  +                    luceneQuery.toString(), LOG_CHANNEL, Logger.DEBUG);
               long start = System.currentTimeMillis();
       
               searcher = this.index.getSearcher();
  @@ -122,6 +137,7 @@
                   result.add(resource);
               }
               
  +            this.resultSet = result;
               return result;
           } catch (InvalidScopeException e) {
               throw e;
  @@ -189,10 +205,10 @@
       {
           Element prop = operator.getChild("prop", 
                   NodeProperty.NamespaceCache.DEFAULT_NAMESPACE);
  -        if (prop == null) throw new BadQueryException("Missing prop element"); 
  +        if (prop == null) throw new InvalidQueryException("Missing prop element"); 
           
           prop = getFirstElement(prop);
  -        if (prop == null) throw new BadQueryException("Empty prop element given");
  +        if (prop == null) throw new InvalidQueryException("Empty prop element 
given");
           return prop;
       }
       /**
  @@ -205,7 +221,7 @@
       {
           Element literal = operator.getChild("literal", 
                   NodeProperty.NamespaceCache.DEFAULT_NAMESPACE);
  -        if (literal == null) throw new BadQueryException("Missing literal element");
  +        if (literal == null) throw new InvalidQueryException("Missing literal 
element");
           return literal;
       }    
   
  @@ -216,7 +232,36 @@
           if (children.size() > 1) {
               return (Element)children.get(1);
           } else {
  -            throw new BadQueryException("Missing second literal element");
  +            throw new InvalidQueryException("Missing second literal element");
  +        }
  +    }
  +    
  +    
  +    
  +    
  +    public Set getPool() throws BadQueryException
  +    {   
  +        try {
  +            return execute();
  +        } catch (SearchException e) {
  +            throw new BadQueryException("Can't compute ComparableResourcesPool", e);
  +        }
  +    }
  +    public QueryScope getScope()
  +    {
  +        // TODO Auto-generated method stub
  +        return null;
  +    }
  +    public boolean partialResult()
  +    {
  +        return false;
  +    }
  +    public Iterator resourceIterator()
  +    {
  +        try {
  +            return getPool().iterator();
  +        } catch (BadQueryException e) {
  +            throw new RuntimeException("Ooops", e);
           }
       }
   }
  
  
  
  1.3       +6 -5      
jakarta-slide/src/stores/org/apache/slide/index/lucene/expressions/BetweenExpression.java
  
  Index: BetweenExpression.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/stores/org/apache/slide/index/lucene/expressions/BetweenExpression.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- BetweenExpression.java    22 Oct 2004 15:14:46 -0000      1.2
  +++ BetweenExpression.java    25 Oct 2004 07:52:30 -0000      1.3
  @@ -33,13 +33,14 @@
   
   
   /**
  - * Implements a slide specific <code>between</code> operator.
  + * Implements a slide specific <code>between</code> and 
  + * <code>between-inclusive</code> operators.
    * 
    * <p>
    * With lucene <code>(between prop val1 val2)</code> will be much more efficient 
    * than <code>(and (gt prop1 val1) (lt prop val2))</code>.
    * 
  - * <p>TODO May be could optimize such expressions by transformation.   
  + * <p>TODO May be we could optimize such expressions by transformation.   
    * 
    * <p>Usage:
    * <pre>
  
  
  
  1.3       +14 -3     
jakarta-slide/src/stores/org/apache/slide/index/lucene/expressions/EqExpression.java
  
  Index: EqExpression.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/stores/org/apache/slide/index/lucene/expressions/EqExpression.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- EqExpression.java 22 Oct 2004 15:14:46 -0000      1.2
  +++ EqExpression.java 25 Oct 2004 07:52:30 -0000      1.3
  @@ -23,6 +23,7 @@
   package org.apache.slide.index.lucene.expressions;
   
   import org.apache.lucene.index.Term;
  +import org.apache.lucene.search.BooleanQuery;
   import org.apache.lucene.search.TermQuery;
   
   import org.apache.slide.index.lucene.Index;
  @@ -60,5 +61,15 @@
           Term term = new Term(field, value);
           
           setQuery(new TermQuery(term));
  +
  +        if (negated) {
  +            BooleanQuery booleanQuery = new BooleanQuery();
  +            booleanQuery.add(
  +                    new TermQuery(new Term(Index.IS_DEFINED_FIELD_NAME, field)),
  +                    true, false);
  +            booleanQuery.add(getQuery(),
  +                    false, true);
  +            setQuery(booleanQuery);
  +        }
       }
   }
  
  
  
  1.3       +4 -4      
jakarta-slide/src/stores/org/apache/slide/index/lucene/expressions/GtExpression.java
  
  Index: GtExpression.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/stores/org/apache/slide/index/lucene/expressions/GtExpression.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- GtExpression.java 22 Oct 2004 15:14:46 -0000      1.2
  +++ GtExpression.java 25 Oct 2004 07:52:30 -0000      1.3
  @@ -60,7 +60,7 @@
           } 
           else {
               value = literal.getTextTrim();
  -            upperBound = "ZZZZZZZZ"; //TODO
  +            upperBound = "\uffff\uffff"; //TODO
           }
           
           
  
  
  
  1.3       +5 -4      
jakarta-slide/src/stores/org/apache/slide/index/lucene/expressions/IsDefinedExpression.java
  
  Index: IsDefinedExpression.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/stores/org/apache/slide/index/lucene/expressions/IsDefinedExpression.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- IsDefinedExpression.java  22 Oct 2004 15:14:46 -0000      1.2
  +++ IsDefinedExpression.java  25 Oct 2004 07:52:30 -0000      1.3
  @@ -32,7 +32,8 @@
   
   
   /**
  - * @author Stefan L�tzkendorf
  + * Implements the <code>is-defined</code> and the <code>not-is-defined</code>
  + * expression.
    */
   public class IsDefinedExpression extends AbstractExpression
   {
  
  
  
  1.2       +13 -22    
jakarta-slide/src/stores/org/apache/slide/index/lucene/expressions/MergeExpression.java
  
  Index: MergeExpression.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/stores/org/apache/slide/index/lucene/expressions/MergeExpression.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MergeExpression.java      18 Oct 2004 09:27:36 -0000      1.1
  +++ MergeExpression.java      25 Oct 2004 07:52:30 -0000      1.2
  @@ -40,30 +40,21 @@
        * Constructor.
        * @param index The index to be searched.
        * @param and <code>true</code> if AND or <code>false</code> if OR
  -     * @param expressions list of expressions
  +     * @param expressions list of expressions (must all be derived from 
  +     *        [EMAIL PROTECTED] AbstractExpression}, i.e. must all be lucene 
executable)
        */
       public MergeExpression(Index index, boolean and, Collection expressions)
       {
           super(index);
           
  -        if (expressions.size() > 0) {
  -            BooleanQuery booleanQuery = new BooleanQuery();
  -            
  -            for(Iterator i = expressions.iterator(); i.hasNext();) {
  -                Object e = i.next();
  -                if (e instanceof AbstractExpression) {
  -                    Query q = ((AbstractExpression)e).getQuery();
  -                    booleanQuery.add(q, and, false);
  -                } else {
  -                    // TODO
  -                    System.out.println("merge with non lucene expression");
  -                }
  -            }
  -            
  -            setQuery(booleanQuery);
  -        } else {
  -            // TODO
  -            System.out.println("merge without expressions");
  +        BooleanQuery booleanQuery = new BooleanQuery();
  +        
  +        for(Iterator i = expressions.iterator(); i.hasNext();) {
  +            Object e = i.next();
  +            Query q = ((AbstractExpression)e).getQuery();
  +            booleanQuery.add(q, and, false);
           }
  +        
  +        setQuery(booleanQuery);
       }
   }
  
  
  
  1.2       +22 -1     
jakarta-slide/src/stores/org/apache/slide/index/lucene/expressions/PropertyContainsExpression.java
  
  Index: PropertyContainsExpression.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/stores/org/apache/slide/index/lucene/expressions/PropertyContainsExpression.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PropertyContainsExpression.java   22 Oct 2004 15:14:46 -0000      1.1
  +++ PropertyContainsExpression.java   25 Oct 2004 07:52:30 -0000      1.2
  @@ -1,4 +1,25 @@
  -// vi: set ts=3 sw=3:
  +/*
  + * $Header$
  + * $Revision$
  + * $Date$
  + *
  + * ====================================================================
  + *
  + * Copyright 1999-2004 The Apache Software Foundation
  + *
  + * Licensed under the Apache License, Version 2.0 (the "License");
  + * you may not use this file except in compliance with the License.
  + * You may obtain a copy of the License at
  + *
  + *     http://www.apache.org/licenses/LICENSE-2.0
  + *
  + * Unless required by applicable law or agreed to in writing, software
  + * distributed under the License is distributed on an "AS IS" BASIS,
  + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  + * See the License for the specific language governing permissions and
  + * limitations under the License.
  + *
  + */
   package org.apache.slide.index.lucene.expressions;
   
   import java.io.IOException;
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to