本文整理汇总了Java中org.apache.solr.request.SolrQueryRequest类的典型用法代码示例。如果您正苦于以下问题:Java SolrQueryRequest类的具体用法?Java SolrQueryRequest怎么用?Java SolrQueryRequest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SolrQueryRequest类属于org.apache.solr.request包,在下文中一共展示了SolrQueryRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSynonymes
import org.apache.solr.request.SolrQueryRequest; //导入依赖的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.request.SolrQueryRequest; //导入依赖的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.request.SolrQueryRequest; //导入依赖的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.request.SolrQueryRequest; //导入依赖的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.request.SolrQueryRequest; //导入依赖的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.request.SolrQueryRequest; //导入依赖的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.request.SolrQueryRequest; //导入依赖的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.request.SolrQueryRequest; //导入依赖的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.request.SolrQueryRequest; //导入依赖的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.request.SolrQueryRequest; //导入依赖的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.request.SolrQueryRequest; //导入依赖的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: test_QParserGetsCalled
import org.apache.solr.request.SolrQueryRequest; //导入依赖的package包/类
/**
* Basic test that checks that the "/similarity-query"
* defined in the resources/solrconfig.xml does set the query parser
* to the <code>{@link SimilarityParserPlugin}</code>
*/
public void test_QParserGetsCalled() throws Exception {
// arrange
SolrQueryRequest queryRequest = req("testQueryString");
// act
SolrQueryResponse resp = h.queryAndResponse("/similarity-query", queryRequest);
// assert - the only way to check that the similarity parser was used is to check
// the type of the query returned by the similarity parser (for a single term): AugmentedTermQuery
BasicResultContext basicResultContext = (BasicResultContext)resp.getResponse();
Query usedLuceneQuery = basicResultContext.getQuery();
assertTrue(usedLuceneQuery instanceof AugmentedTermQuery);
// cleanup
queryRequest.close();
}
开发者ID:sebastian-hofstaetter,项目名称:ir-generalized-translation-models,代码行数:23,代码来源:SimilarityParserPluginIntegrationTest.java
示例13: test_QParserTwoTerms
import org.apache.solr.request.SolrQueryRequest; //导入依赖的package包/类
/**
* Checks that two terms are parsed and 2 <code>{@link AugmentedTermQuery}</code> inside
* 1 <code>{@link org.apache.lucene.search.BooleanQuery}</code> are returned.
* The schema.xml must define an analyzer for the default field defined in solrconfig.xml
*/
public void test_QParserTwoTerms() throws Exception {
// arrange
SolrQueryRequest queryRequest = req("good days");
// act
SolrQueryResponse resp = h.queryAndResponse("/similarity-query", queryRequest);
// assert - the only way to check that the similarity parser was used is to check
// the type of the query returned by the similarity parser (for a single term): AugmentedTermQuery
BasicResultContext basicResultContext = (BasicResultContext)resp.getResponse();
Query usedLuceneQuery = basicResultContext.getQuery();
assertTrue(usedLuceneQuery instanceof BooleanQuery);
BooleanQuery booleanQuery = (BooleanQuery) usedLuceneQuery;
assertEquals(2, booleanQuery.clauses().size());
assertTrue(booleanQuery.clauses().get(0).getQuery() instanceof AugmentedTermQuery);
assertTrue(booleanQuery.clauses().get(1).getQuery() instanceof AugmentedTermQuery);
// cleanup
queryRequest.close();
}
开发者ID:sebastian-hofstaetter,项目名称:ir-generalized-translation-models,代码行数:28,代码来源:SimilarityParserPluginIntegrationTest.java
示例14: test_QParserTwoTerms_ET
import org.apache.solr.request.SolrQueryRequest; //导入依赖的package包/类
/**
* Checks that two terms are parsed and 2 <code>{@link AugmentedTermQuery}</code> inside
* 1 <code>{@link org.apache.lucene.search.BooleanQuery}</code> are returned.
* The schema.xml must define an analyzer for the default field defined in solrconfig.xml
*/
public void test_QParserTwoTerms_ET() throws Exception {
// arrange
SolrQueryRequest queryRequest = req("good days");
// act
SolrQueryResponse resp = h.queryAndResponse("/similarity-query-et", queryRequest);
// assert - the only way to check that the similarity parser was used is to check
// the type of the query returned by the similarity parser (for a single term): AugmentedTermQuery
BasicResultContext basicResultContext = (BasicResultContext)resp.getResponse();
Query usedLuceneQuery = basicResultContext.getQuery();
assertTrue(usedLuceneQuery instanceof BooleanQuery);
BooleanQuery booleanQuery = (BooleanQuery) usedLuceneQuery;
assertEquals(2, booleanQuery.clauses().size());
assertTrue(booleanQuery.clauses().get(0).getQuery() instanceof AugmentedTermQuery);
assertTrue(booleanQuery.clauses().get(1).getQuery() instanceof AugmentedTermQuery);
// cleanup
queryRequest.close();
}
开发者ID:sebastian-hofstaetter,项目名称:ir-generalized-translation-models,代码行数:28,代码来源:SimilarityParserPluginIntegrationTest.java
示例15: newFrom
import org.apache.solr.request.SolrQueryRequest; //导入依赖的package包/类
/**
* Creates a new {@link SolrQueryRequest} from a given prototype and injects there a set of params.
*
* @param request the prototype {@link SolrQueryRequest}.
* @param params the parameters that will be injected.
* @return a {@link SolrQueryRequest} clone.
*/
public SolrQueryRequest newFrom(final SolrQueryRequest request, final SolrParams params) {
return new SolrQueryRequestBase(
request.getCore(),
new ModifiableSolrParams(params),
new RTimerTree()) {
@Override
public Map<Object, Object> getContext() {
return request.getContext();
}
@Override
public SolrIndexSearcher getSearcher() {
return request.getSearcher();
}
};
}
开发者ID:spaziocodice,项目名称:invisible-queries-request-handler,代码行数:24,代码来源:InvisibleQueriesRequestHandler.java