MtasSpanSequenceQuery.java

  1. package mtas.search.spans;

  2. import java.io.IOException;
  3. import java.util.ArrayList;
  4. import java.util.Iterator;
  5. import java.util.List;
  6. import java.util.Map;
  7. import java.util.Set;

  8. import org.apache.lucene.index.IndexReader;
  9. import org.apache.lucene.index.LeafReaderContext;
  10. import org.apache.lucene.index.Term;
  11. import org.apache.lucene.index.TermContext;
  12. import org.apache.lucene.index.Terms;
  13. import org.apache.lucene.search.IndexSearcher;
  14. import org.apache.lucene.search.spans.SpanWeight;
  15. import org.apache.lucene.search.spans.Spans;

  16. import mtas.search.spans.util.MtasExpandSpanQuery;
  17. import mtas.search.spans.util.MtasIgnoreItem;
  18. import mtas.search.spans.util.MtasSpanQuery;
  19. import mtas.search.spans.util.MtasSpanWeight;
  20. import mtas.search.spans.util.MtasSpans;

  21. /**
  22.  * The Class MtasSpanSequenceQuery.
  23.  */
  24. public class MtasSpanSequenceQuery extends MtasSpanQuery {

  25.   /** The items. */
  26.   private List<MtasSpanSequenceItem> items;

  27.   /** The left minimum. */
  28.   private int leftMinimum;

  29.   /** The left maximum. */
  30.   private int leftMaximum;

  31.   /** The right minimum. */
  32.   private int rightMinimum;

  33.   /** The right maximum. */
  34.   private int rightMaximum;

  35.   /** The ignore query. */
  36.   private MtasSpanQuery ignoreQuery;

  37.   /** The maximum ignore length. */
  38.   private Integer maximumIgnoreLength;

  39.   /** The field. */
  40.   private String field;

  41.   /**
  42.    * Instantiates a new mtas span sequence query.
  43.    *
  44.    * @param items the items
  45.    * @param ignoreQuery the ignore query
  46.    * @param maximumIgnoreLength the maximum ignore length
  47.    */
  48.   public MtasSpanSequenceQuery(List<MtasSpanSequenceItem> items,
  49.       MtasSpanQuery ignoreQuery, Integer maximumIgnoreLength) {
  50.     this(items, 0, 0, 0, 0, ignoreQuery, maximumIgnoreLength);
  51.   }

  52.   /**
  53.    * Instantiates a new mtas span sequence query.
  54.    *
  55.    * @param items the items
  56.    * @param leftMinimum the left minimum
  57.    * @param leftMaximum the left maximum
  58.    * @param rightMinimum the right minimum
  59.    * @param rightMaximum the right maximum
  60.    * @param ignoreQuery the ignore query
  61.    * @param maximumIgnoreLength the maximum ignore length
  62.    */
  63.   public MtasSpanSequenceQuery(List<MtasSpanSequenceItem> items,
  64.       int leftMinimum, int leftMaximum, int rightMinimum, int rightMaximum,
  65.       MtasSpanQuery ignoreQuery, Integer maximumIgnoreLength) {
  66.     super(null, null);
  67.     this.items = items;
  68.     this.leftMinimum = leftMinimum;
  69.     this.leftMaximum = leftMaximum;
  70.     this.rightMinimum = rightMinimum;
  71.     this.rightMaximum = rightMaximum;
  72.     // get field and do checks
  73.     Integer minimum = leftMinimum + rightMinimum;
  74.     Integer maximum = leftMaximum + rightMaximum;
  75.     for (MtasSpanSequenceItem item : items) {
  76.       if (field == null) {
  77.         field = item.getQuery().getField();
  78.       } else if (item.getQuery().getField() != null
  79.           && !item.getQuery().getField().equals(field)) {
  80.         throw new IllegalArgumentException("Clauses must have same field.");
  81.       }
  82.       if (minimum != null && !item.isOptional()) {
  83.         minimum = item.getQuery().getMinimumWidth() != null
  84.             ? minimum + item.getQuery().getMinimumWidth() : null;
  85.       }
  86.       if (maximum != null) {
  87.         maximum = item.getQuery().getMaximumWidth() != null
  88.             ? maximum + item.getQuery().getMaximumWidth() : null;
  89.       }
  90.     }
  91.     // check ignore
  92.     if (field != null && ignoreQuery != null) {
  93.       if (ignoreQuery.getField() == null
  94.           || field.equals(ignoreQuery.getField())) {
  95.         this.ignoreQuery = ignoreQuery;
  96.         if (maximumIgnoreLength == null) {
  97.           this.maximumIgnoreLength = MtasIgnoreItem.DEFAULT_MAXIMUM_IGNORE_LENGTH;
  98.         } else {
  99.           this.maximumIgnoreLength = maximumIgnoreLength;
  100.         }
  101.       } else {
  102.         throw new IllegalArgumentException(
  103.             "ignore must have same field as clauses");
  104.       }
  105.       if (maximum != null && items.size() > 1) {
  106.         if (this.ignoreQuery.getMaximumWidth() != null) {
  107.           maximum += (items.size() - 1) * this.maximumIgnoreLength
  108.               * this.ignoreQuery.getMaximumWidth();
  109.         } else {
  110.           maximum = null;
  111.         }
  112.       }
  113.     } else {
  114.       this.ignoreQuery = null;
  115.       this.maximumIgnoreLength = null;
  116.     }
  117.     setWidth(minimum, maximum);
  118.   }

  119.   /*
  120.    * (non-Javadoc)
  121.    *
  122.    * @see org.apache.lucene.search.spans.SpanQuery#getField()
  123.    */
  124.   @Override
  125.   public String getField() {
  126.     return field;
  127.   }

  128.   /**
  129.    * Gets the items.
  130.    *
  131.    * @return the items
  132.    */
  133.   public List<MtasSpanSequenceItem> getItems() {
  134.     return items;
  135.   }

  136.   /**
  137.    * Gets the ignore query.
  138.    *
  139.    * @return the ignore query
  140.    */
  141.   public MtasSpanQuery getIgnoreQuery() {
  142.     return ignoreQuery;
  143.   }

  144.   /**
  145.    * Gets the maximum ignore length.
  146.    *
  147.    * @return the maximum ignore length
  148.    */
  149.   public Integer getMaximumIgnoreLength() {
  150.     return maximumIgnoreLength;
  151.   }

  152.   /*
  153.    * (non-Javadoc)
  154.    *
  155.    * @see
  156.    * org.apache.lucene.search.Query#rewrite(org.apache.lucene.index.IndexReader)
  157.    */
  158.   @Override
  159.   public MtasSpanQuery rewrite(IndexReader reader) throws IOException {
  160.     if (items.size() == 1) {
  161.       MtasSpanQuery singleQuery = items.get(0).getQuery();
  162.       if (leftMaximum != 0 || rightMaximum != 0) {
  163.         singleQuery = new MtasExpandSpanQuery(singleQuery, leftMinimum,
  164.             leftMaximum, rightMinimum, rightMaximum);
  165.       }
  166.       return singleQuery.rewrite(reader);
  167.     } else {
  168.       MtasSpanSequenceItem newItem;
  169.       MtasSpanSequenceItem previousNewItem = null;
  170.       ArrayList<MtasSpanSequenceItem> newItems = new ArrayList<>(items.size());
  171.       int newLeftMinimum = leftMinimum;
  172.       int newLeftMaximum = leftMaximum;
  173.       int newRightMinimum = rightMinimum;
  174.       int newRightMaximum = rightMaximum;
  175.       MtasSpanQuery newIgnoreClause = ignoreQuery != null
  176.           ? ignoreQuery.rewrite(reader) : null;
  177.       boolean actuallyRewritten = ignoreQuery != null
  178.           ? !newIgnoreClause.equals(ignoreQuery) : false;
  179.       for (int i = 0; i < items.size(); i++) {
  180.         newItem = items.get(i).rewrite(reader);
  181.         if (newItem.getQuery() instanceof MtasSpanMatchNoneQuery) {
  182.           if (!newItem.isOptional()) {
  183.             return new MtasSpanMatchNoneQuery(field);
  184.           } else {
  185.             actuallyRewritten = true;
  186.           }
  187.         } else {
  188.           actuallyRewritten |= !items.get(i).equals(newItem);
  189.           MtasSpanSequenceItem previousMergedItem = MtasSpanSequenceItem.merge(
  190.               previousNewItem, newItem, ignoreQuery, maximumIgnoreLength);
  191.           if (previousMergedItem != null) {
  192.             newItems.set((newItems.size() - 1), previousMergedItem);
  193.             actuallyRewritten = true;
  194.           } else {
  195.             newItems.add(newItem);
  196.           }
  197.           previousNewItem = newItem;
  198.         }
  199.       }
  200.       // check first and last
  201.       if (ignoreQuery == null) {
  202.         ArrayList<MtasSpanSequenceItem> possibleTrimmedItems = new ArrayList<>(
  203.             newItems.size());
  204.         MtasSpanSequenceItem firstItem = newItems.get(0);
  205.         MtasSpanQuery firstQuery = firstItem.getQuery();
  206.         if (firstQuery instanceof MtasSpanMatchAllQuery) {
  207.           newLeftMaximum++;
  208.           if (!firstItem.isOptional()) {
  209.             newLeftMinimum++;
  210.           }
  211.         } else if (firstQuery instanceof MtasSpanRecurrenceQuery) {
  212.           MtasSpanRecurrenceQuery firstRecurrenceQuery = (MtasSpanRecurrenceQuery) firstQuery;
  213.           if (firstRecurrenceQuery.getQuery() instanceof MtasSpanMatchAllQuery
  214.               && firstRecurrenceQuery.getIgnoreQuery() == null) {
  215.             if (!firstItem.isOptional()) {
  216.               newLeftMinimum += firstRecurrenceQuery.getMinimumRecurrence();
  217.               newLeftMaximum += firstRecurrenceQuery.getMaximumRecurrence();
  218.             } else {
  219.               if (firstRecurrenceQuery.getMinimumRecurrence() == 1
  220.                   || firstRecurrenceQuery
  221.                       .getMinimumRecurrence() <= newLeftMinimum) {
  222.                 newLeftMinimum += 0;
  223.                 newLeftMaximum += firstRecurrenceQuery.getMaximumRecurrence();
  224.               } else {
  225.                 possibleTrimmedItems.add(firstItem);
  226.               }
  227.             }
  228.           } else {
  229.             possibleTrimmedItems.add(firstItem);
  230.           }
  231.         } else {
  232.           possibleTrimmedItems.add(firstItem);
  233.         }
  234.         for (int i = 1; i < (newItems.size() - 1); i++) {
  235.           possibleTrimmedItems.add(newItems.get(i));
  236.         }
  237.         if (newItems.size() > 1) {
  238.           MtasSpanSequenceItem lastItem = newItems.get((newItems.size() - 1));
  239.           MtasSpanQuery lastQuery = lastItem.getQuery();
  240.           if (lastQuery instanceof MtasSpanMatchAllQuery) {
  241.             newRightMaximum++;
  242.             if (!lastItem.isOptional()) {
  243.               newRightMinimum++;
  244.             }
  245.           } else if (lastQuery instanceof MtasSpanRecurrenceQuery) {
  246.             MtasSpanRecurrenceQuery lastRecurrenceQuery = (MtasSpanRecurrenceQuery) lastQuery;
  247.             if (lastRecurrenceQuery.getQuery() instanceof MtasSpanMatchAllQuery
  248.                 && lastRecurrenceQuery.getIgnoreQuery() == null) {
  249.               if (!lastItem.isOptional()) {
  250.                 newRightMinimum += lastRecurrenceQuery.getMinimumRecurrence();
  251.                 newRightMaximum += lastRecurrenceQuery.getMaximumRecurrence();
  252.               } else if (lastRecurrenceQuery.getMinimumRecurrence() == 1
  253.                   || lastRecurrenceQuery
  254.                       .getMinimumRecurrence() <= newRightMinimum) {
  255.                 newRightMinimum += 0;
  256.                 newRightMaximum += lastRecurrenceQuery.getMaximumRecurrence();
  257.               } else {
  258.                 possibleTrimmedItems.add(lastItem);
  259.               }
  260.             } else {
  261.               possibleTrimmedItems.add(lastItem);
  262.             }
  263.           } else {
  264.             possibleTrimmedItems.add(lastItem);
  265.           }
  266.         }
  267.         if (possibleTrimmedItems.size() < newItems.size()) {
  268.           actuallyRewritten = true;
  269.           newItems = possibleTrimmedItems;
  270.         }
  271.       }
  272.       if (!actuallyRewritten) {
  273.         if (leftMaximum != 0 || rightMaximum != 0) {
  274.           newLeftMinimum = leftMinimum;
  275.           newLeftMaximum = leftMaximum;
  276.           newRightMinimum = rightMinimum;
  277.           newRightMaximum = rightMaximum;
  278.           leftMinimum = 0;
  279.           leftMaximum = 0;
  280.           rightMinimum = 0;
  281.           rightMaximum = 0;
  282.           MtasSpanQuery finalQuery = new MtasExpandSpanQuery(this,
  283.               newLeftMinimum, newLeftMaximum, newRightMinimum, newRightMaximum);
  284.           return finalQuery.rewrite(reader);
  285.         } else {
  286.           return super.rewrite(reader);
  287.         }
  288.       } else {
  289.         if (!newItems.isEmpty()) {
  290.           return new MtasSpanSequenceQuery(newItems, newLeftMinimum,
  291.               newLeftMaximum, newRightMinimum, newRightMaximum, newIgnoreClause,
  292.               maximumIgnoreLength).rewrite(reader);
  293.         } else {
  294.           return new MtasSpanMatchNoneQuery(field);
  295.         }
  296.       }
  297.     }
  298.   }

  299.   /*
  300.    * (non-Javadoc)
  301.    *
  302.    * @see org.apache.lucene.search.Query#toString(java.lang.String)
  303.    */
  304.   @Override
  305.   public String toString(String field) {
  306.     StringBuilder buffer = new StringBuilder();
  307.     buffer.append(this.getClass().getSimpleName() + "([");
  308.     Iterator<MtasSpanSequenceItem> i = items.iterator();
  309.     while (i.hasNext()) {
  310.       MtasSpanSequenceItem item = i.next();
  311.       MtasSpanQuery clause = item.getQuery();
  312.       buffer.append(clause.toString(field));
  313.       if (item.isOptional()) {
  314.         buffer.append("{OPTIONAL}");
  315.       }
  316.       if (i.hasNext()) {
  317.         buffer.append(", ");
  318.       }
  319.     }
  320.     buffer.append("[" + leftMinimum + "," + leftMaximum + "]");
  321.     buffer.append("[" + rightMinimum + "," + rightMaximum + "]");
  322.     buffer.append("]");
  323.     buffer.append(", ");
  324.     buffer.append(ignoreQuery);
  325.     buffer.append(")");
  326.     return buffer.toString();
  327.   }

  328.   /*
  329.    * (non-Javadoc)
  330.    *
  331.    * @see org.apache.lucene.search.Query#equals(java.lang.Object)
  332.    */
  333.   @Override
  334.   public boolean equals(Object obj) {
  335.     if (this == obj)
  336.       return true;
  337.     if (obj == null)
  338.       return false;
  339.     if (getClass() != obj.getClass())
  340.       return false;
  341.     MtasSpanSequenceQuery other = (MtasSpanSequenceQuery) obj;
  342.     boolean isEqual;
  343.     isEqual = field.equals(other.field);
  344.     isEqual &= items.equals(other.items);
  345.     isEqual &= leftMinimum == other.leftMinimum;
  346.     isEqual &= leftMaximum == other.leftMaximum;
  347.     isEqual &= rightMinimum == other.rightMinimum;
  348.     isEqual &= rightMaximum == other.rightMaximum;
  349.     isEqual &= ((ignoreQuery == null && other.ignoreQuery == null)
  350.         || (ignoreQuery != null && other.ignoreQuery != null
  351.             && ignoreQuery.equals(other.ignoreQuery)));
  352.     return isEqual;
  353.   }

  354.   /*
  355.    * (non-Javadoc)
  356.    *
  357.    * @see org.apache.lucene.search.Query#hashCode()
  358.    */
  359.   @Override
  360.   public int hashCode() {
  361.     int h = this.getClass().getSimpleName().hashCode();
  362.     h = (h * 3) ^ field.hashCode();
  363.     h = (h * 5) ^ items.hashCode();
  364.     h = Integer.rotateLeft(h, leftMinimum) + leftMinimum;
  365.     h ^= 11;
  366.     h = Integer.rotateLeft(h, leftMaximum) + leftMaximum;
  367.     h ^= 13;
  368.     h = Integer.rotateLeft(h, rightMinimum) + rightMinimum;
  369.     h ^= 17;
  370.     h = Integer.rotateLeft(h, rightMaximum) + rightMaximum;
  371.     if (ignoreQuery != null) {
  372.       h = (h * 7) ^ ignoreQuery.hashCode();
  373.       h = (h * 11) ^ maximumIgnoreLength.hashCode();
  374.     }
  375.     return h;
  376.   }

  377.   /*
  378.    * (non-Javadoc)
  379.    *
  380.    * @see
  381.    * org.apache.lucene.search.spans.SpanQuery#createWeight(org.apache.lucene.
  382.    * search.IndexSearcher, boolean)
  383.    */
  384.   @Override
  385.   public MtasSpanWeight createWeight(IndexSearcher searcher,
  386.       boolean needsScores, float boost) throws IOException {
  387.     List<MtasSpanSequenceQueryWeight> subWeights = new ArrayList<>();
  388.     SpanWeight ignoreWeight = null;
  389.     for (MtasSpanSequenceItem item : items) {
  390.       subWeights.add(new MtasSpanSequenceQueryWeight(
  391.           item.getQuery().createWeight(searcher, false, boost), item.isOptional()));
  392.     }
  393.     if (ignoreQuery != null) {
  394.       ignoreWeight = ignoreQuery.createWeight(searcher, false, boost);
  395.     }
  396.     return new SpanSequenceWeight(subWeights, ignoreWeight, maximumIgnoreLength,
  397.         searcher, needsScores ? getTermContexts(subWeights) : null, boost);
  398.   }

  399.   /**
  400.    * Gets the term contexts.
  401.    *
  402.    * @param items the items
  403.    * @return the term contexts
  404.    */
  405.   protected Map<Term, TermContext> getTermContexts(
  406.       List<MtasSpanSequenceQueryWeight> items) {
  407.     List<SpanWeight> weights = new ArrayList<>();
  408.     for (MtasSpanSequenceQueryWeight item : items) {
  409.       weights.add(item.spanWeight);
  410.     }
  411.     return getTermContexts(weights);
  412.   }

  413.   /*
  414.    * (non-Javadoc)
  415.    *
  416.    * @see mtas.search.spans.util.MtasSpanQuery#disableTwoPhaseIterator()
  417.    */
  418.   @Override
  419.   public void disableTwoPhaseIterator() {
  420.     super.disableTwoPhaseIterator();
  421.     for (MtasSpanSequenceItem item : items) {
  422.       item.getQuery().disableTwoPhaseIterator();
  423.     }
  424.     if (ignoreQuery != null) {
  425.       ignoreQuery.disableTwoPhaseIterator();
  426.     }
  427.   }

  428.   /**
  429.    * The Class SpanSequenceWeight.
  430.    */
  431.   protected class SpanSequenceWeight extends MtasSpanWeight {

  432.     /** The sub weights. */
  433.     final List<MtasSpanSequenceQueryWeight> subWeights;

  434.     /** The ignore weight. */
  435.     final SpanWeight ignoreWeight;

  436.     /** The maximum ignore length. */
  437.     final Integer maximumIgnoreLength;

  438.     /**
  439.      * Instantiates a new span sequence weight.
  440.      *
  441.      * @param subWeights the sub weights
  442.      * @param ignoreWeight the ignore weight
  443.      * @param maximumIgnoreLength the maximum ignore length
  444.      * @param searcher the searcher
  445.      * @param terms the terms
  446.      * @throws IOException Signals that an I/O exception has occurred.
  447.      */
  448.     public SpanSequenceWeight(List<MtasSpanSequenceQueryWeight> subWeights,
  449.         SpanWeight ignoreWeight, Integer maximumIgnoreLength,
  450.         IndexSearcher searcher, Map<Term, TermContext> terms, float boost)
  451.         throws IOException {
  452.       super(MtasSpanSequenceQuery.this, searcher, terms, boost);
  453.       this.subWeights = subWeights;
  454.       this.ignoreWeight = ignoreWeight;
  455.       this.maximumIgnoreLength = maximumIgnoreLength;
  456.     }

  457.     /*
  458.      * (non-Javadoc)
  459.      *
  460.      * @see
  461.      * org.apache.lucene.search.spans.SpanWeight#extractTermContexts(java.util.
  462.      * Map)
  463.      */
  464.     @Override
  465.     public void extractTermContexts(Map<Term, TermContext> contexts) {
  466.       for (MtasSpanSequenceQueryWeight w : subWeights) {
  467.         w.spanWeight.extractTermContexts(contexts);
  468.       }
  469.       if (ignoreWeight != null) {
  470.         ignoreWeight.extractTermContexts(contexts);
  471.       }
  472.     }

  473.     /*
  474.      * (non-Javadoc)
  475.      *
  476.      * @see
  477.      * org.apache.lucene.search.spans.SpanWeight#getSpans(org.apache.lucene.
  478.      * index.LeafReaderContext,
  479.      * org.apache.lucene.search.spans.SpanWeight.Postings)
  480.      */
  481.     @Override
  482.     public MtasSpans getSpans(LeafReaderContext context,
  483.         Postings requiredPostings) throws IOException {
  484.       if (field == null) {
  485.         return null;
  486.       } else {
  487.         Terms terms = context.reader().terms(field);
  488.         if (terms == null) {
  489.           return null; // field does not exist
  490.         }
  491.         List<MtasSpanSequenceQuerySpans> setSequenceSpans = new ArrayList<>(
  492.             items.size());
  493.         Spans ignoreSpans = null;
  494.         boolean allSpansEmpty = true;
  495.         for (MtasSpanSequenceQueryWeight w : subWeights) {
  496.           Spans sequenceSpans = w.spanWeight.getSpans(context,
  497.               requiredPostings);
  498.           if (sequenceSpans != null) {
  499.             setSequenceSpans.add(new MtasSpanSequenceQuerySpans(
  500.                 MtasSpanSequenceQuery.this, sequenceSpans, w.optional));
  501.             allSpansEmpty = false;
  502.           } else {
  503.             if (w.optional) {
  504.               setSequenceSpans.add(new MtasSpanSequenceQuerySpans(
  505.                   MtasSpanSequenceQuery.this, null, w.optional));
  506.             } else {
  507.               return null;
  508.             }
  509.           }
  510.         }
  511.         if (allSpansEmpty) {
  512.           return null; // at least one required
  513.         } else if (ignoreWeight != null) {
  514.           ignoreSpans = ignoreWeight.getSpans(context, requiredPostings);
  515.         }
  516.         return new MtasSpanSequenceSpans(MtasSpanSequenceQuery.this,
  517.             setSequenceSpans, ignoreSpans, maximumIgnoreLength);
  518.       }
  519.     }

  520.     /*
  521.      * (non-Javadoc)
  522.      *
  523.      * @see org.apache.lucene.search.Weight#extractTerms(java.util.Set)
  524.      */
  525.     @Override
  526.     public void extractTerms(Set<Term> terms) {
  527.       for (MtasSpanSequenceQueryWeight w : subWeights) {
  528.         w.spanWeight.extractTerms(terms);
  529.       }
  530.       if (ignoreWeight != null) {
  531.         ignoreWeight.extractTerms(terms);
  532.       }
  533.     }
  534.    
  535. //    @Override
  536. //    public boolean isCacheable(LeafReaderContext arg0) {      
  537. //      for(MtasSpanSequenceQueryWeight sqw : subWeights) {
  538. //        if(!sqw.spanWeight.isCacheable(arg0)) {
  539. //          return false;
  540. //        }
  541. //      }
  542. //      if(ignoreWeight!=null) {
  543. //        return ignoreWeight.isCacheable(arg0);
  544. //      }
  545. //      return true;            
  546. //    }

  547.   }

  548.   /**
  549.    * The Class MtasSpanSequenceQuerySpans.
  550.    */
  551.   protected static class MtasSpanSequenceQuerySpans {

  552.     /** The spans. */
  553.     public Spans spans;

  554.     /** The optional. */
  555.     public boolean optional;

  556.     /**
  557.      * Instantiates a new mtas span sequence query spans.
  558.      *
  559.      * @param query the query
  560.      * @param spans the spans
  561.      * @param optional the optional
  562.      */
  563.     public MtasSpanSequenceQuerySpans(MtasSpanSequenceQuery query, Spans spans,
  564.         boolean optional) {
  565.       this.spans = spans != null ? spans : new MtasSpanMatchNoneSpans(query);
  566.       this.optional = optional;
  567.     }
  568.   }

  569.   /**
  570.    * The Class MtasSpanSequenceQueryWeight.
  571.    */
  572.   private static class MtasSpanSequenceQueryWeight {

  573.     /** The span weight. */
  574.     public SpanWeight spanWeight;

  575.     /** The optional. */
  576.     public boolean optional;

  577.     /**
  578.      * Instantiates a new mtas span sequence query weight.
  579.      *
  580.      * @param spanWeight the span weight
  581.      * @param optional the optional
  582.      */
  583.     public MtasSpanSequenceQueryWeight(SpanWeight spanWeight,
  584.         boolean optional) {
  585.       this.spanWeight = spanWeight;
  586.       this.optional = optional;
  587.     }
  588.   }
  589.  
  590.   @Override
  591.   public boolean isMatchAllPositionsQuery() {
  592.     return false;
  593.   }

  594. }