问题
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