rjvdboon
rjvdboon

Reputation: 60

SolrNet: How to use a custom searchcomponent (and its result) from solrnet

On a project I'm working on we interact with Solr using SolrNet. We have a custom search component in solr, activated by adding join=true to the query. (I do this in solrnet through the ExtraParams of the CommonQueryOptions). In the response there is a custom <lst name="joinresult"> after the normal results which I want to parse, and return to the caller.

Now I don't know where I can cleanly insert a custom ResponseParser in the SolrNet pipeline.

What have I done so far:

The next step was to plug all these classes in the right places, and use SolrQueryExecuter<T>.Execute to do the rest of the heavy lifting. But this will always return a SolrQueryResult, not my custom result.

Does anybody have any idea what I need to to support my scenario?

EDIT:
What I've got so far is the following:

This works, but it doesn't really feel 'right'. My Execute method is a copy of the normal Execute method with only one essential change: I replaced new SolrQueryResults with new JoinQueryResults.

Reading the SolrNet code I couldn't find any other 'easy' way, so I'm keeping this approach for now.

Upvotes: 1

Views: 643

Answers (1)

Paige Cook
Paige Cook

Reputation: 22555

I am not sure if the SolrNet library supports inserting custom response parsers without modifying the source.

However, I would recommend checking out the source for SolrNet on GitHub and look at how the Faceting or Highlighting results are being parsed out of the SolrQueryResponse. Based on one of these examples you should be able to modify the source to handle the JoinQueryResults you have created. Then ideally, you could contribute this back to the project so that others may benefit as well.

Upvotes: 1

Related Questions