问题
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