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

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

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

Query.addFieldSort介绍

暂无

代码示例

代码示例来源: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

q.addFieldSort(sortDesc, Direction.DESCENDING);

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

query.addFieldSort("issn");
QueryResult queryResult = lumongoWorkPool.query(query);

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

query.addFieldSort("date", Direction.ASCENDING);
QueryResult queryResult = lumongoWorkPool.query(query);

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

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());
Query sortQuery = new Query(MY_TEST_INDEX, "an:[0 TO 5]", 2).addFieldSort("an").setResultFetchType(Lumongo.FetchType.FULL);
QueryResult first = lumongoWorkPool.query(sortQuery);
assertEquals("Result size is not 2", 2, first.getResults().size());
Query sortQuery = new Query(MY_TEST_INDEX, "an:[0 TO 5]", 2).addFieldSort("an").setResultFetchType(Lumongo.FetchType.FULL);
QueryResult first = lumongoWorkPool.query(sortQuery);
assertEquals("Result size is not 2", 2, first.getResults().size());
Query sortQuery = new Query(MY_TEST_INDEX, "an:[0 TO 5]", 2).addFieldSort("an").setResultFetchType(Lumongo.FetchType.FULL);
QueryResult first = lumongoWorkPool.query(sortQuery);
assertEquals("Result size is not 2", 2, first.getResults().size());

相关文章