我正在使用 SOLRJ 库。
query.setQuery("content_raw:born");
query.setParam("df", "content");
query.setParam("hl", "true");
QueryResponse solrResponse = server.query(query);
我收到未定义字段 content_raw
错误。
但是当我在浏览器中点击生成的 URL(我从日志中获取它)时,它就起作用了。
http://localhost:8983/solr/testCollection/select?
q=content_raw%3Aborn
&df=content
&hl=true
关于为什么会出现这种奇怪行为的任何想法。
我的 schema.xml
<field name="content" type="text_general" indexed="false" stored="true"
multiValued="true" />
<field name="content_raw" type="text_general" indexed="true" stored="false"
multiValued="true" />
<copyField source="content" dest="content_raw" />
最佳答案
这可能是您在创建服务器实例时使用的 solrserver url 可能错误的问题,因为它默认使用 collection1。您必须在服务器中将 solr-core 指定为 testCollection
。
之后它肯定会正常工作。
关于java - 为什么 SOLRJ 会因未定义字段错误而失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28362232/