我收到错误: - 无法将值'System.Collections.ArrayList'转换为文档类型IKnowWhoKnowsSolrNet的属性'Specialization'
mycode的
//Initialise the solrNet Client.
var solr = ServiceLocator.Current.GetInstance<ISolrOperations<IKnowWhoKnowsSolrNet>>();
//Get the data from the ID.
var results = solr.Query(new SolrQueryByField("id", userName));//Error Place.
//Check the name is empty or not.
if (results.Count != 0)
{
//assign the areaSpecialisation value.
areaSpecialisation = results[0].Specialisation;
}
我在这里收到错误 var results = solr.Query(new SolrQueryByField(“id”,userName));
如果我使用 userName = bhagirathi 检查它的工作正常,但现在将用户名更改为 userName = 123 | bhagirathi | bhagi@abc.com
给出错误。
[编辑]
[SolrUniqueKey("id")]
public string UserName { get; set; }
[SolrField("features")]
public string Specialisation { get; set; }
#endregion
#region Constractor
public IKnowWhoKnowsSolrNet()
{
//
// TODO: Add constructor logic here
//
}
/// <summary>
/// Set the class property's value
/// </summary>
/// <param name="userDetails"></param>
/// <param name="areaSpecialisation"></param>
public IKnowWhoKnowsSolrNet(string userName, string areaSpecialisation)
{
UserName = userName;
Specialisation = areaSpecialisation;
}
#endregion
Id是solr中的字符串。
[/编辑]
请帮助 为什么只需更改搜索查询就会出现此错误?
提前致谢。
答案 0 :(得分:2)
你的solr schema.xml中的features
是多值的吗?如果是这样,Specialisation
IKnowWhoKnowsSolrNet
也需要多值。
[SolrField("features")]
public ICollection<string> Specialisation { get; set; }