Package org.apache.lucene.search.join

Examples of org.apache.lucene.search.join.ToParentBlockJoinQuery$BlockJoinWeight


    // Define parent document criteria (find a resident in the UK)
    Query parentQuery = new TermQuery(new Term("country", "United Kingdom"));

    // Wrap the child document query to 'join' any matches
    // up to corresponding parent:
    ToParentBlockJoinQuery childJoinQuery = new ToParentBlockJoinQuery(childQuery, parentsFilter, ToParentBlockJoinQuery.ScoreMode.Avg);

    // Combine the parent and nested child queries into a single query for a candidate
    BooleanQuery fullQuery = new BooleanQuery();
    fullQuery.add(new BooleanClause(parentQuery, Occur.MUST));
    fullQuery.add(new BooleanClause(childJoinQuery, Occur.MUST));
View Full Code Here


    // Define parent document criteria (find a resident in the UK)
    Query parentQuery = new TermQuery(new Term("country", "United Kingdom"));
     
    // Wrap the child document query to 'join' any matches
    // up to corresponding parent:
    ToParentBlockJoinQuery childJoinQuery = new ToParentBlockJoinQuery(childQuery, parentsFilter, ToParentBlockJoinQuery.ScoreMode.Avg);
     
    assertEquals("no filter - both passed", 2, s.search(childJoinQuery, 10).totalHits);

    assertEquals("dummy filter passes everyone ", 2, s.search(childJoinQuery, parentsFilter, 10).totalHits);
    assertEquals("dummy filter passes everyone ", 2, s.search(childJoinQuery, new QueryWrapperFilter(new TermQuery(new Term("docType", "resume"))), 10).totalHits);
View Full Code Here

    final RandomIndexWriter w = new RandomIndexWriter(random, dir);
    IndexReader r = w.getReader();
    w.close();
    IndexSearcher s = newSearcher(r, false);
   
    ToParentBlockJoinQuery q = new ToParentBlockJoinQuery(new MatchAllDocsQuery(), new QueryWrapperFilter(new MatchAllDocsQuery()), ToParentBlockJoinQuery.ScoreMode.Avg);
    s.search(q, 10);
    BooleanQuery bq = new BooleanQuery();
    bq.setBoost(2f); // we boost the BQ
    bq.add(q, BooleanClause.Occur.MUST);
    s.search(bq, 10);
View Full Code Here

        agg = ToParentBlockJoinQuery.ScoreMode.Total;
      } else {
        agg = ToParentBlockJoinQuery.ScoreMode.Avg;
      }

      final ToParentBlockJoinQuery childJoinQuery = new ToParentBlockJoinQuery(childQuery, parentsFilter, agg);

      // To run against the block-join index:
      final Query parentJoinQuery;

      // Same query as parentJoinQuery, but to run against
View Full Code Here

    // Define parent document criteria (find a resident in the UK)
    Query parentQuery = new TermQuery(new Term("country", "United Kingdom"));

    // Wrap the child document query to 'join' any matches
    // up to corresponding parent:
    ToParentBlockJoinQuery childJobJoinQuery = new ToParentBlockJoinQuery(childJobQuery, parentsFilter, ToParentBlockJoinQuery.ScoreMode.Avg);
    ToParentBlockJoinQuery childQualificationJoinQuery = new ToParentBlockJoinQuery(childQualificationQuery, parentsFilter, ToParentBlockJoinQuery.ScoreMode.Avg);

    // Combine the parent and nested child queries into a single query for a candidate
    BooleanQuery fullQuery = new BooleanQuery();
    fullQuery.add(new BooleanClause(parentQuery, Occur.MUST));
    fullQuery.add(new BooleanClause(childJobJoinQuery, Occur.MUST));
View Full Code Here

    IndexSearcher s = newSearcher(r, false);
    Query tq = new TermQuery(new Term("child", "1"));
    final Filter parentsFilter = new CachingWrapperFilter(new RawTermFilter(new Term("parent", "1")),
                                                          CachingWrapperFilter.DeletesMode.IGNORE);

    ToParentBlockJoinQuery q = new ToParentBlockJoinQuery(tq, parentsFilter, ToParentBlockJoinQuery.ScoreMode.Avg);
    Weight weight = s.createNormalizedWeight(q);
   
    IndexReader atomic;
    if (s.getIndexReader().getSequentialSubReaders() == null) {
      atomic = s.getIndexReader();
View Full Code Here

    IndexSearcher s = newSearcher(r, false);
    Query tq = new TermQuery(new Term("child", "2"));
    final Filter parentsFilter = new CachingWrapperFilter(new RawTermFilter(new Term("isparent", "yes")),
                                                          CachingWrapperFilter.DeletesMode.IGNORE);

    ToParentBlockJoinQuery q = new ToParentBlockJoinQuery(tq, parentsFilter, ToParentBlockJoinQuery.ScoreMode.Avg);
    Weight weight = s.createNormalizedWeight(q);
    final IndexReader[] subs = s.getIndexReader().getSequentialSubReaders();
    final IndexReader sub;
    if (subs == null) {
      sub = s.getIndexReader();
View Full Code Here

                //}
            } else {
                parentFilter = parseContext.bitsetFilter(parentFilter);
            }

            Filter nestedFilter = Queries.wrap(new ToParentBlockJoinQuery(query, parentFilter, ScoreMode.None), parseContext);

            if (cache) {
                nestedFilter = parseContext.cacheFilter(nestedFilter, cacheKey);
            }
            if (filterName != null) {
View Full Code Here

                //    parentFilter = mapper.docMapper().typeFilter();
                //}
            } else {
                parentFilter = parseContext.bitsetFilter(parentFilter);
            }
            ToParentBlockJoinQuery joinQuery = new ToParentBlockJoinQuery(query, parentFilter, scoreMode);
            joinQuery.setBoost(boost);
            if (queryName != null) {
                parseContext.addNamedQuery(queryName, joinQuery);
            }
            return joinQuery;
        } finally {
View Full Code Here

        }
        Filter parentFilter = new TermFilter(new Term("type", "parent"));
        Filter childFilter = new NotFilter(parentFilter);
        Nested nested = createNested(parentFilter, childFilter);
        BytesRefFieldComparatorSource nestedComparatorSource = new BytesRefFieldComparatorSource(fieldData, missingValue, sortMode, nested);
        ToParentBlockJoinQuery query = new ToParentBlockJoinQuery(new FilteredQuery(new MatchAllDocsQuery(), childFilter), new BitDocIdSetCachingWrapperFilter(parentFilter), ScoreMode.None);
        Sort sort = new Sort(new SortField("text", nestedComparatorSource));
        TopFieldDocs topDocs = searcher.search(query, randomIntBetween(1, numParents), sort);
        assertTrue(topDocs.scoreDocs.length > 0);
        BytesRef previous = null;
        for (int i = 0; i < topDocs.scoreDocs.length; ++i) {
View Full Code Here

TOP

Related Classes of org.apache.lucene.search.join.ToParentBlockJoinQuery$BlockJoinWeight

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.