本文整理汇总了Java中org.apache.solr.client.solrj.SolrServer.query方法的典型用法代码示例。如果您正苦于以下问题:Java SolrServer.query方法的具体用法?Java SolrServer.query怎么用?Java SolrServer.query使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.solr.client.solrj.SolrServer
的用法示例。
在下文中一共展示了SolrServer.query方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doAtomicUpdate
import org.apache.solr.client.solrj.SolrServer; //导入方法依赖的package包/类
public void doAtomicUpdate() throws Exception {
log.info("### STARTING doAtomicUpdate");
int nClients = clients.size();
assertEquals(8, nClients);
int expectedVal = 0;
for (SolrServer client : clients) {
client.add(sdoc("id", "b!doc", "foo_i", map("inc",1)));
expectedVal++;
QueryResponse rsp = client.query(params("qt","/get", "id","b!doc"));
Object val = ((Map)rsp.getResponse().get("doc")).get("foo_i");
assertEquals((Integer)expectedVal, val);
}
}
示例2: obtainCollectionCounts
import org.apache.solr.client.solrj.SolrServer; //导入方法依赖的package包/类
private List<VloReport.CollectionCount> obtainCollectionCounts(SolrServer solrServer) throws SolrServerException {
final SolrQuery query = new SolrQuery();
query.setRows(0);
query.setFacet(true);
query.addFacetField(FacetConstants.FIELD_COLLECTION);
query.setFacetLimit(Integer.MAX_VALUE);
final QueryResponse result = solrServer.query(query);
final FacetField collectionField = result.getFacetField(FacetConstants.FIELD_COLLECTION);
logger.debug("Collection field: {}", collectionField.getValues());
final List<VloReport.CollectionCount> counts
= collectionField.getValues().stream().map((count) -> {
VloReport.CollectionCount collectionCount = new VloReport.CollectionCount();
collectionCount.setCollection(count.getName());
collectionCount.setCount(count.getCount());
return collectionCount;
}).collect(Collectors.toList());
return counts;
}
示例3: obtainFacetStats
import org.apache.solr.client.solrj.SolrServer; //导入方法依赖的package包/类
private List<VloReport.Facet> obtainFacetStats(VloConfig config, SolrServer solrServer) throws SolrServerException {
final SolrQuery query = new SolrQuery();
query.setRows(0);
query.setFacet(true);
FacetConstants.AVAILABLE_FACETS.forEach((field) -> {
query.addFacetField(field);
});
query.setFacetLimit(-1);
final QueryResponse result = solrServer.query(query);
final List<FacetField> facetFields = result.getFacetFields();
final List<VloReport.Facet> facets
= facetFields.stream().map((field) -> {
final VloReport.Facet facet = new VloReport.Facet();
facet.setName(field.getName());
facet.setValueCount(field.getValueCount());
return facet;
}).collect(Collectors.toList());
return facets;
}
示例4: searchSolrIndex
import org.apache.solr.client.solrj.SolrServer; //导入方法依赖的package包/类
public QueryResponse searchSolrIndex(String queryString, String fields, int rows, int startOffset) throws SolrServerException {
SolrServer solr = null;
try {
solr = bookeryService.getSolrConnection();
} catch (IOException ex) {
throw new SolrServerException(ex.getMessage());
}
SolrQuery query = new SolrQuery();
query.setQuery(queryString);
query.setRows(rows);
query.setStart(startOffset);
query.setFields(fields);
QueryResponse rsp = solr.query(query);
return rsp;
}
示例5: emitTuples
import org.apache.solr.client.solrj.SolrServer; //导入方法依赖的package包/类
@Override
public void emitTuples()
{
SolrParams solrQueryParams = getQueryParams();
try {
SolrServer solrServer = solrServerConnector.getSolrServer();
QueryResponse response = solrServer.query(solrQueryParams);
SolrDocumentList queriedDocuments = response.getResults();
for (SolrDocument solrDocument : queriedDocuments) {
emitTuple(solrDocument);
lastEmittedTuple = solrDocument;
lastEmittedTimeStamp = System.currentTimeMillis();
logger.debug("Emiting document: " + solrDocument.getFieldValue("name"));
}
} catch (SolrServerException ex) {
throw new RuntimeException("Unable to fetch documents from Solr server", ex);
}
}
示例6: complete
import org.apache.solr.client.solrj.SolrServer; //导入方法依赖的package包/类
public List<String> complete(String query) {
List<String> results = new ArrayList<>();
SolrServer solrServer = new HttpSolrServer("http://" + systemConfig.getSolrHostColonPort() + "/solr");
SolrQuery solrQuery = new SolrQuery();
solrQuery.setParam("qt", "/terms");
solrQuery.setTermsLower(query);
solrQuery.setTermsPrefix(query);
// dataverses and files use SearchFields.NAME
// solrQuery.addTermsField(SearchFields.NAME);
solrQuery.addTermsField("text");
// long datasetFieldDescription = 33L;
// String solrFieldDatasetFieldDescription = datasetFieldService.find(datasetFieldDescription).getSolrField();
// solrQuery.addTermsField(solrFieldDatasetFieldDescription);
List<Term> items = null;
try {
logger.info("Solr query: " + solrQuery);
QueryResponse qr = solrServer.query(solrQuery);
TermsResponse resp = qr.getTermsResponse();
// items = resp.getTerms(SearchFields.NAME);
items = resp.getTerms("text");
// items = resp.getTerms(solrFieldDatasetFieldDescription);
} catch (SolrServerException e) {
items = null;
}
if (items != null) {
for (Term term : items) {
logger.info("term: " + term.getTerm());
results.add(term.getTerm());
}
} else {
logger.info("no terms found");
}
return results;
}
开发者ID:pengchengluo,项目名称:Peking-University-Open-Research-Data-Platform,代码行数:39,代码来源:AutoCompleteBean.java
示例7: SolrResult
import org.apache.solr.client.solrj.SolrServer; //导入方法依赖的package包/类
public SolrResult(DataStore<K, T> dataStore, Query<K, T> query,
SolrServer server, int resultsSize) throws IOException {
super(dataStore, query);
store = (SolrStore<K, T>)dataStore;
ModifiableSolrParams params = new ModifiableSolrParams();
if (query instanceof PartitionQueryImpl) {
query = ((PartitionQueryImpl<K, T>)query).getBaseQuery();
}
String q = ((SolrQuery<K, T>)query).toSolrQuery();
params.set(CommonParams.Q, q);
fields = query.getFields();
if (fields == null) {
params.set(CommonParams.FL, "*");
} else {
HashSet<String> uniqFields = new HashSet<>(Arrays.asList(fields));
String keyFld = ((SolrStore<K, T>)dataStore).getMapping().getPrimaryKey();
uniqFields.add(keyFld); // return also primary key
StringBuilder sb = new StringBuilder();
for (String f : uniqFields) {
if (sb.length() > 0) sb.append(',');
sb.append(f);
}
params.set(CommonParams.FL, sb.toString());
}
params.set(CommonParams.ROWS, resultsSize);
try {
QueryResponse rsp = server.query(params);
list = rsp.getResults();
} catch (SolrServerException e) {
throw new IOException(e);
}
}
示例8: collect
import org.apache.solr.client.solrj.SolrServer; //导入方法依赖的package包/类
@Override
public void collect(VloReport report, VloConfig config, SolrServer solrServer) throws SolrServerException {
final SolrQuery query = new SolrQuery();
query.setQuery("*:*");
query.setRows(0);
final QueryResponse result = solrServer.query(query);
final long recordCount = result.getResults().getNumFound();
report.setRecordCount(recordCount);
}
示例9: searchSolrIndex
import org.apache.solr.client.solrj.SolrServer; //导入方法依赖的package包/类
public static QueryResponse searchSolrIndex(SolrServer solr,String queryString, int rows, int startOffset) throws SolrServerException {
SolrQuery query = new SolrQuery();
query.setQuery(queryString);
query.setRows(rows);
query.setStart(startOffset);
QueryResponse rsp = solr.query(query);
return rsp;
}
示例10: searchSolr
import org.apache.solr.client.solrj.SolrServer; //导入方法依赖的package包/类
public QueryResponse searchSolr(SolrQuery solrQuery) throws SolrServerException {
try {
SolrServer solr = bookeryService.getSolrConnection();
return solr.query(solrQuery);
} catch (IOException ex) {
throw new SolrServerException(ex.getMessage());
}
}
示例11: executeQuery
import org.apache.solr.client.solrj.SolrServer; //导入方法依赖的package包/类
@Override
public QueryResponse executeQuery(String q, String fq, String qt,
boolean highlight, String facetFields, String sort, String sortOrder, Integer rows, Integer start,
String otherParams) throws QueryException {
SolrServer server = SolrServerRegistry.getSolrServer(SolrMeterConfiguration.getProperty(SolrMeterConfiguration.SOLR_SEARCH_URL));
SolrQuery query = this.createQuery(q, fq, qt, highlight, facetFields, sort, sortOrder, rows, start, otherParams);
QueryResponse response = null;
try {
response = server.query(query);
} catch (SolrServerException e) {
throw new QueryException(e);
}
return response;
}
示例12: getBookDetail
import org.apache.solr.client.solrj.SolrServer; //导入方法依赖的package包/类
public List<BookEntry> getBookDetail(String bookID) throws SolrServerException {
SolrServer solr = null;
try {
solr = bookeryService.getSolrConnection();
} catch (IOException ex) {
throw new SolrServerException(ex.getMessage());
}
SolrQuery query = new SolrQuery();
query.setQuery("id:"+bookID);
query.setRows(1);
query.setFields("id,author,title,isbn,publisher,description,language,releaseDate,likes,downloadcount,uploader,viewed,shared,cover,thumbnail,thumbnailgenerated,likedby");
QueryResponse rsp = solr.query(query);
return rsp.getBeans(BookEntry.class);
}
示例13: getEpubBook
import org.apache.solr.client.solrj.SolrServer; //导入方法依赖的package包/类
public List<BookEntry> getEpubBook(String bookID) throws SolrServerException {
SolrServer solr = null;
try {
solr = bookeryService.getSolrConnection();
} catch (IOException ex) {
throw new SolrServerException(ex.getMessage());
}
SolrQuery query = new SolrQuery();
query.setQuery("id:"+bookID);
query.setRows(1);
query.setFields("id,epub");
QueryResponse rsp = solr.query(query);
return rsp.getBeans(BookEntry.class);
}
示例14: getMobiFormat
import org.apache.solr.client.solrj.SolrServer; //导入方法依赖的package包/类
public List<BookEntry> getMobiFormat(String bookID) throws SolrServerException {
SolrServer solr = null;
try {
solr = bookeryService.getSolrConnection();
} catch (IOException ex) {
throw new SolrServerException(ex.getMessage());
}
SolrQuery query = new SolrQuery();
query.setQuery("id:"+bookID);
query.setRows(1);
query.setFields("id,mobi");
QueryResponse rsp = solr.query(query);
return rsp.getBeans(BookEntry.class);
}
示例15: checkSolr
import org.apache.solr.client.solrj.SolrServer; //导入方法依赖的package包/类
public long checkSolr() throws SolrServerException, IOException {
SolrServer solr = bookeryService.getSolrConnection();
SolrQuery query = new SolrQuery();
query.setQuery("*:*");
query.setRows(1);
QueryResponse rsp = solr.query(query);
return rsp.getResults().getNumFound();
}