org.lumongo.client.command.Query.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(13.9k)|赞(0)|评价(0)|浏览(248)

本文整理了Java中org.lumongo.client.command.Query.<init>方法的一些代码示例,展示了Query.<init>的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.<init>方法的具体详情如下:
包路径:org.lumongo.client.command.Query
类名称:Query
方法名:<init>

Query.<init>介绍

暂无

代码示例

代码示例来源:origin: lumongo/lumongo

  1. public void simpleQueryAsync() throws Exception {
  2. Query query = new Query(MY_INDEX_NAME, "issn:1234-1234 AND title:special", 10);
  3. ListenableFuture<QueryResult> resultFuture = lumongoWorkPool.queryAsync(query);
  4. Futures.addCallback(resultFuture, new FutureCallback<QueryResult>() {
  5. @Override
  6. public void onSuccess(QueryResult explosion) {
  7. }
  8. @Override
  9. public void onFailure(Throwable thrown) {
  10. }
  11. });
  12. }

代码示例来源:origin: lumongo/lumongo

  1. public void simpleQuery() throws Exception {
  2. int numberOfResults = 10;
  3. String[] indexes = new String[] { MY_INDEX_NAME, MY_INDEX_NAME2 };
  4. String normalLuceneQuery = "issn:1234-1234 AND title:special";
  5. Query query = new Query(indexes, normalLuceneQuery, numberOfResults);
  6. QueryResult queryResult = lumongoWorkPool.query(query);
  7. long totalHits = queryResult.getTotalHits();
  8. System.out.println("Found <" + totalHits + "> hits");
  9. for (ScoredResult sr : queryResult.getResults()) {
  10. System.out.println("Matching document <" + sr.getUniqueId() + "> with score <" + sr.getScore() + ">");
  11. }
  12. }

代码示例来源:origin: lumongo/lumongo

  1. public void simpleQueryWithSort() throws Exception {
  2. int numberOfResults = 10;
  3. String normalLuceneQuery = "title:special";
  4. Query query = new Query(MY_INDEX_NAME, normalLuceneQuery, numberOfResults);
  5. query.addFieldSort("issn", Direction.ASCENDING);
  6. QueryResult queryResult = lumongoWorkPool.query(query);
  7. long totalHits = queryResult.getTotalHits();
  8. System.out.println("Found <" + totalHits + "> hits");
  9. for (ScoredResult sr : queryResult.getResults()) {
  10. System.out.println("Matching document <" + sr.getUniqueId() + "> with score <" + sr.getScore() + ">");
  11. }
  12. }

代码示例来源:origin: lumongo/lumongo

  1. public static void main(String[] args) throws Exception {
  2. LogUtil.loadLogConfig();
  3. lumongoWorkPool = new LumongoWorkPool(new LumongoPoolConfig().addMember("localhost"));
  4. mapper = new Mapper<Article>(Article.class);
  5. int maxSize = 2000;
  6. ClientDocumentCache clientDocumentCache = new ClientDocumentCache(lumongoWorkPool, maxSize);
  7. Query query = new Query("wikipedia", "title:a*", 10);
  8. QueryResult queryResult = lumongoWorkPool.query(query);
  9. BatchFetchResult batchFetchResult = clientDocumentCache.fetch(queryResult);
  10. List<Article> articles = mapper.fromBatchFetchResult(batchFetchResult);
  11. System.out.println(articles);
  12. lumongoWorkPool.shutdown();
  13. }
  14. }

代码示例来源:origin: lumongo/lumongo

  1. public void facetQuery() throws Exception {
  2. // Can set number of documents to return to 0 unless you want the documents
  3. // at the same time
  4. String[] indexes = new String[] { MY_INDEX_NAME, MY_INDEX_NAME2 };
  5. Query query = new Query(indexes, "title:special", 0);
  6. int maxFacets = 30;
  7. query.addCountRequest("issn", maxFacets);
  8. QueryResult queryResult = lumongoWorkPool.query(query);
  9. for (FacetCount fc : queryResult.getFacetCounts("issn")) {
  10. System.out.println("Facet <" + fc.getFacet() + "> with count <" + fc.getCount() + ">");
  11. }
  12. }

代码示例来源:origin: lumongo/lumongo

  1. public void drillDownQuery() throws Exception {
  2. Query query = new Query(MY_INDEX_NAME, "title:special", 0);
  3. query.addDrillDown("issn", "1111-1111");
  4. QueryResult queryResult = lumongoWorkPool.query(query);
  5. for (FacetCount fc : queryResult.getFacetCounts("issn")) {
  6. System.out.println("Facet <" + fc.getFacet() + "> with count <" + fc.getCount() + ">");
  7. }
  8. }

代码示例来源:origin: lumongo/lumongo

  1. @Test
  2. public void test04Search() throws Exception {
  3. LumongoWorkPool lumongoWorkPool = getLumongoWorkPool();
  4. {
  5. Query query = new Query("person", "firstName:Bob", 10);
  6. QueryResult qr = lumongoWorkPool.query(query);
  7. assertEquals(1, qr.getTotalHits());
  8. }
  9. {
  10. Query query = new Query("person", "phoneNumbers.type:Mobile", 10);
  11. QueryResult qr = lumongoWorkPool.query(query);
  12. assertEquals(1, qr.getTotalHits());
  13. }
  14. {
  15. Query query = new Query("person", "phoneNumbers.type:Home", 10);
  16. QueryResult qr = lumongoWorkPool.query(query);
  17. assertEquals(2, qr.getTotalHits());
  18. }
  19. }

代码示例来源:origin: lumongo/lumongo

  1. "ultrasonic", "tyrosine", "tuberculosis", "triphosphate", "transplantable", "toxoplasmosis" };
  2. Query q = new Query("medline", "cancer", 25);

代码示例来源:origin: lumongo/lumongo

  1. public void pagingQuery() throws Exception {
  2. int numberOfResults = 2;
  3. String normalLuceneQuery = "issn:1234-1234 AND title:special";
  4. String[] indexes = new String[] { MY_INDEX_NAME, MY_INDEX_NAME2 };
  5. Query query = new Query(indexes, normalLuceneQuery, numberOfResults);
  6. QueryResult firstResult = lumongoWorkPool.query(query);
  7. query.setLastResult(firstResult);
  8. QueryResult secondResult = lumongoWorkPool.query(query);
  9. for (ScoredResult sr : secondResult.getResults()) {
  10. System.out.println("Matching document <" + sr.getUniqueId() + "> with score <" + sr.getScore() + ">");
  11. }
  12. }

代码示例来源:origin: lumongo/lumongo

  1. public void moreComplexQuery() throws Exception {
  2. int numberOfResults = 10;
  3. Query query = new Query(Arrays.asList(MY_INDEX_NAME, MY_INDEX_NAME2), "cancer cure", numberOfResults);
  4. query.addQueryField("abstract");
  5. query.addQueryField("title");
  6. query.addFilterQuery("title:special");
  7. query.addFilterQuery("issn:1234-1234");
  8. QueryResult queryResult = lumongoWorkPool.query(query);
  9. long totalHits = queryResult.getTotalHits();
  10. System.out.println("Found <" + totalHits + "> hits");
  11. for (ScoredResult sr : queryResult.getResults()) {
  12. System.out.println("Matching document <" + sr.getUniqueId() + "> with score <" + sr.getScore() + ">");
  13. }
  14. }

代码示例来源:origin: lumongo/lumongo

  1. Query query = new Query("medlineBoth", "title:" + term, 10);
  2. query.setResultFetchType(fetchType);
  3. Query query = new Query("medlineBoth", "title:cancer AND issn:*", 10);
  4. query.setResultFetchType(fetchType);
  5. query.addFieldSort("issn");
  6. Query query = new Query("medlineBoth", "title:cancer AND issn:*", 10);
  7. query.setResultFetchType(fetchType);
  8. query.addCountRequest("issn", 4);
  9. Query query = new Query("medlineBoth", "title:cancer AND issn:*", 10);
  10. query.setResultFetchType(fetchType);
  11. query.addCountRequest("issn", 4);
  12. Query query = new Query("medlineBoth", "title:cancer AND issn:*", 10);
  13. query.setResultFetchType(fetchType);
  14. query.addCountRequest("journalCountry", 4);
  15. Query query = new Query("medlineBoth", "title:asthma", 10);
  16. query.setResultFetchType(fetchType);
  17. query.addCountRequest("publicationDate", 15);
  18. Query query = new Query("medlineBoth", "title:asthma", 10);
  19. query.setResultFetchType(fetchType);
  20. query.addCountRequest("publicationDate", 15);
  21. Query query = new Query("medlineBoth", "title:cancer AND issn:*", 1000);
  22. query.setResultFetchType(fetchType);

代码示例来源:origin: lumongo/lumongo

  1. lumongoWorkPool = new LumongoWorkPool(lumongoPoolConfig);
  2. Query q = new Query(indexes, query, amount);

代码示例来源:origin: lumongo/lumongo

  1. public void queryWithBatchFetch() throws Exception {
  2. int numberOfResults = 10;
  3. String[] indexes = new String[] { MY_INDEX_NAME, MY_INDEX_NAME2 };
  4. String normalLuceneQuery = "issn:1234-1234 AND title:special";
  5. Query query = new Query(indexes, normalLuceneQuery, numberOfResults);
  6. QueryResult queryResult = lumongoWorkPool.query(query);
  7. List<ScoredResult> scoredResults = queryResult.getResults();
  8. BatchFetch batchFetch = new BatchFetch();
  9. batchFetch.addFetchDocumentsFromResults(scoredResults);
  10. BatchFetchResult batchFetchResult = lumongoWorkPool.batchFetch(batchFetch);
  11. @SuppressWarnings("unused") List<FetchResult> results = batchFetchResult.getFetchResults();
  12. }

代码示例来源:origin: lumongo/lumongo

  1. Query q = new Query(FACET_TEST_INDEX, "title:userguide", 10).addCountRequest("keyword", 30);
  2. QueryResult qr = lumongoWorkPool.query(q);
  3. Query q = new Query(FACET_TEST_INDEX, "title:userguide", 10).addCountRequest("keyword", 30);
  4. QueryResult qr = lumongoWorkPool.query(q);
  5. Query q = new Query(FACET_TEST_INDEX, "title:userguide", 10).addCountRequest("issn", 30);
  6. QueryResult qr = lumongoWorkPool.query(q);
  7. Query q = new Query(FACET_TEST_INDEX, "title:userguide", 10).addCountRequest("date", 30);
  8. QueryResult qr = lumongoWorkPool.query(q);
  9. Query q = new Query(FACET_TEST_INDEX, "title:userguide", 10).addDrillDown("date", "2014-10-04");
  10. Query q = new Query(FACET_TEST_INDEX, "title:userguide", 10).addDrillDown("date", "2013-09-04");
  11. Query q = new Query(FACET_TEST_INDEX, "title:userguide", 10).addDrillDown("date", "2013-08-04");
  12. Query q = new Query(FACET_TEST_INDEX, "title:userguide", 10).addDrillDown("issn", "1234-1234");
  13. Query q = new Query(FACET_TEST_INDEX, "title:userguide", 10).addDrillDown("issn", "1234-1234").addDrillDown("issn", "3333-1234");
  14. Query q = new Query(FACET_TEST_INDEX, "title:userguide", 10).addDrillDown("issn", "1234-1234").addDrillDown("country", "France");
  15. Query q = new Query(FACET_TEST_INDEX, "title:userguide", 10);
  16. q.addDrillDown("issn", "1234-1234").addDrillDown("country", "France");
  17. q.addCountRequest("issn");

代码示例来源:origin: lumongo/lumongo

  1. LumongoWorkPool lumongoWorkPool = getLumongoWorkPool();
  2. Query q = new Query(FACET_TEST_INDEX, "title:userguide", 10).addCountRequest("issn", 30);
  3. QueryResult qr = lumongoWorkPool.query(q);
  4. Query q = new Query(FACET_TEST_INDEX, "title:userguide", 10).addCountRequest("date", 30);
  5. QueryResult qr = lumongoWorkPool.query(q);
  6. Query q = new Query(FACET_TEST_INDEX, "title:userguide", 10).addDrillDown("date", "2014-10-04");
  7. Query q = new Query(FACET_TEST_INDEX, "title:userguide", 10).addDrillDown("date", "2013-09-04");
  8. Query q = new Query(FACET_TEST_INDEX, "title:userguide", 10).addDrillDown("date", "2013-08-04");
  9. Query q = new Query(FACET_TEST_INDEX, "title:userguide", 10).addDrillDown("issn", "1234-1234");
  10. Query q = new Query(FACET_TEST_INDEX, "title:userguide", 10).addDrillDown("issn", "1234-1234").addDrillDown("issn", "3333-1234");
  11. Query q = new Query(FACET_TEST_INDEX, "title:userguide", 10).addDrillDown("issn", "1234-1234").addDrillDown("country", "France");
  12. Query q = new Query(FACET_TEST_INDEX, "title:userguide", 10);
  13. q.addDrillDown("issn", "1234-1234").addDrillDown("country", "France");
  14. q.addCountRequest("issn");

代码示例来源:origin: lumongo/lumongo

  1. String normalLuceneQuery = "issn:1234-1234 AND title:special";
  2. Query q = new Query(MY_TEST_INDEX, normalLuceneQuery, numberOfResults);
  3. QueryResult qr = lumongoWorkPool.query(q);
  4. @SuppressWarnings("unused") long totalHits = qr.getTotalHits();
  5. String normalLuceneQuery = "title:special";
  6. Query q = new Query(MY_TEST_INDEX, normalLuceneQuery, numberOfResults);
  7. Query q = new Query(FACET_TEST_INDEX, "title:userguide", 10).addCountRequest("issn", 30);
  8. Query q = new Query(FACET_TEST_INDEX, "title:userguide", 10).addDrillDown("issn", "1234-1234");

代码示例来源:origin: lumongo/lumongo

  1. lumongoWorkPool.store(s);
  2. Query query = new Query(SingleNodeTest.MY_TEST_INDEX, "*:*", 10);
  3. query.addFieldSort("date", Direction.ASCENDING);
  4. QueryResult queryResult = lumongoWorkPool.query(query);

代码示例来源:origin: lumongo/lumongo

  1. qr = lumongoWorkPool.query(new Query(MY_TEST_INDEX, "an:3", 10));
  2. assertEquals("Total hits is not 1", 1, qr.getTotalHits());
  3. qr = lumongoWorkPool.query(new Query(MY_TEST_INDEX, "an:[1 TO 3]", 10));
  4. assertEquals("Total hits is not 3", 3, qr.getTotalHits());
  5. qr = lumongoWorkPool.query(new Query(MY_TEST_INDEX, "an:{1 TO 3}", 10));
  6. assertEquals("Total hits is not 1", 1, qr.getTotalHits());
  7. qr = lumongoWorkPool.query(new Query(MY_TEST_INDEX, "an:[1 TO 5]", 10).addFieldSort("an"));
  8. assertEquals("Unique id does not match expected", "someUniqueId-1", qr.getResults().get(0).getUniqueId());
  9. qr = lumongoWorkPool.query(new Query(MY_TEST_INDEX, "an:[1 TO 4]", 10).addFieldSort("an", Lumongo.FieldSort.Direction.DESCENDING));
  10. System.out.println(qr.getResults().get(0).getSortValues());
  11. assertEquals("Unique id does not match expected", "someUniqueId-4", qr.getResults().get(0).getUniqueId());
  12. qr = lumongoWorkPool.query(new Query(MY_TEST_INDEX, "title:distributed", 300));
  13. assertEquals("Total hits is not " + DOCUMENTS_LOADED, DOCUMENTS_LOADED, qr.getTotalHits());
  14. qr = lumongoWorkPool.query(new Query(MY_TEST_INDEX, "title:distributed", 100));
  15. assertEquals("Total hits is not " + DOCUMENTS_LOADED, DOCUMENTS_LOADED, qr.getTotalHits());
  16. qr = lumongoWorkPool.query(new Query(MY_TEST_INDEX, "distributed", 20));
  17. assertEquals("Total hits is not " + DOCUMENTS_LOADED, DOCUMENTS_LOADED, qr.getTotalHits());
  18. qr = lumongoWorkPool.query(new Query(MY_TEST_INDEX, "issn:1234-1234", 20));
  19. assertEquals("Total hits is not " + DOCUMENTS_LOADED, DOCUMENTS_LOADED, qr.getTotalHits());
  20. qr = lumongoWorkPool.query(new Query(MY_TEST_INDEX, "title:cluster", 10));

代码示例来源:origin: lumongo/lumongo

  1. assertTrue("Document is missing raw document before delete", fr.hasResultDocument());
  2. qr = lumongoWorkPool.query(new Query(MY_TEST_INDEX, "uid" + ":" + uniqueIdToDelete, 10));
  3. assertEquals("Total hits is not 1 before delete", 1, qr.getTotalHits());
  4. assertTrue("Document has raw document after delete", !fr.hasResultDocument());
  5. qr = lumongoWorkPool.query(new Query(MY_TEST_INDEX, "uid" + ":" + uniqueIdToDelete, 10));
  6. assertEquals("Total hits is not 0 after delete", 0, qr.getTotalHits());

相关文章