我不确定 solrNet 中是否存在错误,或者我做错了什么。因此,在我进入细节之前,首先要了解高级细节。
我在做什么:运行 solr.Query(SearchText) 命令。
错误: “System.Collections.ArrayList”类型的对象无法转换为“System.String”类型。
现在详细...
我可以使用 solr.Net 在 Solr 中非常愉快地创建文档,并且可以使用搜索
“http://localhost:8080/solr/select/?”
SolrQueryByField sq1 = SolrNet.DSL.Query.Field("flutr_EventMarketURI").Is(sfi.flutr_EventMarketURI);
SolrQuery sq2 = SolrNet.DSL.Query.Simple("flutr_EventMarketURI:\""+ sfi.flutr_EventMarketURI + "\"");
SolrQueryByField sq3 = new SolrQueryByField("flutr_EventMarketURI", sfi.flutr_EventMarketURI);
ISolrQueryResults<SolrFlutrItem> results = solr.Query(sq1); //Tried all three and same result
如您所见,我正在尝试三种方法从索引中获取项目。
在 SolrNet 的幕后,它正在向 solr 发出以下请求
2012 年 9 月 19 日下午 1:08:21 org.apache.solr.core.SolrCore 执行信息:[] webapp=/solr path=/select/params={q=flutr_EventMarketURI:"Football/Europe/England/Premier+League /2012/09/22/Swansea+City+-+Everton+FC/"&?=&rows=100000000} hits=1 status=0 QTime=0
这意味着 solr 正在返回数据,但是在执行 solrNet'ty 的过程中,这个错误会冒泡。- IsolrQueryResults 结果 = solr.Query(sq1);
[ArgumentException: Object of type 'System.Collections.ArrayList' cannot be converted to type 'System.String'.]
System.RuntimeType.TryChangeType(Object value, Binder binder, CultureInfo culture, Boolean needsSpecialCast) +4074070
System.RuntimeType.CheckValue(Object value, Binder binder, CultureInfo culture, BindingFlags invokeAttr) +9636530
System.Reflection.MethodBase.CheckArguments(Object[] parameters, Binder binder, BindingFlags invokeAttr, CultureInfo culture, Signature sig) +151
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) +223
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +28
System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture) +101
System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, Object[] index) +25
SolrNet.Impl.DocumentPropertyVisitors.RegularDocumentVisitor.Visit(Object doc, String fieldName, XmlNode field) in c:\prg\SolrNet\svn\SolrNet\Impl\DocumentPropertyVisitors\RegularDocumentVisitor.cs:48
SolrNet.Impl.DocumentPropertyVisitors.AggregateDocumentVisitor.Visit(Object doc, String fieldName, XmlNode field) in c:\prg\SolrNet\svn\SolrNet\Impl\DocumentPropertyVisitors\AggregateDocumentVisitor.cs:37
SolrNet.Impl.DocumentPropertyVisitors.DefaultDocumentVisitor.Visit(Object doc, String fieldName, XmlNode field) in c:\prg\SolrNet\svn\SolrNet\Impl\DocumentPropertyVisitors\DefaultDocumentVisitor.cs:39
SolrNet.Impl.SolrDocumentResponseParser`1.ParseDocument(XmlNode node, ICollection`1 fields) in c:\prg\SolrNet\svn\SolrNet\Impl\SolrDocumentResponseParser.cs:65
SolrNet.Impl.SolrDocumentResponseParser`1.ParseResults(XmlNode parentNode) in c:\prg\SolrNet\svn\SolrNet\Impl\SolrDocumentResponseParser.cs:50
SolrNet.Impl.ResponseParsers.ResultsResponseParser`1.Parse(XmlDocument xml, SolrQueryResults`1 results) in c:\prg\SolrNet\svn\SolrNet\Impl\ResponseParsers\ResultsResponseParser.cs:41
SolrNet.Impl.SolrQueryResultParser`1.Parse(String r) in c:\prg\SolrNet\svn\SolrNet\Impl\SolrQueryResultParser.cs:46
SolrNet.Impl.SolrQueryExecuter`1.Execute(ISolrQuery q, QueryOptions options) in c:\prg\SolrNet\svn\SolrNet\Impl\SolrQueryExecuter.cs:309
SolrNet.Impl.SolrBasicServer`1.Query(ISolrQuery query, QueryOptions options) in c:\prg\SolrNet\svn\SolrNet\Impl\SolrBasicServer.cs:83
SolrNet.Impl.SolrServer`1.Query(ISolrQuery query, QueryOptions options) in c:\prg\SolrNet\svn\SolrNet\Impl\SolrServer.cs:50
SolrNet.Impl.SolrServer`1.Query(ISolrQuery q) in c:\prg\SolrNet\svn\SolrNet\Impl\SolrServer.cs:87
flutrClassLibrary.TSGCsolrHelper.GetFlutrItemViaURI(String solrURL, SolrFlutrItem sfi) in D:\Dropbox\aspDevelopment\flutrBetService\flutrClassLibrary\TSGCsolrHelper.cs:89
ReIndex.btnSendToSolr_Click(Object sender, EventArgs e) in d:\Dropbox\aspDevelopment\flutrBetService\flutrOddsAdmin\ReIndex.aspx.cs:97
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +118
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +112
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563
作为参考,这是 solr 返回的内容
"http://localhost:8080/solr/select/?q=flutr_EventMarketURI:%22Football/Europe/England/Premier+League/2012/09/22/Swansea+City+-+Everton+FC/%22&?=&rows= 100000000"
<?xml version="1.0" encoding="UTF-8"?>
<response>
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">0</int>
<lst name="params">
<str name="q">flutr_EventMarketURI:"Football/Europe/England/Premier League/2012/09/22/Swansea City - Everton FC/"</str>
<str name="?"/>
<str name="rows">100000000</str>
</lst>
</lst>
<result name="response" numFound="1" start="0">
<doc>
<str name="EventCategory">Football/Europe/England/Premier League</str>
<date name="EventDate">2012-09-22T11:45:00Z</date>
<date name="EventLastUpdated">2012-09-19T10:49:31Z</date>
<str name="EventName">Swansea City - Everton FC</str>
<str name="ResultsJSON">
{
"Category_name": "Football/Europe/England/Premier League",
"Event_name": "Everton FC - Southampton FC",
"Event_date": "2012-09-29T14:00:00",
"uri_event": "Football/Europe/England/Premier League/2012/09/29/Everton FC - Southampton FC/",
"Markets": [
{
"Market_name": "Match betting",
"Outcomes": [
{
"Outcome_name": "Everton FC",
"Odds": [
{
"Odds_decimal": "1.45",
"Last_updated_date": "2012-09-19T09:49:13.9144052Z",
"uri_odd": "Football/Europe/England/Premier League/2012/09/29/Everton FC - Southampton FC/Match betting/1/odd/bwin/"
}
],
"uri_outcome": "Football/Europe/England/Premier League/2012/09/29/Everton FC - Southampton FC/Match betting/1/"
},
{
"Outcome_name": "Southampton FC",
"Odds": [
{
"Odds_decimal": "6.45",
"Last_updated_date": "2012-09-19T09:49:13.9144052Z",
"uri_odd": "Football/Europe/England/Premier League/2012/09/29/Everton FC - Southampton FC/Match betting/1/odd/bwin/"
}
],
"uri_outcome": "Football/Europe/England/Premier League/2012/09/29/Everton FC - Southampton FC/Match betting/1/"
},
{
"Outcome_name": "Draw",
"Odds": [
{
"Odds_decimal": "4",
"Last_updated_date": "2012-09-19T09:49:13.9144052Z",
"uri_odd": "Football/Europe/England/Premier League/2012/09/29/Everton FC - Southampton FC/Match betting/X/odd/bwin/"
}
],
"uri_outcome": "Football/Europe/England/Premier League/2012/09/29/Everton FC - Southampton FC/Match betting/X/"
}
],
"uri_market": "Football/Europe/England/Premier League/2012/09/29/Everton FC - Southampton FC/Match betting/"
}
]
}
</str>
<str name="flutr_EventMarketURI">Football/Europe/England/Premier League/2012/09/22/Swansea City - Everton FC/</str>
<str name="flutr_ResultType">EVENT</str>
<arr name="text">
<str>Football/Europe/England/Premier League/2012/09/22/Swansea City - Everton FC/</str>
<str>Football/Europe/England/Premier League</str>
<str>Swansea City - Everton FC</str>
<str>Football/Europe/England/Premier League22/09/2012 11:45:00Swansea City - Everton FC1 , X , 2 , Match betting , Football/Europe/England/Premier League/2012/09/22/Swansea City - Everton FC/Match betting/ , </str>
</arr>
</doc>
</result>
</response>
这是我的课
public class SolrFlutrItem : ICloneable
{
public SolrFlutrItem() { }
[SolrUniqueKey("flutr_EventMarketURI")]
public string flutr_EventMarketURI { get; set; }
[SolrField("flutr_ResultType")]
public string flutr_ResultType { get; set; }
[SolrField("EventCategory")]
public string EventCategory { get; set; }
[SolrField("EventDate")]
public DateTime EventDate { get; set; }
[SolrField("EventLastUpdated")]
public DateTime EventLastUpdated { get; set; }
[SolrField("EventName")]
public string EventName { get; set; }
[SolrField("MarketName")]
public string MarketName { get; set; }
[SolrField("OutcomeName")]
public string OutcomeName { get; set; }
[SolrField("ResultsJSON")]
public string ResultsJSON { get; set; }
[SolrField("InternalJSON")]
public string InternalJSON { get; set; }
[SolrField("text")]
public string text { get; set; }
public object Clone()
{
return this.MemberwiseClone();
}
}
有任何想法吗?
非常感谢帮助。
谢谢