How we changes standard query handler

笑着哭i 提交于 2019-12-13 01:31:42

问题


I am using solrnet I have created a new handler and want to change standard query handler "select" to "new" without using any extra parameter like "qt" or defType.

Currently "http://localhost:8080/solr/select?q=:"

Want "http://localhost:8080/solr/new?q=:"

Please advise me this is possible or not?


回答1:


The post Changing Handler Endpoint in SolrQueryExecutor in the SolrNet Google Groups states that in order to do this you will need to modify the SolrQueryExecutor as described:

Question: On our Solr instance we have changed the search endpoint from "/ select" to "/search". I see in SolrQueryExecuter that there is a Handler property that just returns the DefaultHandler of "/select". Is there any way to change this to use my endpoint?

Answer: That's correct, you need to change that property in SolrQueryExecuter. How you do that depends on your IoC container. For example, with the built-in container you'd Remove() ISolrQueryExecuter and add your own with the changed handler property. This is a quite rare thing to do, usually I just set up different request handlers not as endpoints but as regular names, then you can use the qt parameter to select one.




回答2:


If all you want is to invoke a different request handler, you can just get an instance of ISolrQueryExecuter and set the Handler accordingly. No need to replace the built-in SolrQueryExecuter with a concrete decorator.

Startup.Init<T>(new SolrConnection("http://localhost:8080/solr")),

var executor = ServiceLocator.Current.GetInstance<ISolrQueryExecuter<T>>() as SolrQueryExecuter<T>;
executor.Handler = "/new";

BTW, your url seems to be missing the name of the collection.



来源:https://stackoverflow.com/questions/13393700/how-we-changes-standard-query-handler

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!