Package net.sf.katta.lib.lucene

Examples of net.sf.katta.lib.lucene.Hits


    // final Query query = new QueryParser("", new
    // KeywordAnalyzer()).parse(fieldName + ": " + queryTerm);
    final Query query = new QueryParser(Version.LUCENE_30, "", new KeywordAnalyzer()).parse(fieldName + ": "
            + queryTerm);
    final TopDocs searchResultsLucene;
    final Hits searchResultsKatta;
    if (sort == null) {
      searchResultsLucene = indexSearcher.search(query, resultCount);
      searchResultsKatta = _client.search(query, new String[] { kattaIndexName }, resultCount);
    } else {
      searchResultsLucene = indexSearcher.search(query, null, resultCount, sort);
      searchResultsKatta = _client.search(query, new String[] { kattaIndexName }, resultCount, sort);
    }

    assertEquals(searchResultsLucene.totalHits, searchResultsKatta.size());

    ScoreDoc[] scoreDocs = searchResultsLucene.scoreDocs;
    List<Hit> hits = searchResultsKatta.getHits();
    if (sort == null) {
      for (int i = 0; i < scoreDocs.length; i++) {
        assertEquals(scoreDocs[i].score, hits.get(i).getScore(), 0.0);
      }
    } else {
View Full Code Here


  public void testGetDetails_NodeProxyDownAfterClientInitialization() throws Exception {
    deployTestIndices(1, getNodeCount());
    LuceneClient luceneClient = new LuceneClient(_miniCluster.getZkConfiguration());
    ((NodeProxyManager) luceneClient.getClient().getProxyManager()).setSuccessiveProxyFailuresBeforeReestablishing(1);
    final Query query = new QueryParser(Version.LUCENE_30, "", new KeywordAnalyzer()).parse("content: the");
    Hits hits = luceneClient.search(query, new String[] { INDEX_NAME }, 10);

    // shutdown proxy of node1
    System.out.println("=========================");
    if (_miniCluster.getNode(0).getName().equals(hits.getHits().get(0).getNode())) {
      _miniCluster.shutdownNodeRpc(0);
    } else {
      _miniCluster.shutdownNodeRpc(1);
    }
    assertFalse(luceneClient.getDetails(hits.getHits().get(0)).isEmpty());
    assertFalse(luceneClient.getDetails(hits.getHits().get(0)).isEmpty());
    // search 2 time to ensure we get all available nodes
    System.out.println("=========================");
    shutdownNodes();
    luceneClient.close();
  }
View Full Code Here

        } else {
          client = _client;
        }
        while (!_stopped) {
          final Query query = new QueryParser(Version.LUCENE_30, "", new KeywordAnalyzer()).parse("foo:bar");
          Hits hits = client.search(query, new String[] { "*" });
          _firedQueryCount++;
          if (hits.size() != _expectedTotalHitCount) {
            _unexpectedResultCount++;
            LOG.error("expected " + _expectedTotalHitCount + " hits but got " + hits.size());
          }
        }
        if (_client == null) {
          client.close();
        }
View Full Code Here

      } catch (Exception e) {
        logException("undeploy", e);
      }

      try {
        Hits search = luceneClient.search(query, new String[] { "*" });
        LOG.info(runThroughs + ": got " + search.size() + " results");
      } catch (Exception e) {
        logException("search", e);
      }
      Thread.sleep(5000);
      runThroughs++;
View Full Code Here

    for (int i = 0; i < _hitCount; i++) {
      final Hit hit = new Hit("shard", "node", random.nextFloat(), random.nextInt());
      hitList.add(hit);
    }

    final Hits hits = new Hits();
    hits.addHits(hitList);
    return hits;
  }
View Full Code Here

    for (int i = 0; i < _hitCount; i++) {
      final Hit hit = new Hit("shard", "node", random.nextFloat(), random.nextInt());
      hitListsArray[random.nextInt(hitListsArray.length)].add(hit);
    }

    final Hits hits = new Hits();
    for (List<Hit> hitList : hitListsArray) {
      Collections.sort(hitList);
      hits.addHits(hitList);
    }
    return hits;
  }
View Full Code Here

  @Test
  public void testGetDetails() throws Exception {
    deployTestIndices(1, 1);
    ILuceneClient client = new LuceneClient(_miniCluster.getZkConfiguration());
    final Query query = new QueryParser(Version.LUCENE_30, "", new KeywordAnalyzer()).parse("content: the");
    final Hits hits = client.search(query, new String[] { INDEX_NAME }, 10);
    assertNotNull(hits);
    assertEquals(10, hits.getHits().size());
    for (final Hit hit : hits.getHits()) {
      final MapWritable details = client.getDetails(hit);
      final Set<Writable> keySet = details.keySet();
      assertFalse(keySet.isEmpty());
      assertNotNull(details.get(new Text("path")));
      assertNotNull(details.get(new Text("category")));
View Full Code Here

  @Test
  public void testGetDetailsWithFieldNames() throws Exception {
    deployTestIndices(1, 1);
    ILuceneClient client = new LuceneClient(_miniCluster.getZkConfiguration());
    final Query query = new QueryParser(Version.LUCENE_30, "", new KeywordAnalyzer()).parse("content: the");
    final Hits hits = client.search(query, new String[] { INDEX_NAME }, 10);
    assertNotNull(hits);
    assertEquals(10, hits.getHits().size());
    for (final Hit hit : hits.getHits()) {
      final MapWritable details = client.getDetails(hit, new String[] { "path" });
      final Set<Writable> keySet = details.keySet();
      assertFalse(keySet.isEmpty());
      assertNotNull(details.get(new Text("path")));
      assertNull(details.get(new Text("category")));
View Full Code Here

    assertEquals(IndexState.DEPLOYED, indexState);

    ILuceneClient client = new LuceneClient(_miniCluster.getZkConfiguration());
    final Query query = new QueryParser(Version.LUCENE_30, "", new KeywordAnalyzer()).parse(textFieldName + ": "
            + textFieldContent);
    final Hits hits = client.search(query, new String[] { index.getName() }, 10);
    assertNotNull(hits);
    assertEquals(1, hits.getHits().size());
    final Hit hit = hits.getHits().get(0);
    final MapWritable details = client.getDetails(hit);
    final Set<Writable> keySet = details.keySet();
    assertEquals(1, keySet.size());
    final Writable writable = details.get(new Text(binaryFieldName));
    assertNotNull(writable);
View Full Code Here

  @Test
  public void testGetDetailsConcurrently() throws KattaException, ParseException, InterruptedException {
    deployTestIndices(1, 1);
    ILuceneClient client = new LuceneClient(_miniCluster.getZkConfiguration());
    final Query query = new QueryParser(Version.LUCENE_30, "", new KeywordAnalyzer()).parse("content: the");
    final Hits hits = client.search(query, new String[] { INDEX_NAME }, 10);
    assertNotNull(hits);
    assertEquals(10, hits.getHits().size());
    List<MapWritable> detailList = client.getDetails(hits.getHits());
    assertEquals(hits.getHits().size(), detailList.size());
    for (int i = 0; i < detailList.size(); i++) {
      final MapWritable details1 = client.getDetails(hits.getHits().get(i));
      final MapWritable details2 = detailList.get(i);
      assertEquals(details1.entrySet(), details2.entrySet());
      final Set<Writable> keySet = details2.keySet();
      assertFalse(keySet.isEmpty());
      final Writable writable = details2.get(new Text("path"));
View Full Code Here

TOP

Related Classes of net.sf.katta.lib.lucene.Hits

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.