Reputation: 56
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?
Upvotes: 1
Views: 1552
Reputation: 11
use the latest version of SolrNet (I used it with .net 4.6). Define a new RequestHandlerParameters in your QueryOptions like following:
using CommonServiceLocator;
using SolrNet;
using SolrNet.Commands.Parameters;
Startup.Init<MwDoc>("http://localhost:8983/solr/mycore");
var solr = ServiceLocator.Current.GetInstance<ISolrOperations<MyClass>>();
QueryOptions options = new QueryOptions()
{
RequestHandler = new RequestHandlerParameters("/new"),
// define your other Options here
};
solr.Query("keyword to search", options);
Upvotes: 1
Reputation: 1823
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.
Upvotes: 1
Reputation: 22555
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.
Upvotes: 4