Exemplo n.º 1
0
 @Override
 public void passHitQueryContextToClauses(HitQueryContext context) {
   producer.setHitQueryContext(context);
   filter.setHitQueryContext(context);
 }
Exemplo n.º 2
0
 @Override
 public void getCapturedGroups(Span[] capturedGroups) {
   if (!childClausesCaptureGroups) return;
   producer.getCapturedGroups(capturedGroups);
   filter.getCapturedGroups(filterIndex, capturedGroups);
 }
Exemplo n.º 3
0
  /**
   * Find a container with search hits in it, starting from the current container.
   *
   * @return true if found, false if no such container exists (i.e. we're done)
   * @throws IOException
   */
  private boolean synchronize() throws IOException {
    // Find the next "valid" container, if there is one.
    while (true) {
      // Are search and container in the same document?
      if (filter.doc() < producer.doc()) {
        // No, advance search to be in the same document as the container
        stillValidSearch = filter.skipTo(producer.doc());
        if (!stillValidSearch) return false; // No more search results, we're done.
      }

      // Are there search results in this document?
      if (filter.doc() == producer.doc()) {
        // Yes. See if the current container contains any of the search results.
        // List<Hit> filterHits = filter.getHits();
        switch (op) {
          case CONTAINING:
            // Looking for producer hits with a filter hit inside
            for (int i = 0; i < filter.bucketSize(); i++) {
              if (filter.start(i) >= producer.start() && filter.end(i) <= producer.end()) {
                // Yes, this filter hit is contained in the current producer hit.
                filterIndex = i; // remember for captured groups
                return true;
              }
            }
            break;
          case WITHIN:
            // Looking for producer hits contained by a filter hit
            for (int i = 0; i < filter.bucketSize(); i++) {
              if (filter.start(i) <= producer.start() && filter.end(i) >= producer.end()) {
                // Yes, this filter hit contains the current producer hit.
                filterIndex = i; // remember for captured groups
                return true;
              }
            }
            break;
          case STARTS_AT:
            // Looking for producer hits starting at a filter hit
            for (int i = 0; i < filter.bucketSize(); i++) {
              if (filter.start(i) == producer.start()) {
                // Yes, this filter hit starts at the current producer hit.
                filterIndex = i; // remember for captured groups
                return true;
              }
            }
            break;
          case ENDS_AT:
            // Looking for producer hits ending at a filter hit
            for (int i = 0; i < filter.bucketSize(); i++) {
              if (filter.end(i) == producer.end()) {
                // Yes, this filter hit ends at the current producer hit.
                filterIndex = i; // remember for captured groups
                return true;
              }
            }
            break;
          default:
            throw new RuntimeException("Unknown filter operation " + op);
        }
      }

      // No search results found in the current container.
      // Advance to the next container.
      stillValidContainers = producer.next();
      if (!stillValidContainers) return false; // no more containers; we're done.
    }
  }