tamaramata / solrnet

Automatically exported from code.google.com/p/solrnet
0 stars 0 forks source link

ExtraPram Option #162

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
Hi I want to add following dismax as ExtraParams

defType=dismax

qf=features^20.0+text^0.3

I can add those as ExtraParam but when I try to execute the query its throwing 
exception and I found its for encoding + and ^ this two character. 

Can you please advise me how can i pass qf param as extra instead of boost() by 
field.

Original issue reported on code.google.com by ami...@justparts.com on 30 Sep 2011 at 3:24

GoogleCodeExporter commented 8 years ago
Please post the full exception stack trace.

Original comment by mauricio...@gmail.com on 5 Oct 2011 at 1:25

GoogleCodeExporter commented 8 years ago
Are you still there?

Original comment by mauricio...@gmail.com on 4 Nov 2011 at 10:30

GoogleCodeExporter commented 8 years ago
HI,
  I also found this problem.Solr does not accept 'qt=features^20.0+text^0.3' in fact.But it can  accept 'qt=features^20.0&qt=text^0.3'.So I would like to add the query parameters like following:
  ExtraParams = new Dictionary<string, string>()
  {
     {"defType","dismax"},    
     {"qf","features^20.0"},
     {"qf","text^0.3"},
     {"mm","2"}
  }    

But ExtraParams is Dictionary<string,string> and "qt" is a duplicate key.I 
think if ExtraParams is ICollection<KeyValuePair<string, string>> the problem 
can be resolved.

Original comment by Thomas.L...@grapecity.com on 2 Dec 2011 at 2:17

GoogleCodeExporter commented 8 years ago
ExtraParams is not a dictionary, please see 
https://github.com/mausch/SolrNet/blob/8a7a58edd409ca9b7a9d9f39db42f7d783f11f6a/
SolrNet/Commands/Parameters/QueryOptions.cs#L109

Please post the stack trace or a failing test that reproduces this.

Original comment by mauricio...@gmail.com on 2 Dec 2011 at 2:28

GoogleCodeExporter commented 8 years ago
Hi,
  Thanks for you help!
  I did ignore it's definition.I just saw the example in wiki.The example in wiki like following:
  ISolrOperations<Product> solr = ...
  var products = solr.Query(SolrQuery.All, new QueryOptions {
        ExtraParams = new Dictionary<string, string> {
                {"qt", "dismax"}
        }
 });
 So I used Dictionary<string,string> and then I got an error message.

Original comment by Thomas.L...@grapecity.com on 2 Dec 2011 at 2:50

GoogleCodeExporter commented 8 years ago
@Thomas.Liu please post the stack trace for the exception you get when defining 
qf.

Original comment by mauricio...@gmail.com on 2 Dec 2011 at 2:56

GoogleCodeExporter commented 8 years ago
I think this is not a defect because Solr does not support that expression.If 
you want to search terms or phrases in multiple fields you should split that 
into multiple sub expressions.For example 'qt=features^20.0+text^0.3' should be 
split into 'qt=features^20.0' and 'qt=text^0.3'.'pf' is same.

Original comment by Thomas.L...@grapecity.com on 2 Dec 2011 at 3:00

GoogleCodeExporter commented 8 years ago
   at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
   at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
   at SolrDemo.Demo3.CommonQuery(String queryString) in E:\Practise\SolrDemo\SolrDemo\Demo3.aspx.cs:line 101
   at SolrDemo.Demo3.Button1_Click(Object sender, EventArgs e) in E:\Practise\SolrDemo\SolrDemo\Demo3.aspx.cs:line 89
   at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
   at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
   at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
   at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
   at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Original comment by Thomas.L...@grapecity.com on 2 Dec 2011 at 3:05

GoogleCodeExporter commented 8 years ago
Solr *does* support multiple fields with boost in single 'qf' parameter just 
fine. BTW I'm assuming you mean 'qf' and not 'qt' which is a very different 
parameter. 
I suspect you are url-encoding the parameter yourselves, which you shouldn't 
 do. But I really need a failing test or at least a stack trace to confirm, otherwise I can only guess...

Original comment by mauricio...@gmail.com on 2 Dec 2011 at 3:11

GoogleCodeExporter commented 8 years ago
@Thomas.Liu I need the Solr stack trace when you issue a qf with multiple 
fields, not the SolrNet stack trace when you have a dictionary with multiple 
keys.

Original comment by mauricio...@gmail.com on 2 Dec 2011 at 3:12

GoogleCodeExporter commented 8 years ago
Oh,I made a mistake.Solr does support multiple fields.I have found out the 
reason.I used 'qt=features^20.0,text^0.3' to query instead of 
'qt=features^20.0+text^0.3'.So I get the error message as following:
HTTP Status 500 - For input string: "100,TocText_zh" 
java.lang.NumberFormatException: For input string: "100,TocText_zh" at 
sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1241) at 
java.lang.Float.valueOf(Float.java:417) at 
org.apache.solr.util.SolrPluginUtils.parseFieldBoosts(SolrPluginUtils.java:590) 
at org.apache.solr.search.DisMaxQParser.addMainQuery(DisMaxQParser.java:138) at 
org.apache.solr.search.DisMaxQParser.parse(DisMaxQParser.java:78) at 
org.apache.solr.search.QParser.getQuery(QParser.java:142) at 
org.apache.solr.handler.component.QueryComponent.prepare(QueryComponent.java:81)
 at 
org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.
java:173) at 
org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java
:129) at org.apache.solr.core.SolrCore.execute(SolrCore.java:1368) at 
org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:356) 
at 
org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:252)
 at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilt
erChain.java:243) at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.
java:210) at 
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:2
24) at 
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:1
69) at 
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.jav
a:472) at 
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168) 
at 
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) 
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929) at 
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118
) at 
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405) at 
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor
.java:964) at 
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractPro
tocol.java:515) at 
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
 at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) 
at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) 
at java.lang.Thread.run(Thread.java:722)

That's my mistake. You can omit it.

Original comment by Thomas.L...@grapecity.com on 2 Dec 2011 at 4:01

GoogleCodeExporter commented 8 years ago
@Thomas.Liu can you confirm that an ExtraParams with Dictionary<string,string> 
{{"qf", "features^20 text^0.3"}} (note SPACE and not '+' or ',') works 
correctly so I can close this issue? Thanks...

Original comment by mauricio...@gmail.com on 2 Dec 2011 at 4:14

GoogleCodeExporter commented 8 years ago
I have confirmed that.It's OK!

Original comment by Thomas.L...@grapecity.com on 2 Dec 2011 at 4:20

GoogleCodeExporter commented 8 years ago
Great, thanks!!

Original comment by mauricio...@gmail.com on 2 Dec 2011 at 4:24