开发者

How do I properly do a dismax query using solrnet

I know I need to add the following code to change to dismax.

ExtraParams = new Dictionary<string, string> { {"qt", "dismax"} }

But how do I pass the "qf" values? I tried this with no avail:

new Dictionary<string, string> { {"qt", "dismax"},{"qf","field1 field2"} }

and

var matchingItems = solr.Query(new LocalParams {{"type", "dismax"},{"qf","field1 field2"}} 
+ BuildQuery(parameters) ...

Even passing only the ExtraParams I get a 404 bad request.

This is the logged queries

Local parameters + extraparams

GETting 'q={!type=dismax qf='field1 field2'}query text, start=0, rows=10,
spellcheck=开发者_Go百科true, facet=true, facet.field=especialidadefacet,
f.especialidadefacet.facet.mincount=1, facet.field=tipofacet,
f.tipofacet.facet.mincount=1, facet.field=estadofacet, f.estadofacet.facet.mincount=1,
qt=dismax' from '/select'

only extra params

GETting 'q=query text, start=0, rows=10, spellcheck=true, facet=true,
facet.field=especialidadefacet, f.especialidadefacet.facet.mincount=1,
facet.field=tipofacet, f.tipofacet.facet.mincount=1, facet.field=estadofacet,
f.estadofacet.facet.mincount=1, qt=dismax' from '/select'


The qt parameter selects a request handler. So if you don't have a request handler named 'dismax' and you define qt=dismax you'll get a 404.

So either define qt=dismax and a 'dismax' request handler, or alternatively, just use the dismax query parser via LocalParams.


(Very late reply but worth for anyone landing here)

Try using local params, it would be something like:

solr.Query(new LocalParams {{"type", "dismax"},{"qf", "myfield"}} + new SolrQuery("solr rocks"));

Look at the LocalParams section in: https://github.com/mausch/SolrNet/blob/master/Documentation/Querying.md

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜