Package org.apache.lucene.search

Examples of org.apache.lucene.search.Searcher.search()


            } else {
                aQuery = new TermQuery(new Term(aField, aQueryStr));
            }

            // Perform search
            Hits aHits = searcher.search(aQuery);
            int nHitCount = aHits.length();

            String aDocs[] = new String[nHitCount];
            for (int iHit = 0; iHit < nHitCount; iHit++) {
                Document aDoc = aHits.doc(iHit);
View Full Code Here


      int count = 0;
      for (RowResult r : scanner) {
        String value = Bytes.toString(r.getRow());
        Term term = new Term(rowkeyName, value);
        int hitCount = searcher.search(new TermQuery(term)).length();
        assertEquals("check row " + value, 1, hitCount);
        count++;
      }
      LOG.debug("Searcher.maxDoc: " + searcher.maxDoc());
      LOG.debug("IndexReader.numDocs: " + ((IndexSearcher)searcher).getIndexReader().numDocs());     
View Full Code Here

        searcher = new IndexSearcher((Directory)index, true);
      else
        searcher = ((MemoryIndex) index).createSearcher();

      final float[] scores = new float[1]; // inits to 0.0f (no match)
      searcher.search(query, new Collector() {
        private Scorer scorer;

        @Override
        public void collect(int doc) throws IOException {
          scores[0] = scorer.score();
View Full Code Here

      Searcher searcher = null;

      try {
        searcher = new IndexSearcher(blog.getSearchIndexDirectory());
        Query query = QueryParser.parse(queryString, "blogEntry", getAnalyzer());
        Hits hits = searcher.search(query);

        for (int i = 0; i < hits.length(); i++) {
          Document doc = hits.doc(i);
          SearchHit result = new SearchHit(
              blog,
View Full Code Here

  // search for something that does exists
  Query query = new TermQuery(new Term("keyword", "test1"));

  // ensure that queries return expected results without DateFilter first
        Hits hits = searcher.search(query);
  assertEquals(1, hits.length());

        try
        {
            doAssert(hits.doc(0), true);
View Full Code Here

    break;

  Query query = QueryParser.parse(line, "contents", analyzer);
  System.out.println("Searching for: " + query.toString("contents"));

  Hits hits = searcher.search(query);
  System.out.println(hits.length() + " total matching documents");

  final int HITS_PER_PAGE = 10;
  for (int start = 0; start < hits.length(); start += HITS_PER_PAGE) {
    int end = Math.min(hits.length(), start + HITS_PER_PAGE);
View Full Code Here

        searchers[0] = new IndexSearcher(indexStoreB);
        searchers[1] = new IndexSearcher(indexStoreA);
        // creating the multiSearcher
        Searcher mSearcher = new MultiSearcher(searchers);
        // performing the search
        Hits hits = mSearcher.search(query);

        assertEquals(3, hits.length());

        try {
            // iterating over the hit documents
View Full Code Here

        searchers2[0] = new IndexSearcher(indexStoreB);
        searchers2[1] = new IndexSearcher(indexStoreA);
        // creating the mulitSearcher
        Searcher mSearcher2 = new MultiSearcher(searchers2);
        // performing the same search
        Hits hits2 = mSearcher2.search(query);

        assertEquals(4, hits2.length());

        try {
            // iterating over the hit documents
View Full Code Here

        searchers3[0] = new IndexSearcher(indexStoreB);
        searchers3[1] = new IndexSearcher(indexStoreA);
        // creating the mulitSearcher
        Searcher mSearcher3 = new MultiSearcher(searchers3);
        // performing the same search
        Hits hits3 = mSearcher3.search(query);

        assertEquals(3, hits3.length());

        try {
            // iterating over the hit documents
View Full Code Here

      ArrayList results = new ArrayList();
      IndexReader reader = IndexReader.open(storeIndex);
      Searcher searcher = new IndexSearcher(reader);
      Analyzer analyzer = new StandardAnalyzer();
      Query query = QueryParser.parse(item,"TextPath",analyzer);
      Hits hits = searcher.search(query);
      for(int i = 0; i < hits.length() && i < QueryManager.resultSize; i++){
        Document doc = hits.doc(i);
        String path = doc.get("Path");
        if(!results.contains(path))
          results.add(path);
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.