本文整理匯總了Java中org.apache.solr.client.solrj.SolrQuery.setRequestHandler方法的典型用法代碼示例。如果您正苦於以下問題:Java SolrQuery.setRequestHandler方法的具體用法?Java SolrQuery.setRequestHandler怎麽用?Java SolrQuery.setRequestHandler使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.solr.client.solrj.SolrQuery
的用法示例。
在下文中一共展示了SolrQuery.setRequestHandler方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testRuntimeLib
import org.apache.solr.client.solrj.SolrQuery; //導入方法依賴的package包/類
@Test
public void testRuntimeLib() throws SolrServerException, IOException {
SearchServer server = testSearchServer.getSearchServer();
SolrClient client = (SolrClient) server.getBackend();
SolrInputDocument document = new SolrInputDocument();
document.setField("_id_", "1");
document.setField("_type_", "doc");
document.setField("dynamic_multi_facet_string_f1", "test");
document.setField("dynamic_multi_facet_string_f2", "hello");
client.add(document);
client.commit();
SolrQuery query = new SolrQuery("t");
query.setRequestHandler("/suggester");
query.set("suggestion.df", "facets");
query.set("suggestion.field", "dynamic_multi_facet_string_f1");
QueryResponse response = client.query(query);
assertEquals(1, ((HashMap) response.getResponse().get("suggestions")).get("suggestion_count"));
}
示例2: getQuery
import org.apache.solr.client.solrj.SolrQuery; //導入方法依賴的package包/類
private SolrQuery getQuery() {
SolrQuery solrQuery = new SolrQuery();
MCRConfiguration config = MCRConfiguration.instance();
// query
String idQuery = getResult().stream()
.map(getIdentifier())
.map(MCRSolrUtils::escapeSearchValue)
.collect(Collectors.joining(" OR ", "id:(", ")"));
solrQuery.setQuery(idQuery);
solrQuery.setFilterQueries(query);
solrQuery.setFields("id");
solrQuery.setRows(getResult().size());
// request handler
solrQuery.setRequestHandler(config.getString(getConfigPrefix() + "Search.RequestHandler", "/select"));
return solrQuery;
}
示例3: createDocumentQuery
import org.apache.solr.client.solrj.SolrQuery; //導入方法依賴的package包/類
@Override
public SolrQuery createDocumentQuery(String docId) {
// make a query to look up a specific document by its ID
final SolrQuery query = getDefaultDocumentQuery();
// we can use the 'fast' request handler here, document ranking is of no interest
query.setRequestHandler(FacetConstants.SOLR_REQUEST_HANDLER_FAST);
// consider all documents
query.setQuery(SOLR_SEARCH_ALL);
// filter by ID
// check for ID value in both 'id' and 'self link' fields, both ought to
// be unique and self link use to be ID in old VLO, so this should keep old
// URL's valid with a minimal likelihood of clashes
final ImmutableMap<String, String> idOrQueryMap = ImmutableMap.<String, String>builder()
.put(FacetConstants.FIELD_ID, docId)
.put(FacetConstants.FIELD_SELF_LINK, docId)
.build();
query.addFilterQuery(createFilterOrQuery(idOrQueryMap));
// one result max
query.setRows(1);
return query;
}
示例4: getChoices
import org.apache.solr.client.solrj.SolrQuery; //導入方法依賴的package包/類
/**
* Returns list of suggestions for incomplete input (used for autocomplete
* function)
*
* @param input user input
* @return iterator over suggestions
*/
@Override
public Iterator<String> getChoices(String input) {
if (input != null) {
final SolrQuery query = new SolrQuery();
query.setQuery(input.toLowerCase());
query.setRequestHandler("/suggest");
final QueryResponse response = fireQuery(sanitise(query));
if (response.getSpellCheckResponse() != null) {
final List<Suggestion> suggestions = response.getSpellCheckResponse().getSuggestions();
if (suggestions.size() > 0) {
return suggestions.get(0).getAlternatives().iterator();
}
}
}
return Collections.emptyIterator();
}
示例5: printStats
import org.apache.solr.client.solrj.SolrQuery; //導入方法依賴的package包/類
/**
* Gibt für das übergebene Indexfeld die drei Indexterme aus, die die größte Document Frequency haben.
* Es werden hierbei aber nur Indexterme betrachtet, die mit einem Buchstaben beginnen.
*
* @param indexFieldName Feldname des Indexfelds
*/
private void printStats(String indexFieldName) {
System.out.println("- - - - - Field Statistics for Index Field " + indexFieldName + " - - - - -");
SolrQuery query = new SolrQuery();
query.setRequestHandler("/terms");
query.setTermsLimit(3);
query.setTermsSortString(TermsParams.TERMS_SORT_COUNT);
query.addTermsField(indexFieldName);
query.setTermsRegex("^[a-zA-Z].*");
QueryRequest request = new QueryRequest(query);
request.setBasicAuthCredentials(Configuration.USERNAME, Configuration.PASSWORD);
try {
List<TermsResponse.Term> terms = request.process(solrClient).getTermsResponse().getTerms(indexFieldName);
if (terms != null) {
for (TermsResponse.Term term : terms) {
System.out.println(term.getTerm() + " (df = " + term.getFrequency() + ")");
}
}
} catch (SolrServerException|IOException e) {
System.err.println("Fehler bei der Term-Lookup im Dictionary");
}
}
示例6: getCapabilities
import org.apache.solr.client.solrj.SolrQuery; //導入方法依賴的package包/類
@Override
public AgentControllerCapabilities getCapabilities(String controllerId) {
this.logger.debug("Retrieving agent controller capabilities for controller with ID '{}'.", controllerId);
SolrQuery solrQuery = new SolrQuery();
solrQuery.setRequestHandler("/get");
solrQuery.set("id", this.getCapabilitiesId(controllerId));
try {
QueryResponse queryResponse = this.solrClient.query(solrQuery);
SolrDocument solrDocument = (SolrDocument) queryResponse.getResponse().get("doc");
if (solrDocument == null) {
return null;
}
String content = SolrDocumentHelper.getString(solrDocument, FIELD_CONTENT);
return AgentControllerCapabilitiesJsonDeserializer.fromJson(content);
} catch (SolrServerException | IOException e) {
throw new DataRetrievalException("Could not retrieve agent controller capabilities.", e);
}
}
示例7: getOrder
import org.apache.solr.client.solrj.SolrQuery; //導入方法依賴的package包/類
@Override
public Order getOrder(String controllerId) {
this.logger.debug("Retrieving order for controller with ID {}.", controllerId);
SolrQuery solrQuery = new SolrQuery();
solrQuery.setRequestHandler("/get");
solrQuery.set("id", this.getOrderId(controllerId));
try {
QueryResponse queryResponse = this.solrClient.query(solrQuery);
SolrDocument solrDocument = (SolrDocument) queryResponse.getResponse().get("doc");
if (solrDocument == null) {
return null;
}
Order result = new Order();
result.setId(getString(solrDocument, FIELD_ID));
result.setContent(getString(solrDocument, FIELD_CONTENT));
result.setLastModified(getDate(solrDocument, FIELD_TIMESTAMP));
return result;
} catch (SolrServerException | IOException e) {
throw new DataRetrievalException("Could not retrieve order.", e);
}
}
示例8: getSuggestions
import org.apache.solr.client.solrj.SolrQuery; //導入方法依賴的package包/類
/**
* Get suggestions from the suggester component.
* @param input analysed by the suggester component.
* @return the suggester component response.
* @throws IOException network error.
* @throws SolrServerException solr error.
*/
public SuggesterResponse getSuggestions(String input) throws IOException, SolrServerException
{
SolrQuery query = new SolrQuery(input);
query.setRequestHandler("/suggest");
return search(query).getSuggesterResponse();
}
示例9: restoreSolr5Index
import org.apache.solr.client.solrj.SolrQuery; //導入方法依賴的package包/類
/**
* Performs Solr restoration.
*
* @param properties properties containing arguments to execute the restoration.
*/
private static void restoreSolr5Index (Properties properties) throws
IOException, SolrServerException
{
String solrHome = properties.getProperty ("dhus.solr.home");
String coreName = properties.getProperty ("dhus.solr.core.name");
final String name = properties.getProperty ("dhus.solr.backup.name");
final String location = properties.getProperty (
"dhus.solr.backup.location");
if (solrHome == null || coreName == null || name == null ||
location == null)
{
throw new UnsupportedOperationException ();
}
System.setProperty ("solr.solr.home", solrHome);
CoreContainer core = new CoreContainer (solrHome);
EmbeddedSolrServer server = new EmbeddedSolrServer (core, coreName);
try
{
server.getCoreContainer ().load ();
SolrQuery query = new SolrQuery();
query.setRequestHandler("/replication");
query.set("command", "restore");
query.set("name", name);
query.set("location", location);
server.query(query);
LOGGER.info("SolR indexes restored.");
}
finally
{
server.close();
}
}
示例10: buildSolrQuery
import org.apache.solr.client.solrj.SolrQuery; //導入方法依賴的package包/類
protected SolrQuery buildSolrQuery(RealTimeGet search, DocumentFactory assets) {
SolrQuery query = new SolrQuery();
query.setRequestHandler("/get");
search.getValues().forEach(v -> query.add("id" , v.toString()));
return query;
}
示例11: queryWatson
import org.apache.solr.client.solrj.SolrQuery; //導入方法依賴的package包/類
public static QueryResponse queryWatson(String question) {
solrClient = getSolrClient(service.getSolrUrl(SOLR_CLUSTER_ID), USERNAME, PASSWORD);
SolrQuery query = new SolrQuery(question);
query.setParam("ranker_id", RANKER_ID);
query.setRequestHandler("/fcselect"); // use if your solrconfig.xml file does not specify fcselect as the default request handler
QueryResponse response = null;
try {
response = solrClient.query("example_collection", query);
} catch (Exception e) {
e.printStackTrace();
}
return response;
}
示例12: getBaseQuery
import org.apache.solr.client.solrj.SolrQuery; //導入方法依賴的package包/類
private SolrQuery getBaseQuery(String restrictionField) {
String configPrefix = this.identify.getConfigPrefix();
SolrQuery query = new SolrQuery();
// query
String restriction = getConfig().getString(configPrefix + "Search.Restriction", null);
if (restriction != null) {
query.set(restrictionField, restriction);
}
String[] requiredFields = Stream.concat(Stream.of("id", getModifiedField()), getRequiredFieldNames().stream())
.toArray(String[]::new);
query.setFields(requiredFields);
// request handler
query.setRequestHandler(getConfig().getString(configPrefix + "Search.RequestHandler", "/select"));
return query;
}
示例13: execute
import org.apache.solr.client.solrj.SolrQuery; //導入方法依賴的package包/類
@Override
public RepeatStatus execute(StepContribution contribution, ChunkContext context){
SolrQuery query = new SolrQuery();
query.setRequestHandler("/suggest");
query.setParam("suggest.dictionary", suggester);
query.setParam("suggest.build", true);
try {
solrClient.query(query);
} catch (Exception e) {
e.printStackTrace();
}
return RepeatStatus.FINISHED;
}
示例14: testTermsResponse
import org.apache.solr.client.solrj.SolrQuery; //導入方法依賴的package包/類
@Test
public void testTermsResponse() throws Exception {
SolrInputDocument doc = new SolrInputDocument();
doc.setField("id", 1);
doc.setField("terms_s", "samsung");
getSolrServer().add(doc);
getSolrServer().commit(true, true);
SolrQuery query = new SolrQuery();
query.setRequestHandler("/terms");
query.setTerms(true);
query.setTermsLimit(5);
query.setTermsLower("s");
query.setTermsPrefix("s");
query.addTermsField("terms_s");
query.setTermsMinCount(1);
QueryRequest request = new QueryRequest(query);
List<Term> terms = request.process(getSolrServer()).getTermsResponse().getTerms("terms_s");
Assert.assertNotNull(terms);
Assert.assertEquals(terms.size(), 1);
Term term = terms.get(0);
Assert.assertEquals(term.getTerm(), "samsung");
Assert.assertEquals(term.getFrequency(), 1);
}
示例15: realTimeGet
import org.apache.solr.client.solrj.SolrQuery; //導入方法依賴的package包/類
protected SolrDocument realTimeGet(String id) throws SolrServerException, IOException {
SolrQuery solrQuery = new SolrQuery();
solrQuery.setRequestHandler("/get");
solrQuery.set("id", id);
QueryResponse response = this.solrClient.query(solrQuery);
return (SolrDocument) response.getResponse().get("doc");
}