How do I properly do a dismax query using solrnet

十年热恋 提交于 2020-03-03 12:33:29

问题


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=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'

回答1:


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.




回答2:


(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



来源:https://stackoverflow.com/questions/6065357/how-do-i-properly-do-a-dismax-query-using-solrnet

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!