简体   繁体   中英

Why does SOLRJ fail with undefined field error

I'm using SOLRJ library.

query.setQuery("content_raw:born");
query.setParam("df", "content");
query.setParam("hl", "true");
QueryResponse solrResponse = server.query(query);

And I get undefined field content_raw error.

But when I hit the URL that get's generated (I got it from the logs) in a browser, it works.

http://localhost:8983/solr/testCollection/select?
q=content_raw%3Aborn
&df=content
&hl=true

Any Idea on why this strange behaviour.

My 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" />

It might be the problem that your solrserver url used in creating server instance might be wrong as it uses collection1 by default. You have to specify solr-core in server as testCollection . After that it will work fine for sure.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM