SORLJ undefined field null
I am trying to make simple readings over Lucene indexes by using SolrJ. I have been able to access the sample index available in the SolrJ download, but I get an exception when trying to make the reading.
04-feb-2010 17:05:05 org.apache.solr.common.SolrException log
GRAVE: org.apache.solr.common.SolrException: undefined field null
My index only has one document with a single field, called “nombre”
I have specified this in the schema.xml and the route in the slconfig.xml
Java code
System.setProperty( "solr.solr.home", "C:\\solr" );
// CREATING THE SERVER
CoreContainer.Initializer initializer = new CoreContainer.Initializer();
CoreContainer coreContainer = null;
SolrServer embServer = null;
coreContainer = initializer.initialize();
embServer = new EmbeddedSolrServer(coreContainer, "");
// READING
SolrQuery query = new SolrQuery();
String q = "*";
query.setQuery(q);
QueryResponse rsp = null;
/// HERE I GET THE EXCEPTION ///
rsp = embServer.query( query );
/// HERE I GET THE EXCEPTION ///
// GETTING THE NUMBER OF ITEMS
SolrDocumentList docs = rsp.getResults();
System.out.println( docs.size() );
Any ideas? Can you give me a solution? Is it a common mistake? Thank you very much in advance.
If I try this with the Jetty admin console I get : (url: "http://localhost:8983/solr/select/?q=*")
HTTP ERROR: 400
undefined field null
RequestURI=/solr/select/
The shema.xml is this one:
(Remember my index only has one document with a single field, called “nombre” )
<?xml version="1.0" encoding="UTF-8" ?>
<schema name="example" version="1.2">
<types>
<fieldType name="string" class="solr.StrField"/>
</types>
<fields>
<field name="nombre" type="string" indexed="true" stored="true"/>
</fields>
</schema>
The solrconfig.xml is this one:
<?xml version="1.0" encoding="UTF-8" ?>
<config>
<requestHandler name="standard" class="solr.StandardRequestHandler" />
<dataDir>${solr.data.dir:./data/clientes}</dataDir>
</config>
The exception I am getting is:
05-feb-2010 10:07:11 org.apache.solr.common.SolrException log GRAVE: org.apache.solr.common.SolrException: undefined field null at org.apache.solr.schema.IndexSchema.getDynamicFieldType(IndexSchema.java:1136) at org.apache.solr.schema.IndexSchema.getFieldType(IndexSchema.java:1098) at org.apache.solr.search.SolrQueryParser.getWildcardQuery(SolrQueryParser.java:193) at org.apache.lucene.queryParser.QueryParser.Term(QueryParser.java:1434) at org.apache.lucene.queryParser.QueryParser.Clause(QueryParser.java:1337) at org.apache.lucene.queryParser.QueryParser.Query(QueryParser.java:1265) at org.apache.lucene.queryParser.QueryParser.TopLevelQuery(QueryParser.java:1254) at org.apache.lucene.queryParser.QueryParser.parse(QueryParser.java:200) at org.apache.solr.search.LuceneQParser.parse(LuceneQParserPlugin.java:78) at org.apache.solr.search.QParser.getQuery(QParser.java:131) at org.apache.solr.handler.co开发者_Python百科mponent.QueryComponent.prepare(QueryComponent.java:89) at org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:174) at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:131) at org.apache.solr.core.SolrCore.execute(SolrCore.java:1316) at org.apache.solr.client.solrj.embedded.EmbeddedSolrServer.request(EmbeddedSolrServer.java:139) at org.apache.solr.client.solrj.request.QueryRequest.process(QueryRequest.java:89) at org.apache.solr.client.solrj.SolrServer.query(SolrServer.java:118) at paqueteBase.PruebaDeSolr.ejecutate(PruebaDeSolr.java:67) at paqueteBase.PruebaDeSolr.main(PruebaDeSolr.java:24)
Ok, it seems I needed to specify the field "nombre" as uniqueKey and defaultSearchField in the schema.xml. It is starting to work.
In your q parameter there's a wrong query string, should be *:* and not only *. You are getting that exception because SOLR is trying to resolve the name of the target field, first trying with declared field and then looking for a dynamic field definition.
精彩评论