New Contributor
Posts: 5
Registered: ‎08-08-2018
Accepted Solution

Solr - java.lang.NullPointerException : createMainQuery

I am using CDH 15.5, which comes with Solr 4.10


I ran into issues indexing a csv document, in the schema config i had specified a uniqueKey value, for some reason it kept giving me a "org.apache.solr.common.SolrException: Document contains multiple values for uniqueKey field: id" -- I've asked about this in a separate thread.

So i removed the uniqueKey constraint in the configurations, then i ran into another error -- "QueryElevationComponent requires the schema to have a uniqueKeyField" , this means uniqueKey definition is enforced in the solrconfig.xml file. I subsequently disabled this from the Solrconfig.xml, and was able to successfully index the file.


However when i try to query from the Solr admin using the Select handler, i get an exception below.

A quick glance through the stacktrace shows that the null exception is returned in the createMainQuery method.


String keyFieldName = rb.req.getSchema().getUniqueKeyField().getName();


In the method definition of CreateMainQuery, there's an attemp to assign a certain variable the uniqueKeyField, which if not enabled means its null, hence the null exception.






	at org.apache.solr.handler.component.QueryComponent.createMainQuery(
	at org.apache.solr.handler.component.QueryComponent.regularDistributedProcess(
	at org.apache.solr.handler.component.QueryComponent.distributedProcess(
	at org.apache.solr.handler.component.SearchHandler.handleRequestBody(
	at org.apache.solr.handler.RequestHandlerBase.handleRequest(
	at org.apache.solr.core.SolrCore.execute(
	at org.apache.solr.servlet.SolrDispatchFilter.execute(
	at org.apache.solr.servlet.SolrDispatchFilter.httpSolrCall(
	at org.apache.solr.servlet.SolrDispatchFilter.doFilter(
	at org.apache.solr.servlet.SolrDispatchFilter.doFilter(
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(
	at org.apache.solr.servlet.SolrHadoopAuthenticationFilter$2.doFilter(
	at org.apache.solr.servlet.SolrHadoopAuthenticationFilter.doFilter(
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(
	at org.apache.catalina.core.StandardWrapperValve.invoke(
	at org.apache.catalina.core.StandardContextValve.invoke(
	at org.apache.catalina.core.StandardHostValve.invoke(
	at org.apache.catalina.valves.ErrorReportValve.invoke(
	at org.apache.catalina.core.StandardEngineValve.invoke(
	at org.apache.catalina.connector.CoyoteAdapter.service(
	at org.apache.coyote.http11.Http11Processor.process(
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(

Can anyone confirm they've ran into this issue with CDH 15.5






New Contributor
Posts: 5
Registered: ‎08-08-2018

Re: Solr - java.lang.NullPointerException : createMainQuery

curl -v "http://localhost:8983/solr/collection3/update/csv?header=true&stream.file=/home/data1/books.csv&stream.contentType=text/csv;charset=utf-8"


Successfuly indexes, with no uniqueID specified in the schema.xml, but on querying a null exception is returned


When i added the uniqueKey back in the schema.xml and re-enabled the QueryElevationComponent and then re-indexed, i was able to query with no issues.


So i've come to a conculusion that a uniqueKey is a requirement in the schema.xml definition