本文整理匯總了Java中org.apache.solr.common.params.CommonParams類的典型用法代碼示例。如果您正苦於以下問題:Java CommonParams類的具體用法?Java CommonParams怎麽用?Java CommonParams使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
CommonParams類屬於org.apache.solr.common.params包,在下文中一共展示了CommonParams類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testSynonymes
import org.apache.solr.common.params.CommonParams; //導入依賴的package包/類
/**
* Tests MBC-1203 (Static synonyms)
* Attention! To enable this, make sure that you use the WhiteSpaceTokenizer (for query and index).
*/
@Test
@Ignore //At the moment synonyms are not supported in suggestions
public void testSynonymes() {
ModifiableSolrParams params = new ModifiableSolrParams();
params.add(SuggestionRequestParams.SUGGESTION, "true");
params.add(CommonParams.QT,"/suggester");
params.add(CommonParams.Q, "xalps");
params.add(SuggestionRequestParams.SUGGESTION_FIELD, "dynamic_multi_stored_suggest_string_name");
params.add(SuggestionRequestParams.SUGGESTION_DF, "suggestions");
SolrQueryRequest req = new LocalSolrQueryRequest( core, params );
assertQ("suggester - test synonym mapping for single facet",req,
"//response/lst[@name='suggestions']/int[@name='suggestion_count'][.='2']",
"//response/lst[@name='suggestions']/lst[@name='suggestion_facets']/lst[@name='dynamic_multi_stored_suggest_string_name']/int[@name='X-Alps'][.='1']",
"//response/lst[@name='suggestions']/lst[@name='suggestion_facets']/lst[@name='dynamic_multi_stored_suggest_string_name']/int[@name='My xa'][.='1']");
}
示例2: test_MBC_3646_1
import org.apache.solr.common.params.CommonParams; //導入依賴的package包/類
public void test_MBC_3646_1() {
ModifiableSolrParams params = new ModifiableSolrParams();
params.add(SuggestionRequestParams.SUGGESTION,"true");
params.add(CommonParams.QT,"/suggester");
params.add(CommonParams.Q,"MI123");
params.add(SuggestionRequestParams.SUGGESTION_FIELD,"dynamic_multi_stored_suggest_string_id");
params.add(SuggestionRequestParams.SUGGESTION_DF,"suggestions");
SolrQueryRequest req = new LocalSolrQueryRequest( core, params );
assertQ("suggester - test number search without result", req,
"//response/lst[@name='suggestions']/int[@name='suggestion_count'][.='1']",
"//response/lst[@name='suggestions']/lst[@name='suggestion_facets']/lst[@name='dynamic_multi_stored_suggest_string_id']/int[@name='MI123-456-789'][.='1']");
}
示例3: test_MBC_3646_2
import org.apache.solr.common.params.CommonParams; //導入依賴的package包/類
public void test_MBC_3646_2() {
ModifiableSolrParams params = new ModifiableSolrParams();
params.add(SuggestionRequestParams.SUGGESTION,"true");
params.add(CommonParams.QT,"/suggester");
params.add(CommonParams.Q,"MI123-456-788");
params.add(CommonParams.FQ,"dynamic_multi_stored_suggest_string_id:MI123-456-788"); //filter for non existing facet -> no suggestion should be returned
params.add(SuggestionRequestParams.SUGGESTION_FIELD,"dynamic_multi_stored_suggest_string_id");
params.add(SuggestionRequestParams.SUGGESTION_DF,"suggestions");
SolrQueryRequest req = new LocalSolrQueryRequest( core, params );
assertQ("suggester - test number search without result", req,
"not(//response/lst[@name='spellcheck'])");
}
示例4: testQueryTermLimit
import org.apache.solr.common.params.CommonParams; //導入依賴的package包/類
public void testQueryTermLimit() {
ModifiableSolrParams params = new ModifiableSolrParams();
params.add(SuggestionRequestParams.SUGGESTION,"true");
params.add(CommonParams.QT,"/suggester");
params.add(CommonParams.Q,"se");
params.add(SuggestionRequestParams.SUGGESTION_FIELD,"dynamic_multi_stored_suggest_string_name");
params.add(SuggestionRequestParams.SUGGESTION_TERM_LIMIT,"1");
SolrQueryRequest req = new LocalSolrQueryRequest( core, params );
assertQ("suggester - simple facet suggestion for 'sebasti'",req,
"//response/lst[@name='suggestions']/int[@name='suggestion_count'][.='3']",
"//response/lst[@name='suggestions']/lst[@name='suggestion_facets']/lst[@name='dynamic_multi_stored_suggest_string_name']/int[@name='sebastien loeb'][.='2']",
"//response/lst[@name='suggestions']/lst[@name='suggestion_facets']/lst[@name='dynamic_multi_stored_suggest_string_name']/int[@name='sebastian vettel'][.='1']",
"//response/lst[@name='suggestions']/lst[@name='suggestion_facets']/lst[@name='dynamic_multi_stored_suggest_string_name']/int[@name='sebastien vettel'][.='1']");
}
示例5: multiFacetSuggestionTest
import org.apache.solr.common.params.CommonParams; //導入依賴的package包/類
@Test
public void multiFacetSuggestionTest() {
ModifiableSolrParams params = new ModifiableSolrParams();
params.add(SuggestionRequestParams.SUGGESTION,"true");
params.add(CommonParams.Q,"S");
params.add(CommonParams.QT,"/suggester");
params.add(SuggestionRequestParams.SUGGESTION_FIELD,"dynamic_multi_stored_suggest_string_name");
params.add(SuggestionRequestParams.SUGGESTION_FIELD,"dynamic_multi_stored_suggest_string_place");
SolrQueryRequest req = new LocalSolrQueryRequest( core, params );
assertQ("suggester - simple facet suggestion for 'S'",req,
"//response/lst[@name='suggestions']/int[@name='suggestion_count'][.='3']",
"//response/lst[@name='suggestions']/lst[@name='suggestion_facets']/lst[@name='dynamic_multi_stored_suggest_string_name']/int[@name='sebastian vettel'][.='2']",
"//response/lst[@name='suggestions']/lst[@name='suggestion_facets']/lst[@name='dynamic_multi_stored_suggest_string_name']/int[@name='stefan Bradl'][.='1']",
"//response/lst[@name='suggestions']/lst[@name='suggestion_facets']/lst[@name='dynamic_multi_stored_suggest_string_place']/int[@name='suzuka'][.='2']");
}
示例6: spellcheckSuggestionTest
import org.apache.solr.common.params.CommonParams; //導入依賴的package包/類
@Test
public void spellcheckSuggestionTest() {
ModifiableSolrParams params = new ModifiableSolrParams();
params.add(SuggestionRequestParams.SUGGESTION,"true");
params.add(CommonParams.QT,"/suggester");
params.add(CommonParams.Q,"sepastian");
params.add(SuggestionRequestParams.SUGGESTION_FIELD,"dynamic_multi_stored_suggest_string_name");
params.add(SuggestionRequestParams.SUGGESTION_DF,"suggestions");
SolrQueryRequest req = new LocalSolrQueryRequest( core, params );
assertQ("suggester - spellcheck suggestion for 'sepastian'",req,
"//response/lst[@name='suggestions']/int[@name='suggestion_count'][.='1']",
"//response/lst[@name='suggestions']/lst[@name='suggestion_facets']/lst[@name='dynamic_multi_stored_suggest_string_name']/int[@name='sebastian vettel'][.='2']",
"//response/lst[@name='spellcheck']/lst[@name='collations']/str[@name='collation'][.='sebastian*']");
}
示例7: fqParameterTest
import org.apache.solr.common.params.CommonParams; //導入依賴的package包/類
@Test
public void fqParameterTest() {
ModifiableSolrParams params = new ModifiableSolrParams();
params.add(SuggestionRequestParams.SUGGESTION,"true");
params.add(CommonParams.QT,"/suggester");
params.add(CommonParams.Q,"sebastian");
params.add(SuggestionRequestParams.SUGGESTION_FIELD,"dynamic_multi_stored_suggest_string_name");
params.add(CommonParams.FQ,"dynamic_multi_stored_suggest_string_place:\"(1328869589310-619798898)\"");
SolrQueryRequest req = new LocalSolrQueryRequest( core, params );
assertQ("suggester - spellcheck suggestion for 'sepastian'",req,
"//response/lst[@name='suggestions']/int[@name='suggestion_count'][.='1']",
"//response/lst[@name='suggestions']/lst[@name='suggestion_facets']/lst[@name='dynamic_multi_stored_suggest_string_name']/int[@name='sebastian vettel'][.='1']");
}
示例8: sortingTest
import org.apache.solr.common.params.CommonParams; //導入依賴的package包/類
@Test
public void sortingTest() {
ModifiableSolrParams params = new ModifiableSolrParams();
params.add(SuggestionRequestParams.SUGGESTION,"true");
params.add(CommonParams.QT,"/suggester");
params.add(CommonParams.Q,"s");
params.add(SuggestionRequestParams.SUGGESTION_FIELD,"dynamic_multi_stored_suggest_string_name");
params.add(SuggestionRequestParams.SUGGESTION_FIELD,"dynamic_multi_stored_suggest_string_place");
SolrQueryRequest req = new LocalSolrQueryRequest( core, params );
assertQ("suggester - test single sorting for 's' with 2 facets", req,
"//response/lst[@name='suggestions']/lst[@name='suggestion_facets']/lst[@name='dynamic_multi_stored_suggest_string_name']/int[1][.='2']",
"//response/lst[@name='suggestions']/lst[@name='suggestion_facets']/lst[@name='dynamic_multi_stored_suggest_string_name']/int[2][.='1']",
"//response/lst[@name='suggestions']/lst[@name='suggestion_facets']/lst[@name='dynamic_multi_stored_suggest_string_place']/int[1][.='2']");
//TODO fix
/*assertQ("suggester - test multi sorting for 's' with 2 facets",req,
"//response/lst[@name='suggestions']/lst[@name='suggestion_facets']/lst[1]/int[@name='count'][.='2']",
"//response/lst[@name='suggestions']/lst[@name='suggestion_facets']/lst[2]/int[@name='count'][.='2']",
"//response/lst[@name='suggestions']/lst[@name='suggestion_facets']/lst[3]/int[@name='count'][.='1']");
*/
}
示例9: sortingTest2
import org.apache.solr.common.params.CommonParams; //導入依賴的package包/類
@Test
public void sortingTest2() {
ModifiableSolrParams params = new ModifiableSolrParams();
params.add(SuggestionRequestParams.SUGGESTION,"true");
params.add(CommonParams.QT,"/suggester");
params.add(CommonParams.Q,"ku");
params.add(SuggestionRequestParams.SUGGESTION_FIELD,"dynamic_multi_stored_suggest_string_place");
SolrQueryRequest req = new LocalSolrQueryRequest( core, params );
assertQ("suggester - test single sorting for 'ku' with 2 facets", req,
"//response/lst[@name='suggestions']/lst[@name='suggestion_facets']/lst[@name='dynamic_multi_stored_suggest_string_place']/int[@name='kuala Lumpur'][.='2']",
"//response/lst[@name='suggestions']/lst[@name='suggestion_facets']/lst[@name='dynamic_multi_stored_suggest_string_place']/int[1][.='2']",
"//response/lst[@name='suggestions']/lst[@name='suggestion_facets']/lst[@name='dynamic_multi_stored_suggest_string_place']/int[@name='Havanna kuba'][.='1']");
}
示例10: testFacetTypesSingle
import org.apache.solr.common.params.CommonParams; //導入依賴的package包/類
@Test
public void testFacetTypesSingle() {
ModifiableSolrParams params = new ModifiableSolrParams();
params.add(SuggestionRequestParams.SUGGESTION,"true");
params.add(CommonParams.QT,"/suggester");
params.add(CommonParams.Q,"s");
params.add(SuggestionRequestParams.SUGGESTION_FIELD,"dynamic_multi_stored_suggest_string_name");
params.add(SuggestionRequestParams.SUGGESTION_FIELD,"dynamic_multi_stored_suggest_string_place");
SolrQueryRequest req = new LocalSolrQueryRequest( core, params );
assertQ(req,
"//response/lst[@name='suggestions']/int[@name='suggestion_count'][.='3']",
"//response/lst[@name='suggestions']/lst[@name='suggestion_facets']/lst[@name='dynamic_multi_stored_suggest_string_name']/int[@name='sebastian vettel'][.='2']",
"//response/lst[@name='suggestions']/lst[@name='suggestion_facets']/lst[@name='dynamic_multi_stored_suggest_string_name']/int[@name='stefan Bradl'][.='1']",
"//response/lst[@name='suggestions']/lst[@name='suggestion_facets']/lst[@name='dynamic_multi_stored_suggest_string_place']/int[@name='suzuka'][.='2']");
}
示例11: testSynonyms
import org.apache.solr.common.params.CommonParams; //導入依賴的package包/類
@Test
@Ignore //At the moment synonyms are not supported in suggestions
public void testSynonyms() {
ModifiableSolrParams params = new ModifiableSolrParams();
params.add(SuggestionRequestParams.SUGGESTION,"true");
params.add(CommonParams.QT,"/suggester");
params.add(CommonParams.Q,"xfighter");
params.add(SuggestionRequestParams.SUGGESTION_FIELD,"dynamic_multi_stored_suggest_string_name");
SolrQueryRequest req = new LocalSolrQueryRequest( core, params );
assertQ("suggester - test synonym mapping for single facet", req,
"//response/lst[@name='suggestions']/int[@name='suggestion_count'][.='2']",
"//response/lst[@name='suggestions']/lst[@name='suggestion_facets']/lst[@name='dynamic_multi_stored_suggest_string_name']/int[@name='RBXF'][.='1']",
"//response/lst[@name='suggestions']/lst[@name='suggestion_facets']/lst[@name='dynamic_multi_stored_suggest_string_name']/int[@name='X-fighters'][.='1']");
/* TODO does not work for multifacets
params.add(SuggestionRequestParams.SUGGESTION_MULTIVALUE,"true");
params.set(CommonParams.Q,"RB x-fighter");
assertQ("suggester - test synonym mapping for multi facet",req,
"//response/lst[@name='suggestions']/lst[@name='suggestion_facets']/lst[1]/int[@name='count'][.='2']");
*/
}
示例12: buildSolrRequest
import org.apache.solr.common.params.CommonParams; //導入依賴的package包/類
@Override
protected QueryRequest buildSolrRequest(ComponentConfiguration conf, Template intent, Conversation conversation, long offset, int pageSize, MultiValueMap<String, String> queryParams) {
final ConversationSearchQuery searchQuery = buildQuery(conf, intent, conversation);
if (searchQuery == null) {
return null;
}
// TODO: build the real request.
final SolrQuery solrQuery = new SolrQuery(searchQuery.getKeyword().stream().reduce((s, s2) -> s + " OR " + s2).orElse("*:*"));
solrQuery.addField("*").addField("score");
solrQuery.set(CommonParams.DF, "text");
solrQuery.addFilterQuery(String.format("%s:%s",FIELD_TYPE, TYPE_MESSAGE));
solrQuery.addSort("score", SolrQuery.ORDER.desc).addSort("vote", SolrQuery.ORDER.desc);
// #39 - paging
solrQuery.setStart((int) offset);
solrQuery.setRows(pageSize);
//since #46 the client field is used to filter for the current user
addClientFilter(solrQuery, conversation);
addPropertyFilters(solrQuery, conversation, conf);
return new QueryRequest(solrQuery);
}
示例13: getHeader
import org.apache.solr.common.params.CommonParams; //導入依賴的package包/類
@Override
public Optional<Header> getHeader(String mcrId) {
SolrQuery query = getBaseQuery(CommonParams.FQ);
query.set(CommonParams.Q, "id:" + MCRSolrUtils.escapeSearchValue(mcrId));
query.setRows(1);
// do the query
SolrClient solrClient = MCRSolrClientFactory.getSolrClient();
try {
QueryResponse response = solrClient.query(query);
SolrDocumentList results = response.getResults();
if (!results.isEmpty()) {
return Optional.of(toHeader(results.get(0), getSetResolver(results)));
}
} catch (Exception exc) {
LOGGER.error("Unable to handle solr request", exc);
}
return Optional.empty();
}
示例14: solrQuery
import org.apache.solr.common.params.CommonParams; //導入依賴的package包/類
protected MCROAISolrResult solrQuery(Optional<String> cursor) throws SolrServerException, IOException {
SolrQuery query = getBaseQuery(CommonParams.Q);
// set support
if (this.set != null) {
String setId = this.set.getSetId();
MCROAISetConfiguration<SolrQuery, SolrDocument, String> setConfig = getSetManager().getConfig(setId);
setConfig.getHandler().apply(this.set, query);
}
// from & until
if (this.from != null || this.until != null) {
String fromUntilCondition = buildFromUntilCondition(this.from, this.until);
query.add(CommonParams.FQ, fromUntilCondition);
}
// cursor
query.set(CursorMarkParams.CURSOR_MARK_PARAM, cursor.orElse(CursorMarkParams.CURSOR_MARK_START));
query.set(CommonParams.ROWS, String.valueOf(getPartitionSize()));
query.set(CommonParams.SORT, "id asc");
// do the query
SolrClient solrClient = MCRSolrClientFactory.getSolrClient();
QueryResponse response = solrClient.query(query);
Collection<MCROAISetResolver<String, SolrDocument>> setResolver = getSetResolver(response.getResults());
return new MCROAISolrResult(response, d -> toHeader(d, setResolver));
}
示例15: getEarliestTimestamp
import org.apache.solr.common.params.CommonParams; //導入依賴的package包/類
@Override
public Optional<Instant> getEarliestTimestamp() {
String sortBy = getConfig().getString(getConfigPrefix() + "EarliestDatestamp.SortBy", "modified asc");
String fieldName = getConfig().getString(getConfigPrefix() + "EarliestDatestamp.FieldName", "modified");
String restriction = getConfig().getString(getConfigPrefix() + "Search.Restriction", null);
ModifiableSolrParams params = new ModifiableSolrParams();
params.add(CommonParams.SORT, sortBy);
params.add(CommonParams.Q, restriction);
params.add(CommonParams.FQ, fieldName + ":[* TO *]");
params.add(CommonParams.FL, fieldName);
params.add(CommonParams.ROWS, "1");
SolrClient solrClient = MCRSolrClientFactory.getSolrClient();
try {
QueryResponse response = solrClient.query(params);
SolrDocumentList list = response.getResults();
if (list.size() >= 1) {
Date date = (Date) list.get(0).getFieldValue(fieldName);
return Optional.of(date.toInstant());
}
} catch (Exception exc) {
LOGGER.error("Unable to handle solr request", exc);
}
return Optional.empty();
}