How can I perform solrnet query in two different request handler?

413 views
Skip to first unread message

ankita patel

unread,
Apr 3, 2015, 3:07:52 AM4/3/15
to sol...@googlegroups.com
Hello,

I am using SolrNet to perform Solr queries with my application. 

Now, I am having two different request handler one is default /select and another /search for two different web pages. I have already perform a query in Extraparams  with qt parameter for "search"  handler. But it selects "/select" handler. Here is a query:

webapp=/solr path=/select params={mm=75%25&spellcheck=true&facet=true&facet.mincount=1&spellcheck.q=books&qf=Name^9++ShortDescription^1++FullDescription^1+CategoryCopy^1+ManufacturerCopy^1+Sku^1+ChildSku^1+nGramContent+CustomProperties&spellcheck.collate=true&version=2.2&rows=6&defType=edismax&bq=&start=0&q=(books)&facet.field=Category&facet.field=Manufacturer&facet.field=Vendor&facet.field=f_CPU%2BType&facet.field=f_Memory&facet.field=pa_Software&facet.field=pa_HDD&qt=search&fq=Price:[0+TO+9999999999999]} hits=15 status=0 QTime=31 

But I want result as per following query which I have performed directly in Solr:
webapp=/solr path=/mysearch params={indent=true&wt=json&q=Id:10%0a} hits=1 status=0 QTime=0 

How can I achieve this using Solrnet?

I am connecting Solr instance with my application using WindsorContainer. Because I have to perform Solroperations. Here is my code for solr connection:
    var container = new WindsorContainer();
            var solrFacility = new SolrNetFacility(solrUrl);
            string coreName =coreId;
            solrFacility.AddCore(coreName, typeof(SolrCustomProduct), solrUrl);
            container.AddFacility("solr", solrFacility);
          
            return container.Resolve<ISolrOperations<SolrCustomProduct>>(coreName);

Any help is appreciated!

fatmuis fatimus

unread,
Apr 14, 2015, 5:45:50 AM4/14/15
to sol...@googlegroups.com
Hi,

I have the same problem, but no answer yet.

regards

Mauricio Scheffer

unread,
Apr 14, 2015, 6:21:24 AM4/14/15
to sol...@googlegroups.com
There are many references to this on this google group. See for example https://groups.google.com/d/msg/solrnet/Kqxn68pU0uo/uG50WSxu_swJ .

Cheers,
Mauricio


--
Mauricio

--
You received this message because you are subscribed to the Google Groups "SolrNet" group.
To unsubscribe from this group and stop receiving emails from it, send an email to solrnet+u...@googlegroups.com.
To post to this group, send email to sol...@googlegroups.com.
Visit this group at http://groups.google.com/group/solrnet.
For more options, visit https://groups.google.com/d/optout.

fatmuis fatimus

unread,
Apr 14, 2015, 6:58:25 AM4/14/15
to sol...@googlegroups.com
Got it, thank you!

fatmuis fatimus

unread,
Apr 14, 2015, 9:21:01 AM4/14/15
to sol...@googlegroups.com
Ankita, I ended up using this. Hope it helps:

            SolrQueryExecuter<T> sqe = container.Resolve<ISolrQueryExecuter<T>() as SolrQueryExecuter<T>;
            sqe.Handler = "/mysearch ";


ankita patel

unread,
Apr 14, 2015, 10:18:53 AM4/14/15
to sol...@googlegroups.com

Yeah, but I also wanted to use other queries and for that I need to use ISolrQueryOperations instead ISolrQueryExecuter

ankita patel

unread,
Apr 16, 2015, 1:40:51 AM4/16/15
to sol...@googlegroups.com


On Tuesday, April 14, 2015 at 7:48:53 PM UTC+5:30, ankita patel wrote:

Yeah, but I also wanted to use other queries and for that I need to use ISolrQueryOperations instead ISolrQueryExecuter. I am performing following query to achieve my result:

private static ISolrOperations<SolrCustomProduct> solrCustomWorker; 
SolrQueryResults<Product> results = solrCustomWorker.Query(new SolrQuery(query), options); 
Moreover, I have already mentioned in my question how I am conneting Solr with my application. If I am connecting solr using ISolrQueryExecutor then I am unable to perform above query.
On 14-Apr-2015 6:51 pm, "fatmuis fatimus" <terrib...@gmail.com> wrote:
Ankita, I ended up using this. Hope it helps:

            SolrQueryExecuter<T> sqe = container.Resolve<ISolrQueryExecuter<T>() as SolrQueryExecuter<T>;
            sqe.Handler = "/mysearch ";


--
You received this message because you are subscribed to the Google Groups "SolrNet" group.
To unsubscribe from this group and stop receiving emails from it, send an email to solrnet+unsubscribe@googlegroups.com.

Mauricio Scheffer

unread,
Apr 16, 2015, 4:39:43 AM4/16/15
to sol...@googlegroups.com
In that case I recommend creating a separate instance of ISolrOperations for your purpose.


--
Mauricio

ankita patel

unread,
Apr 16, 2015, 5:20:00 AM4/16/15
to sol...@googlegroups.com
Thank you for your quick response. So, you mean first I have to create a solr bridge using ISolrQueryExecuter. Then I perform solr operations using ISolrOperation object. This is what you suggest?

Mauricio Scheffer

unread,
Apr 20, 2015, 7:33:15 PM4/20/15
to sol...@googlegroups.com
Not sure what you mean with a "solr bridge"... what I mean is one instance of ISolrOperations for each handler you need.

ankita patel

unread,
May 4, 2015, 7:18:42 AM5/4/15
to sol...@googlegroups.com
Solr bridge means connection between my application and Solr using SolrNet. Can you please suggest me how can I create instance of ISolrOperations for a specific handler?

Mauricio Scheffer

unread,
May 4, 2015, 7:48:32 AM5/4/15
to sol...@googlegroups.com
Here's some sample code to get you started: https://gist.github.com/mausch/5719418


--
Mauricio

ankita patel

unread,
May 6, 2015, 6:38:40 AM5/6/15
to sol...@googlegroups.com
The link you suggested me is for multicoremapping. My problem is not that. I am having one Solr Core. I just wanted to query in different handler from different pages from my web application.

Thank You.

Mauricio Scheffer

unread,
May 7, 2015, 7:40:03 AM5/7/15
to sol...@googlegroups.com
That code is intended to show how to compose an instance of ISolrOperations<T> without any IoC container. It can be used as reference for multi-core access or different-handler requests. Simply change whatever you need to change for your scenario (in this case the call to create the SolrQueryExecuter).


--
Mauricio
Reply all
Reply to author
Forward
0 new messages