本文整理了Java中org.lumongo.client.command.Query
类的一些代码示例,展示了Query
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query
类的具体详情如下:
包路径:org.lumongo.client.command.Query
类名称:Query
[英]Runs a query on one of more LuMongo indexes.
[中]在一个或多个LuMongo索引上运行查询。
代码示例来源:origin: lumongo/lumongo
public Query addCountRequest(String label) {
return (addCountRequest(label, null));
}
代码示例来源:origin: lumongo/lumongo
public Query addFilterQuery(String query, Collection<String> queryFields, Integer minimumNumberShouldMatch) {
return addFilterQuery(query, queryFields, null, minimumNumberShouldMatch);
}
代码示例来源:origin: lumongo/lumongo
public Query addSummaryAnalysis(String field, int topN) {
return addAnalysis(field, false, false, true, topN);
}
代码示例来源:origin: lumongo/lumongo
lumongoWorkPool = new LumongoWorkPool(lumongoPoolConfig);
Query q = new Query(indexes, query, amount);
q.setStart(start);
q.setResultFetchType(Lumongo.FetchType.FULL);
q.setMinimumNumberShouldMatch(minimumNumberShouldMatch);
q.addCountRequest(facet, facetCount, facetSegmentCount);
q.addFieldSort(sortDesc, Direction.DESCENDING);
代码示例来源:origin: lumongo/lumongo
Query query = new Query("medlineBoth", "title:" + term, 10);
query.setResultFetchType(fetchType);
Query query = new Query("medlineBoth", "title:cancer AND issn:*", 10);
query.setResultFetchType(fetchType);
query.addFieldSort("issn");
QueryResult queryResult = lumongoWorkPool.query(query);
Query query = new Query("medlineBoth", "title:cancer AND issn:*", 10);
query.setResultFetchType(fetchType);
query.addCountRequest("issn", 4);
QueryResult queryResult = lumongoWorkPool.query(query);
Query query = new Query("medlineBoth", "title:cancer AND issn:*", 10);
query.setResultFetchType(fetchType);
query.addCountRequest("issn", 4);
QueryResult queryResult = lumongoWorkPool.query(query);
Query query = new Query("medlineBoth", "title:cancer AND issn:*", 10);
query.setResultFetchType(fetchType);
query.addCountRequest("journalCountry", 4);
query.addCountRequest("issn", 4);
QueryResult queryResult = lumongoWorkPool.query(query);
Query query = new Query("medlineBoth", "title:asthma", 10);
query.setResultFetchType(fetchType);
query.addCountRequest("publicationDate", 15);
Query query = new Query("medlineBoth", "title:asthma", 10);
代码示例来源:origin: lumongo/lumongo
qr = lumongoWorkPool.query(new Query(MY_TEST_INDEX, "an:3", 10));
assertEquals("Total hits is not 1", 1, qr.getTotalHits());
qr = lumongoWorkPool.query(new Query(MY_TEST_INDEX, "an:[1 TO 3]", 10));
assertEquals("Total hits is not 3", 3, qr.getTotalHits());
qr = lumongoWorkPool.query(new Query(MY_TEST_INDEX, "an:{1 TO 3}", 10));
assertEquals("Total hits is not 1", 1, qr.getTotalHits());
qr = lumongoWorkPool.query(new Query(MY_TEST_INDEX, "an:[1 TO 5]", 10).addFieldSort("an"));
assertEquals("Unique id does not match expected", "someUniqueId-1", qr.getResults().get(0).getUniqueId());
qr = lumongoWorkPool.query(new Query(MY_TEST_INDEX, "an:[1 TO 4]", 10).addFieldSort("an", Lumongo.FieldSort.Direction.DESCENDING));
System.out.println(qr.getResults().get(0).getSortValues());
assertEquals("Unique id does not match expected", "someUniqueId-4", qr.getResults().get(0).getUniqueId());
qr = lumongoWorkPool.query(new Query(MY_TEST_INDEX, "title:distributed", 300));
assertEquals("Total hits is not " + DOCUMENTS_LOADED, DOCUMENTS_LOADED, qr.getTotalHits());
qr = lumongoWorkPool.query(new Query(MY_TEST_INDEX, "title:distributed", 100));
assertEquals("Total hits is not " + DOCUMENTS_LOADED, DOCUMENTS_LOADED, qr.getTotalHits());
qr = lumongoWorkPool.query(new Query(MY_TEST_INDEX, "distributed", 20));
assertEquals("Total hits is not " + DOCUMENTS_LOADED, DOCUMENTS_LOADED, qr.getTotalHits());
qr = lumongoWorkPool.query(new Query(MY_TEST_INDEX, "issn:1234-1234", 20));
assertEquals("Total hits is not " + DOCUMENTS_LOADED, DOCUMENTS_LOADED, qr.getTotalHits());
qr = lumongoWorkPool.query(new Query(MY_TEST_INDEX, "title:cluster", 10));
代码示例来源:origin: lumongo/lumongo
LumongoWorkPool lumongoWorkPool = getLumongoWorkPool();
Query q = new Query(FACET_TEST_INDEX, "title:userguide", 10).addCountRequest("issn", 30);
QueryResult qr = lumongoWorkPool.query(q);
Query q = new Query(FACET_TEST_INDEX, "title:userguide", 10).addCountRequest("date", 30);
QueryResult qr = lumongoWorkPool.query(q);
Query q = new Query(FACET_TEST_INDEX, "title:userguide", 10).addDrillDown("date", "2014-10-04");
Query q = new Query(FACET_TEST_INDEX, "title:userguide", 10).addDrillDown("date", "2013-09-04");
Query q = new Query(FACET_TEST_INDEX, "title:userguide", 10).addDrillDown("date", "2013-08-04");
Query q = new Query(FACET_TEST_INDEX, "title:userguide", 10).addDrillDown("issn", "1234-1234");
Query q = new Query(FACET_TEST_INDEX, "title:userguide", 10).addDrillDown("issn", "1234-1234").addDrillDown("issn", "3333-1234");
Query q = new Query(FACET_TEST_INDEX, "title:userguide", 10).addDrillDown("issn", "1234-1234").addDrillDown("country", "France");
Query q = new Query(FACET_TEST_INDEX, "title:userguide", 10);
q.addDrillDown("issn", "1234-1234").addDrillDown("country", "France");
q.addCountRequest("issn");
代码示例来源:origin: lumongo/lumongo
String normalLuceneQuery = "issn:1234-1234 AND title:special";
Query q = new Query(MY_TEST_INDEX, normalLuceneQuery, numberOfResults);
QueryResult qr = lumongoWorkPool.query(q);
@SuppressWarnings("unused") long totalHits = qr.getTotalHits();
String normalLuceneQuery = "title:special";
Query q = new Query(MY_TEST_INDEX, normalLuceneQuery, numberOfResults);
@SuppressWarnings("unused") QueryResult next = lumongoWorkPool.query(q.setLastResult(first));
Query q = new Query(FACET_TEST_INDEX, "title:userguide", 10).addCountRequest("issn", 30);
Query q = new Query(FACET_TEST_INDEX, "title:userguide", 10).addDrillDown("issn", "1234-1234");
代码示例来源:origin: lumongo/lumongo
public void facetQuery() throws Exception {
// Can set number of documents to return to 0 unless you want the documents
// at the same time
String[] indexes = new String[] { MY_INDEX_NAME, MY_INDEX_NAME2 };
Query query = new Query(indexes, "title:special", 0);
int maxFacets = 30;
query.addCountRequest("issn", maxFacets);
QueryResult queryResult = lumongoWorkPool.query(query);
for (FacetCount fc : queryResult.getFacetCounts("issn")) {
System.out.println("Facet <" + fc.getFacet() + "> with count <" + fc.getCount() + ">");
}
}
代码示例来源:origin: lumongo/lumongo
public void simpleQueryWithSort() throws Exception {
int numberOfResults = 10;
String normalLuceneQuery = "title:special";
Query query = new Query(MY_INDEX_NAME, normalLuceneQuery, numberOfResults);
query.addFieldSort("issn", Direction.ASCENDING);
QueryResult queryResult = lumongoWorkPool.query(query);
long totalHits = queryResult.getTotalHits();
System.out.println("Found <" + totalHits + "> hits");
for (ScoredResult sr : queryResult.getResults()) {
System.out.println("Matching document <" + sr.getUniqueId() + "> with score <" + sr.getScore() + ">");
}
}
代码示例来源:origin: lumongo/lumongo
public void moreComplexQuery() throws Exception {
int numberOfResults = 10;
Query query = new Query(Arrays.asList(MY_INDEX_NAME, MY_INDEX_NAME2), "cancer cure", numberOfResults);
query.addQueryField("abstract");
query.addQueryField("title");
query.addFilterQuery("title:special");
query.addFilterQuery("issn:1234-1234");
QueryResult queryResult = lumongoWorkPool.query(query);
long totalHits = queryResult.getTotalHits();
System.out.println("Found <" + totalHits + "> hits");
for (ScoredResult sr : queryResult.getResults()) {
System.out.println("Matching document <" + sr.getUniqueId() + "> with score <" + sr.getScore() + ">");
}
}
代码示例来源:origin: lumongo/lumongo
public void simpleQueryAsync() throws Exception {
Query query = new Query(MY_INDEX_NAME, "issn:1234-1234 AND title:special", 10);
ListenableFuture<QueryResult> resultFuture = lumongoWorkPool.queryAsync(query);
Futures.addCallback(resultFuture, new FutureCallback<QueryResult>() {
@Override
public void onSuccess(QueryResult explosion) {
}
@Override
public void onFailure(Throwable thrown) {
}
});
}
代码示例来源:origin: lumongo/lumongo
public void drillDownQuery() throws Exception {
Query query = new Query(MY_INDEX_NAME, "title:special", 0);
query.addDrillDown("issn", "1111-1111");
QueryResult queryResult = lumongoWorkPool.query(query);
for (FacetCount fc : queryResult.getFacetCounts("issn")) {
System.out.println("Facet <" + fc.getFacet() + "> with count <" + fc.getCount() + ">");
}
}
代码示例来源:origin: lumongo/lumongo
public void pagingQuery() throws Exception {
int numberOfResults = 2;
String normalLuceneQuery = "issn:1234-1234 AND title:special";
String[] indexes = new String[] { MY_INDEX_NAME, MY_INDEX_NAME2 };
Query query = new Query(indexes, normalLuceneQuery, numberOfResults);
QueryResult firstResult = lumongoWorkPool.query(query);
query.setLastResult(firstResult);
QueryResult secondResult = lumongoWorkPool.query(query);
for (ScoredResult sr : secondResult.getResults()) {
System.out.println("Matching document <" + sr.getUniqueId() + "> with score <" + sr.getScore() + ">");
}
}
代码示例来源:origin: lumongo/lumongo
"ultrasonic", "tyrosine", "tuberculosis", "triphosphate", "transplantable", "toxoplasmosis" };
Query q = new Query("medline", "cancer", 25);
int index = ThreadLocalRandom.current().nextInt(queries.length);
String query = queries[index];
q.setQuery(query);
代码示例来源:origin: lumongo/lumongo
public Query addCosineSim(String field, double[] vector, double similarity) {
Lumongo.CosineSimRequest.Builder builder = Lumongo.CosineSimRequest.newBuilder().setField(field).setSimilarity(similarity);
for (int i = 0; i < vector.length; i++) {
builder.addVector(vector[i]);
}
addCosineSim(builder.build());
return this;
}
代码示例来源:origin: lumongo/lumongo
Query q = new Query(FACET_TEST_INDEX, "title:userguide", 10).addCountRequest("keyword", 30);
QueryResult qr = lumongoWorkPool.query(q);
Query q = new Query(FACET_TEST_INDEX, "title:userguide", 10).addCountRequest("keyword", 30);
QueryResult qr = lumongoWorkPool.query(q);
Query q = new Query(FACET_TEST_INDEX, "title:userguide", 10).addCountRequest("issn", 30);
QueryResult qr = lumongoWorkPool.query(q);
Query q = new Query(FACET_TEST_INDEX, "title:userguide", 10).addCountRequest("date", 30);
QueryResult qr = lumongoWorkPool.query(q);
Query q = new Query(FACET_TEST_INDEX, "title:userguide", 10).addDrillDown("date", "2014-10-04");
Query q = new Query(FACET_TEST_INDEX, "title:userguide", 10).addDrillDown("date", "2013-09-04");
Query q = new Query(FACET_TEST_INDEX, "title:userguide", 10).addDrillDown("date", "2013-08-04");
Query q = new Query(FACET_TEST_INDEX, "title:userguide", 10).addDrillDown("issn", "1234-1234");
Query q = new Query(FACET_TEST_INDEX, "title:userguide", 10).addDrillDown("issn", "1234-1234").addDrillDown("issn", "3333-1234");
Query q = new Query(FACET_TEST_INDEX, "title:userguide", 10).addDrillDown("issn", "1234-1234").addDrillDown("country", "France");
Query q = new Query(FACET_TEST_INDEX, "title:userguide", 10);
q.addDrillDown("issn", "1234-1234").addDrillDown("country", "France");
q.addCountRequest("issn");
代码示例来源:origin: lumongo/lumongo
lumongoWorkPool.store(s);
Query query = new Query(SingleNodeTest.MY_TEST_INDEX, "*:*", 10);
query.addFieldSort("date", Direction.ASCENDING);
QueryResult queryResult = lumongoWorkPool.query(query);
代码示例来源:origin: lumongo/lumongo
public void simpleQuery() throws Exception {
int numberOfResults = 10;
String[] indexes = new String[] { MY_INDEX_NAME, MY_INDEX_NAME2 };
String normalLuceneQuery = "issn:1234-1234 AND title:special";
Query query = new Query(indexes, normalLuceneQuery, numberOfResults);
QueryResult queryResult = lumongoWorkPool.query(query);
long totalHits = queryResult.getTotalHits();
System.out.println("Found <" + totalHits + "> hits");
for (ScoredResult sr : queryResult.getResults()) {
System.out.println("Matching document <" + sr.getUniqueId() + "> with score <" + sr.getScore() + ">");
}
}
代码示例来源:origin: lumongo/lumongo
public static void main(String[] args) throws Exception {
LogUtil.loadLogConfig();
lumongoWorkPool = new LumongoWorkPool(new LumongoPoolConfig().addMember("localhost"));
mapper = new Mapper<Article>(Article.class);
int maxSize = 2000;
ClientDocumentCache clientDocumentCache = new ClientDocumentCache(lumongoWorkPool, maxSize);
Query query = new Query("wikipedia", "title:a*", 10);
QueryResult queryResult = lumongoWorkPool.query(query);
BatchFetchResult batchFetchResult = clientDocumentCache.fetch(queryResult);
List<Article> articles = mapper.fromBatchFetchResult(batchFetchResult);
System.out.println(articles);
lumongoWorkPool.shutdown();
}
}
内容来源于网络,如有侵权,请联系作者删除!