Solr.Net 查询:Windows 窗体中的 ArgumentException



所以我有一个Windows窗体项目启动并运行。它使用 Lucene.Net 库,我用它做了一个Lucene索引。该程序接受用户请求,通过一些算法运行它们,并在 DataGridView 中显示结果集。

之后,我安装了XAMPP,使用Tomcat服务来设置Solr 3.6.1。我配置了架构.xml如下所示(感谢 Solr 可以加载原始 Lucene 索引吗?

<fieldType name="tdouble" class="solr.TrieDoubleField" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
[...]
<field name="LuminaireId" type="string" indexed="true" stored="true"/>
<field name="LampCount" type="tdouble" multiValued="true" indexed="true" stored="true" required="false"/>
[...]

我搜索了一些有关如何设置所有内容的示例,并提出了一个用于映射值的产品类(还有更多值,但我认为这对于获得图片就足够了),如下所示:

public class SolrProduct
{
      [SolrUniqueKey("LuminaireId")]
      public string LuminaireId { get; set; }
      [SolrField("LampCount")]
      public ICollection<double> LampCount { get; set; }
}

一个简单的测试查询(使用此方法)

internal override List<KeyValuePair<Int64, Double>> CalculateRanking(List<T> checkedAttributes)
{
    Startup.Init<SolrProduct>("http://localhost:8983/solr/");
    var solr = ServiceLocator.Current.GetInstance<ISolrOperations<SolrProduct>>();
    var results = solr.Query("LampCount:1");
    // as is: no mapping for result-return for now, returning "null" instead
    return(null);
}

生成一个 ArgumentException,告诉我类型为"System.Collections.ArrayList"的对象不能转换为类型"System.String"。即使在互联网上搜索该问题并调试程序后,我仍然不了解异常。"LampCount"是一个多值字段(Lucene索引中的前NumericField),在产品中具有模式.xml和映射.cs它应该可以工作。

它在localhost:8983/solr/admin/上使用Web界面时有效,我可以将查询拍摄为"LampCount:1",它返回一堆正确找到的文档。这可能是另一个问题,但是在所有"按原样设置"的情况下,Solr Web界面的结果集XML显示(在每个找到的文档中):

<arr name="LampCount">
<str>ERROR:SCHEMA-INDEX-MISMATCH,stringValue=1</str>
</arr>

我为 Lucene 索引文档的 LampCount 字段编制了索引

 var valueField = new NumericField(internalname, Field.Store.YES, true);
 valueField.SetDoubleValue(value);
 doc.Add(valueField);

这能成为问题吗,因为我目前看不到大局,感到完全迷茫。如果你能解开我的脑结,非常感谢。;-)

提前感谢!

您的架构与 POCO 不匹配。基本上,Solr正在尝试将该"tdouble"字段类型转换为您的集合。你能做的最好的事情是执行,在管理控制面板和观察返回的内容中执行查询,然后问问自己你认为它将如何处理输入回你的 POCO。

相关内容

  • 没有找到相关文章

最新更新