本文整理汇总了Java中org.apache.solr.handler.component.SearchComponent类的典型用法代码示例。如果您正苦于以下问题:Java SearchComponent类的具体用法?Java SearchComponent怎么用?Java SearchComponent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SearchComponent类属于org.apache.solr.handler.component包,在下文中一共展示了SearchComponent类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: loadSearchComponents
import org.apache.solr.handler.component.SearchComponent; //导入依赖的package包/类
/**
* Register the default search components
*/
private Map<String, SearchComponent> loadSearchComponents()
{
Map<String, SearchComponent> components = new HashMap<>();
initPlugins(components,SearchComponent.class);
for (Map.Entry<String, SearchComponent> e : components.entrySet()) {
SearchComponent c = e.getValue();
if (c instanceof HighlightComponent) {
HighlightComponent hl = (HighlightComponent) c;
if(!HighlightComponent.COMPONENT_NAME.equals(e.getKey())){
components.put(HighlightComponent.COMPONENT_NAME,hl);
}
break;
}
}
addIfNotPresent(components,HighlightComponent.COMPONENT_NAME,HighlightComponent.class);
addIfNotPresent(components,QueryComponent.COMPONENT_NAME,QueryComponent.class);
addIfNotPresent(components,FacetComponent.COMPONENT_NAME,FacetComponent.class);
addIfNotPresent(components,MoreLikeThisComponent.COMPONENT_NAME,MoreLikeThisComponent.class);
addIfNotPresent(components,StatsComponent.COMPONENT_NAME,StatsComponent.class);
addIfNotPresent(components,DebugComponent.COMPONENT_NAME,DebugComponent.class);
addIfNotPresent(components,RealTimeGetComponent.COMPONENT_NAME,RealTimeGetComponent.class);
addIfNotPresent(components,ExpandComponent.COMPONENT_NAME,ExpandComponent.class);
return components;
}
开发者ID:europeana,项目名称:search,代码行数:29,代码来源:SolrCore.java
示例2: loadSearchComponents
import org.apache.solr.handler.component.SearchComponent; //导入依赖的package包/类
/**
* Register the default search components
*/
private Map<String, SearchComponent> loadSearchComponents()
{
Map<String, SearchComponent> components = new HashMap<String, SearchComponent>();
initPlugins(components,SearchComponent.class);
for (Map.Entry<String, SearchComponent> e : components.entrySet()) {
SearchComponent c = e.getValue();
if (c instanceof HighlightComponent) {
HighlightComponent hl = (HighlightComponent) c;
if(!HighlightComponent.COMPONENT_NAME.equals(e.getKey())){
components.put(HighlightComponent.COMPONENT_NAME,hl);
}
break;
}
}
addIfNotPresent(components,HighlightComponent.COMPONENT_NAME,HighlightComponent.class);
addIfNotPresent(components,QueryComponent.COMPONENT_NAME,QueryComponent.class);
addIfNotPresent(components,FacetComponent.COMPONENT_NAME,FacetComponent.class);
addIfNotPresent(components,MoreLikeThisComponent.COMPONENT_NAME,MoreLikeThisComponent.class);
addIfNotPresent(components,StatsComponent.COMPONENT_NAME,StatsComponent.class);
addIfNotPresent(components,DebugComponent.COMPONENT_NAME,DebugComponent.class);
addIfNotPresent(components,RealTimeGetComponent.COMPONENT_NAME,RealTimeGetComponent.class);
return components;
}
开发者ID:pkarmstr,项目名称:NYBC,代码行数:27,代码来源:SolrCore.java
示例3: loadSearchComponents
import org.apache.solr.handler.component.SearchComponent; //导入依赖的package包/类
/**
* Register the default search components
*/
private Map<String, SearchComponent> loadSearchComponents() {
Map<String, SearchComponent> components = new HashMap<String, SearchComponent>();
initPlugins(components, SearchComponent.class);
for(Map.Entry<String, SearchComponent> e : components.entrySet()) {
SearchComponent c = e.getValue();
if(c instanceof HighlightComponent) {
HighlightComponent hl = (HighlightComponent) c;
if(!HighlightComponent.COMPONENT_NAME.equals(e.getKey())) {
components.put(HighlightComponent.COMPONENT_NAME, hl);
}
break;
}
}
addIfNotPresent(components, HighlightComponent.COMPONENT_NAME, HighlightComponent.class);
addIfNotPresent(components, QueryComponent.COMPONENT_NAME, QueryComponent.class);
addIfNotPresent(components, FacetComponent.COMPONENT_NAME, FacetComponent.class);
addIfNotPresent(components, MoreLikeThisComponent.COMPONENT_NAME, MoreLikeThisComponent.class);
addIfNotPresent(components, StatsComponent.COMPONENT_NAME, StatsComponent.class);
addIfNotPresent(components, DebugComponent.COMPONENT_NAME, DebugComponent.class);
addIfNotPresent(components, RealTimeGetComponent.COMPONENT_NAME, RealTimeGetComponent.class);
return components;
}
开发者ID:netboynb,项目名称:search-core,代码行数:26,代码来源:SolrCore.java
示例4: test
import org.apache.solr.handler.component.SearchComponent; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
protected NamedList test(ModifiableSolrParams params, String componentName) {
SolrCore core = h.getCore();
SearchComponent sc = core.getSearchComponent(componentName);
assertTrue("XJoinSearchComponent not found in solrconfig", sc != null);
QParserPlugin qp = core.getQueryPlugin("xjoin");
assertTrue("XJoinQParserPlugin not found in solrconfig", qp != null);
params.add("q", "*:*");
params.add("fq", "{!xjoin}" + componentName);
SolrQueryResponse rsp = new SolrQueryResponse();
rsp.add("responseHeader", new SimpleOrderedMap<>());
SolrQueryRequest req = new LocalSolrQueryRequest(core, params);
SolrRequestHandler handler = core.getRequestHandler("standard");
handler.handleRequest(req, rsp);
req.close();
assertNull(rsp.getException());
return rsp.getValues();
}
开发者ID:flaxsearch,项目名称:BioSolr,代码行数:25,代码来源:AbstractXJoinTestCase.java
示例5: modifyRequest
import org.apache.solr.handler.component.SearchComponent; //导入依赖的package包/类
@Override
public void modifyRequest(ResponseBuilder rb, SearchComponent who, ShardRequest sreq) {
System.out.println("===== MODIFY REQUEST =====");
System.out.println("who=" + who);
System.out.println("purpose=" + sreq.purpose);
if ((sreq.purpose & ShardRequest.PURPOSE_GET_FIELDS) > 0) {
if (fieldListIncludes(rb, DJOIN_FIELD)) {
Set<String> fl = new HashSet<>(getFieldList(sreq.params));
fl.add(SHARD_FIELD);
sreq.params.set(CommonParams.FL, String.join(",", fl));
}
// enable faceting on shards to get join ids
sreq.params.set("facet", true);
sreq.params.set("facet.field", joinField);
}
}
开发者ID:flaxsearch,项目名称:BioSolr,代码行数:18,代码来源:NumFoundSearchComponent.java
示例6: modifyRequest
import org.apache.solr.handler.component.SearchComponent; //导入依赖的package包/类
@Override
public void modifyRequest(ResponseBuilder rb, SearchComponent who, ShardRequest sreq) {
if (!checkComponentShouldProcess(rb)) {
return;
}
sreq.params.set(getComponentName(), "false");
}
开发者ID:sematext,项目名称:solr-researcher,代码行数:9,代码来源:AbstractReSearcherComponent.java
示例7: modifyRequest
import org.apache.solr.handler.component.SearchComponent; //导入依赖的package包/类
@Override
public void modifyRequest(ResponseBuilder rb, SearchComponent who, ShardRequest sreq) {
SolrParams params = rb.req.getParams();
if (!params.getBool(COMPONENT_NAME, false) || !params.getBool(ClusteringParams.USE_SEARCH_RESULTS, false)) {
return;
}
sreq.params.remove(COMPONENT_NAME);
if( ( sreq.purpose & ShardRequest.PURPOSE_GET_FIELDS ) != 0 ){
String fl = sreq.params.get(CommonParams.FL,"*");
// if fl=* then we don't need check
if( fl.indexOf( '*' ) >= 0 ) return;
Set<String> fields = getSearchClusteringEngine(rb).getFieldsToLoad(rb.req);
if( fields == null || fields.size() == 0 ) return;
StringBuilder sb = new StringBuilder();
String[] flparams = fl.split( "[,\\s]+" );
Set<String> flParamSet = new HashSet<>(flparams.length);
for( String flparam : flparams ){
// no need trim() because of split() by \s+
flParamSet.add(flparam);
}
for( String aFieldToLoad : fields ){
if( !flParamSet.contains( aFieldToLoad ) ){
sb.append( ',' ).append( aFieldToLoad );
}
}
if( sb.length() > 0 ){
sreq.params.set( CommonParams.FL, fl + sb.toString() );
}
}
}
开发者ID:europeana,项目名称:search,代码行数:31,代码来源:ClusteringComponent.java
示例8: createInitInstance
import org.apache.solr.handler.component.SearchComponent; //导入依赖的package包/类
public <T extends Object> T createInitInstance(PluginInfo info,Class<T> cast, String msg, String defClassName){
if(info == null) return null;
T o = createInstance(info.className == null ? defClassName : info.className,cast, msg);
if (o instanceof PluginInfoInitialized) {
((PluginInfoInitialized) o).init(info);
} else if (o instanceof NamedListInitializedPlugin) {
((NamedListInitializedPlugin) o).init(info.initArgs);
}
if(o instanceof SearchComponent) {
((SearchComponent) o).setName(info.name);
}
return o;
}
开发者ID:europeana,项目名称:search,代码行数:14,代码来源:SolrCore.java
示例9: addIfNotPresent
import org.apache.solr.handler.component.SearchComponent; //导入依赖的package包/类
private <T> void addIfNotPresent(Map<String ,T> registry, String name, Class<? extends T> c){
if(!registry.containsKey(name)){
T searchComp = resourceLoader.newInstance(c.getName(), c);
if (searchComp instanceof NamedListInitializedPlugin){
((NamedListInitializedPlugin)searchComp).init( new NamedList<String>() );
}
if(searchComp instanceof SearchComponent) {
((SearchComponent)searchComp).setName(name);
}
registry.put(name, searchComp);
if (searchComp instanceof SolrInfoMBean){
infoRegistry.put(((SolrInfoMBean)searchComp).getName(), (SolrInfoMBean)searchComp);
}
}
}
开发者ID:europeana,项目名称:search,代码行数:16,代码来源:SolrCore.java
示例10: getSearchComponent
import org.apache.solr.handler.component.SearchComponent; //导入依赖的package包/类
/**
* @return a Search Component registered to a given name. Throw an exception if the component is undefined
*/
public SearchComponent getSearchComponent( String name )
{
SearchComponent component = searchComponents.get( name );
if( component == null ) {
throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,
"Unknown Search Component: "+name );
}
return component;
}
开发者ID:europeana,项目名称:search,代码行数:13,代码来源:SolrCore.java
示例11: testCallMBeanInfo
import org.apache.solr.handler.component.SearchComponent; //导入依赖的package包/类
/**
* Gets a list of everything we can find in the classpath and makes sure it has
* a name, description, etc...
*/
public void testCallMBeanInfo() throws Exception {
List<Class> classes = new ArrayList<>();
classes.addAll(getClassesForPackage(StandardRequestHandler.class.getPackage().getName()));
classes.addAll(getClassesForPackage(SearchHandler.class.getPackage().getName()));
classes.addAll(getClassesForPackage(SearchComponent.class.getPackage().getName()));
classes.addAll(getClassesForPackage(LukeRequestHandler.class.getPackage().getName()));
classes.addAll(getClassesForPackage(DefaultSolrHighlighter.class.getPackage().getName()));
classes.addAll(getClassesForPackage(LRUCache.class.getPackage().getName()));
// System.out.println(classes);
int checked = 0;
for( Class clazz : classes ) {
if( SolrInfoMBean.class.isAssignableFrom( clazz ) ) {
try {
SolrInfoMBean info = (SolrInfoMBean)clazz.newInstance();
//System.out.println( info.getClass() );
assertNotNull( info.getName() );
assertNotNull( info.getDescription() );
assertNotNull( info.getCategory() );
if( info instanceof LRUCache ) {
continue;
}
assertNotNull( info.toString() );
// increase code coverage...
assertNotNull( info.getDocs() + "" );
assertNotNull( info.getStatistics()+"" );
checked++;
}
catch( InstantiationException ex ) {
// expected...
//System.out.println( "unable to initalize: "+clazz );
}
}
}
assertTrue( "there are at least 10 SolrInfoMBean that should be found in the classpath, found " + checked, checked > 10 );
}
开发者ID:europeana,项目名称:search,代码行数:44,代码来源:SolrInfoMBeanTest.java
示例12: testCollateWithFilter
import org.apache.solr.handler.component.SearchComponent; //导入依赖的package包/类
@Test
public void testCollateWithFilter() throws Exception
{
SolrCore core = h.getCore();
SearchComponent speller = core.getSearchComponent("spellcheck");
assertTrue("speller is null and it shouldn't be", speller != null);
ModifiableSolrParams params = new ModifiableSolrParams();
params.add(SpellCheckComponent.COMPONENT_NAME, "true");
params.add(SpellingParams.SPELLCHECK_BUILD, "true");
params.add(SpellingParams.SPELLCHECK_COUNT, "10");
params.add(SpellingParams.SPELLCHECK_COLLATE, "true");
params.add(SpellingParams.SPELLCHECK_MAX_COLLATION_TRIES, "10");
params.add(SpellingParams.SPELLCHECK_MAX_COLLATIONS, "10");
params.add(CommonParams.Q, "lowerfilt:(+fauth +home +loane)");
params.add(CommonParams.FQ, "NOT(id:1)");
//Because a FilterQuery is applied which removes doc id#1 from possible hits, we would
//not want the collations to return us "lowerfilt:(+faith +hope +loaves)" as this only matches doc id#1.
SolrRequestHandler handler = core.getRequestHandler("spellCheckCompRH");
SolrQueryResponse rsp = new SolrQueryResponse();
rsp.add("responseHeader", new SimpleOrderedMap());
SolrQueryRequest req = new LocalSolrQueryRequest(core, params);
handler.handleRequest(req, rsp);
req.close();
NamedList values = rsp.getValues();
NamedList spellCheck = (NamedList) values.get("spellcheck");
NamedList suggestions = (NamedList) spellCheck.get("suggestions");
List<String> collations = suggestions.getAll("collation");
assertTrue(collations.size() > 0);
for(String collation : collations) {
assertTrue(!collation.equals("lowerfilt:(+faith +hope +loaves)"));
}
}
开发者ID:europeana,项目名称:search,代码行数:35,代码来源:SpellCheckCollatorTest.java
示例13: testCollateWithGrouping
import org.apache.solr.handler.component.SearchComponent; //导入依赖的package包/类
@Test
public void testCollateWithGrouping() throws Exception
{
SolrCore core = h.getCore();
SearchComponent speller = core.getSearchComponent("spellcheck");
assertTrue("speller is null and it shouldn't be", speller != null);
ModifiableSolrParams params = new ModifiableSolrParams();
params.add(SpellCheckComponent.COMPONENT_NAME, "true");
params.add(SpellingParams.SPELLCHECK_BUILD, "true");
params.add(SpellingParams.SPELLCHECK_COUNT, "10");
params.add(SpellingParams.SPELLCHECK_COLLATE, "true");
params.add(SpellingParams.SPELLCHECK_MAX_COLLATION_TRIES, "5");
params.add(SpellingParams.SPELLCHECK_MAX_COLLATIONS, "1");
params.add(CommonParams.Q, "lowerfilt:(+fauth)");
params.add(GroupParams.GROUP, "true");
params.add(GroupParams.GROUP_FIELD, "id");
//Because a FilterQuery is applied which removes doc id#1 from possible hits, we would
//not want the collations to return us "lowerfilt:(+faith +hope +loaves)" as this only matches doc id#1.
SolrRequestHandler handler = core.getRequestHandler("spellCheckCompRH");
SolrQueryResponse rsp = new SolrQueryResponse();
rsp.add("responseHeader", new SimpleOrderedMap());
SolrQueryRequest req = new LocalSolrQueryRequest(core, params);
handler.handleRequest(req, rsp);
req.close();
NamedList values = rsp.getValues();
NamedList spellCheck = (NamedList) values.get("spellcheck");
NamedList suggestions = (NamedList) spellCheck.get("suggestions");
List<String> collations = suggestions.getAll("collation");
assertTrue(collations.size() == 1);
}
开发者ID:europeana,项目名称:search,代码行数:33,代码来源:SpellCheckCollatorTest.java
示例14: testZeroTries
import org.apache.solr.handler.component.SearchComponent; //导入依赖的package包/类
@Test
public void testZeroTries() throws Exception
{
SolrCore core = h.getCore();
SearchComponent speller = core.getSearchComponent("spellcheck");
assertTrue("speller is null and it shouldn't be", speller != null);
ModifiableSolrParams params = new ModifiableSolrParams();
params.add(SpellCheckComponent.COMPONENT_NAME, "true");
params.add(SpellCheckComponent.SPELLCHECK_BUILD, "true");
params.add(SpellCheckComponent.SPELLCHECK_COUNT, "10");
params.add(SpellCheckComponent.SPELLCHECK_COLLATE, "true");
params.add(SpellCheckComponent.SPELLCHECK_MAX_COLLATION_TRIES, "0");
params.add(SpellCheckComponent.SPELLCHECK_MAX_COLLATIONS, "2");
params.add(CommonParams.Q, "lowerfilt:(+fauth)");
SolrRequestHandler handler = core.getRequestHandler("spellCheckCompRH");
SolrQueryResponse rsp = new SolrQueryResponse();
rsp.add("responseHeader", new SimpleOrderedMap());
SolrQueryRequest req = new LocalSolrQueryRequest(core, params);
handler.handleRequest(req, rsp);
req.close();
NamedList values = rsp.getValues();
NamedList spellCheck = (NamedList) values.get("spellcheck");
NamedList suggestions = (NamedList) spellCheck.get("suggestions");
List<String> collations = suggestions.getAll("collation");
assertTrue(collations.size() == 2);
}
开发者ID:europeana,项目名称:search,代码行数:28,代码来源:SpellCheckCollatorTest.java
示例15: modifyRequest
import org.apache.solr.handler.component.SearchComponent; //导入依赖的package包/类
@Override
public void modifyRequest(ResponseBuilder rb, SearchComponent who, ShardRequest sreq) {
SolrParams params = rb.req.getParams();
if (!params.getBool(COMPONENT_NAME, false) || !params.getBool(ClusteringParams.USE_SEARCH_RESULTS, false)) {
return;
}
sreq.params.remove(COMPONENT_NAME);
if( ( sreq.purpose & ShardRequest.PURPOSE_GET_FIELDS ) != 0 ){
String fl = sreq.params.get(CommonParams.FL,"*");
// if fl=* then we don't need check
if( fl.indexOf( '*' ) >= 0 ) return;
Set<String> fields = getSearchClusteringEngine(rb).getFieldsToLoad(rb.req);
if( fields == null || fields.size() == 0 ) return;
StringBuilder sb = new StringBuilder();
String[] flparams = fl.split( "[,\\s]+" );
Set<String> flParamSet = new HashSet<String>(flparams.length);
for( String flparam : flparams ){
// no need trim() because of split() by \s+
flParamSet.add(flparam);
}
for( String aFieldToLoad : fields ){
if( !flParamSet.contains( aFieldToLoad ) ){
sb.append( ',' ).append( aFieldToLoad );
}
}
if( sb.length() > 0 ){
sreq.params.set( CommonParams.FL, fl + sb.toString() );
}
}
}
开发者ID:pkarmstr,项目名称:NYBC,代码行数:31,代码来源:ClusteringComponent.java
示例16: createInitInstance
import org.apache.solr.handler.component.SearchComponent; //导入依赖的package包/类
public <T extends Object> T createInitInstance(PluginInfo info, Class<T> cast, String msg, String defClassName) {
if(info == null)
return null;
T o = createInstance(info.className == null ? defClassName : info.className, cast, msg);
if(o instanceof PluginInfoInitialized) {
((PluginInfoInitialized) o).init(info);
} else if(o instanceof NamedListInitializedPlugin) {
((NamedListInitializedPlugin) o).init(info.initArgs);
}
if(o instanceof SearchComponent) {
((SearchComponent) o).setName(info.name);
}
return o;
}
开发者ID:netboynb,项目名称:search-core,代码行数:15,代码来源:SolrCore.java
示例17: addIfNotPresent
import org.apache.solr.handler.component.SearchComponent; //导入依赖的package包/类
private <T> void addIfNotPresent(Map<String, T> registry, String name, Class<? extends T> c) {
if(!registry.containsKey(name)) {
T searchComp = resourceLoader.newInstance(c.getName(), c);
if(searchComp instanceof NamedListInitializedPlugin) {
((NamedListInitializedPlugin) searchComp).init(new NamedList<String>());
}
if(searchComp instanceof SearchComponent) {
((SearchComponent) searchComp).setName(name);
}
registry.put(name, searchComp);
if(searchComp instanceof SolrInfoMBean) {
infoRegistry.put(((SolrInfoMBean) searchComp).getName(), (SolrInfoMBean) searchComp);
}
}
}
开发者ID:netboynb,项目名称:search-core,代码行数:16,代码来源:SolrCore.java
示例18: getSearchComponent
import org.apache.solr.handler.component.SearchComponent; //导入依赖的package包/类
/**
* @return a Search Component registered to a given name. Throw an exception if the component is
* undefined
*/
public SearchComponent getSearchComponent(String name) {
SearchComponent component = searchComponents.get(name);
if(component == null) {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Unknown Search Component: " + name);
}
return component;
}
开发者ID:netboynb,项目名称:search-core,代码行数:12,代码来源:SolrCore.java
示例19: modifyRequest
import org.apache.solr.handler.component.SearchComponent; //导入依赖的package包/类
@Override
public void modifyRequest(ResponseBuilder rb, SearchComponent who, ShardRequest sreq) {
// do the filterQParser stuff first
super.modifyRequest(rb, who, sreq);
if (! doMerge(rb)) {
return;
}
ReturnFields rf = rb.rsp.getReturnFields();
if (rf.wantsAllFields()) {
// we already have what we need since we ask for everything...
return;
}
IndexSchema schema = rb.req.getCore().getLatestSchema();
for (SchemaField field : schema.getFields().values()) {
if (! rf.wantsField(field.getName())) {
continue;
}
for (String source : schema.getCopySources(field.getName())) {
if (rf.wantsField(source)) {
continue;
}
sreq.params.add(CommonParams.FL, source);
}
}
}
开发者ID:flaxsearch,项目名称:BioSolr,代码行数:29,代码来源:MergeSearchComponent.java
示例20: handleRequestBody
import org.apache.solr.handler.component.SearchComponent; //导入依赖的package包/类
public void handleRequestBody(SolrQueryRequest req, org.apache.solr.response.SolrQueryResponse rsp) throws Exception, ParseException, InstantiationException, IllegalAccessException {
try {
super.handleRequestBody(req,rsp);
}
catch(Exception e){
// Call the solrToActiveMQComponent directly and pass the exception
SearchComponent solrToActiveMQComponent = new SolrToActiveMQComponent();
List<SearchComponent> singleComponent = Arrays.asList(solrToActiveMQComponent);
rsp.setException(e);
ResponseBuilder rb = new ResponseBuilder(req, rsp, singleComponent);
solrToActiveMQComponent.process(rb);
// Finally throw the exception
throw e;
}
}
开发者ID:dbraga,项目名称:solr2activemq,代码行数:16,代码来源:SolrToActiveMQHandler.java
注:本文中的org.apache.solr.handler.component.SearchComponent类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论