Examples of MatchAllDocsQuery


Examples of org.apache.lucene.search.MatchAllDocsQuery

      writer.commit();

      // try the search over the first doc
      IndexSearcher indexSearcher = new IndexSearcher(writer.getReader());
      TopDocs result = indexSearcher.search(
              new MatchAllDocsQuery("contents"), 10);
      assertTrue(result.totalHits > 0);
      Document d = indexSearcher.doc(result.scoreDocs[0].doc);
      assertNotNull(d);
      assertNotNull(d.getFieldable("title"));
      assertNotNull(d.getFieldable("contents"));

      // add a second doc
      doc = new Document();
      doc.add(new Field("title", "il mio titolo", Field.Store.YES,
              Field.Index.ANALYZED));
      doc.add(new Field("contents", "che cosa e' scritto qui",
              Field.Store.YES, Field.Index.ANALYZED));
      writer.addDocument(doc, analyzer);
      writer.commit();

      // do a matchalldocs query to retrieve both docs
      indexSearcher = new IndexSearcher(writer.getReader());
      result = indexSearcher.search(
              new MatchAllDocsQuery("contents"), 10);
      assertTrue(result.totalHits > 0);
      for (ScoreDoc di : result.scoreDocs) {
        d = indexSearcher.doc(di.doc);
        assertNotNull(d);
        assertNotNull(d.getFieldable("title"));
View Full Code Here

Examples of org.apache.lucene.search.MatchAllDocsQuery

    public TopDocs search(String term, String category, String sortOrder, boolean beforeDeadlineOnly, int maxDocument) throws EventSearchServiceException, ParseException, IllegalArgumentException {
        try {
            Query query;
            if (StringUtils.isEmpty(term)) {
                // If the search term is not null, all events should be displayed.
                query = new MatchAllDocsQuery();
            } else {
                QueryParser partialParser = new QueryParser(Version.LUCENE_30, "CONTENT", analyzer);
                query = partialParser.parse(term);
            }
View Full Code Here

Examples of org.apache.lucene.search.MatchAllDocsQuery

    for (String word : words) {
      Term t = new Term("content", word);
      TermQuery tq = new TermQuery(t);
      bq.add(tq, BooleanClause.Occur.SHOULD);
    }
    bq.add(new MatchAllDocsQuery(), BooleanClause.Occur.SHOULD);
   
    SearchResults results = new SearchResults();

    IndexReader reader = IndexReader.open(this.index);
    IndexSearcher searcher = new IndexSearcher(reader);
View Full Code Here

Examples of org.apache.lucene.search.MatchAllDocsQuery

  /** Fixes a negative query by adding a MatchAllDocs query clause.
   * The query passed in *must* be a negative query.
   */
  public static Query fixNegativeQuery(Query q) {
    BooleanQuery newBq = (BooleanQuery)q.clone();
    newBq.add(new MatchAllDocsQuery(), BooleanClause.Occur.MUST);
    return newBq;   
  }
View Full Code Here

Examples of org.apache.lucene.search.MatchAllDocsQuery

      writer.addDocument(doc);
    }
    writer.close();
    IndexReader reader = IndexReader.open(directory);
    IndexSearcher searcher = new IndexSearcher(reader);
    TopDocs topDocs = searcher.search(new MatchAllDocsQuery(), terms.length);
    for (int i = 0; i < topDocs.scoreDocs.length; i++){
        System.out.println("Id: " + topDocs.scoreDocs[i].doc + " Val: " + searcher.doc(topDocs.scoreDocs[i].doc).get("chars"));
    }
    QueryParser qp = new QueryParser(Version.LUCENE_36, "chars", analyzer);
    Query query = qp.parse(queryTerm);
View Full Code Here

Examples of org.apache.lucene.search.MatchAllDocsQuery

  }

  @Override
  protected Query newWildcardQuery(Term t) {
    if (SUPER.equals(t.field()) && "*".equals(t.text())) {
      return new MatchAllDocsQuery();
    }
    String field = t.field();
    try {
      Boolean b = _fieldManager.checkSupportForWildcardQuery(field);
      if (!(b == null || b)) {
View Full Code Here

Examples of org.apache.lucene.search.MatchAllDocsQuery

  public void testMatchAllDocs() throws Exception {
    StandardQueryParser qp = new StandardQueryParser();
    qp.setAnalyzer(new MockAnalyzer(random, MockTokenizer.WHITESPACE, false));

    assertEquals(new MatchAllDocsQuery(), qp.parse("*:*", "field"));
    assertEquals(new MatchAllDocsQuery(), qp.parse("(*:*)", "field"));
    BooleanQuery bq = (BooleanQuery) qp.parse("+*:* -*:*", "field");
    assertTrue(bq.getClauses()[0].getQuery() instanceof MatchAllDocsQuery);
    assertTrue(bq.getClauses()[1].getQuery() instanceof MatchAllDocsQuery);
  }
View Full Code Here

Examples of org.apache.lucene.search.MatchAllDocsQuery

    }
  }

  public void testMatchAllDocs() throws Exception {
    QueryParser qp = new QueryParser(TEST_VERSION_CURRENT, "field", new MockAnalyzer(random, MockTokenizer.WHITESPACE, false));
    assertEquals(new MatchAllDocsQuery(), qp.parse("*:*"));
    assertEquals(new MatchAllDocsQuery(), qp.parse("(*:*)"));
    BooleanQuery bq = (BooleanQuery)qp.parse("+*:* -*:*");
    assertTrue(bq.getClauses()[0].getQuery() instanceof MatchAllDocsQuery);
    assertTrue(bq.getClauses()[1].getQuery() instanceof MatchAllDocsQuery);
  }
View Full Code Here

Examples of org.apache.lucene.search.MatchAllDocsQuery

  }

  public void testLatLongFilterOnDeletedDocs() throws Exception {
    writer.deleteDocuments(new Term("name", "Potomac"));
    IndexReader r = IndexReader.open(writer, true);
    LatLongDistanceFilter f = new LatLongDistanceFilter(new QueryWrapperFilter(new MatchAllDocsQuery()),
                                                        lat, lng, 1.0, latField, lngField);

    IndexReader[] readers = r.getSequentialSubReaders();
    for(int i=0;i<readers.length;i++) {
      f.getDocIdSet(readers[i]);
View Full Code Here

Examples of org.apache.lucene.search.MatchAllDocsQuery

  /**
   * Builds a new MatchAllDocsQuery instance
   * @return new MatchAllDocsQuery instance
   */
  protected Query newMatchAllDocsQuery() {
    return new MatchAllDocsQuery();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.