2015-11-30 74 views
1

以下是我的Solr 4.7.2使用或者與連接查詢結果導致NullPointerException異常

brands {id, brand_name} 
products {id, product_name, brand_id} 

以下配置的樣本文件和字段的數據索引

BRANDS: {1, Apple}, {2, Samsung}, {3, HTC} 

PRODUCTS: {10, iPhone, 1}, {11, iPad, 1}, {12, Galaxy S3, 2}, {13, Galaxy Note, 2}, {14, Desire, 3} 

我試圖讓所有brand_name爲「Samsung」或product_name爲「Desire」的產品

brand_name:Samsung OR {!join from=brand_id to=id} product_name:Desire 

Bu我得到錯誤說

ERROR [SolrDispatchFilter] null:java.lang.NullPointerException: while trying to invoke the method org.apache.lucene.search.Query.hashCode() of a null object loaded from field org.apache.solr.search.JoinQuery.q of an object loaded from local variable 'this' 
     at org.apache.solr.search.JoinQuery.hashCode(JoinQParserPlugin.java:594) 
     at org.apache.lucene.search.BooleanClause.hashCode(BooleanClause.java:99) 
     at java.util.AbstractList.hashCode(AbstractList.java:541) 
     at org.apache.lucene.search.BooleanQuery.hashCode(BooleanQuery.java:520) 
     at org.apache.solr.search.QueryResultKey.<init>(QueryResultKey.java:47) 
     at org.apache.solr.search.SolrIndexSearcher.getDocListC(SolrIndexSearcher.java:1305) 
     at org.apache.solr.search.SolrIndexSearcher.search(SolrIndexSearcher.java:476) 
     at org.apache.solr.handler.component.QueryComponent.process(QueryComponent.java:461) 
     at org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:217) 
     at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:135) 
     at org.apache.solr.core.SolrCore.execute(SolrCore.java:1916) 
     at org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:768) 
     at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:415) 
     at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:205) 
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
     at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96) 
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230) 
     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:173) 
     at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182) 
     at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84) 
     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) 
     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104) 
     at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157) 
     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) 
     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241) 
     at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) 
     at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) 
     at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) 
     at java.lang.Thread.run(Thread.java:812) 

什麼是正確的方式來使用OR與連接查詢結果?我也想用OR對多個連接結果進行分組。

喜歡的東西下面的查詢

(字段1:值1或場:數值2或場3:值3或{!從= SOME_ID加盟= some_other_id}字段4:VALUE4或{!加入來自= some_field_is到= some_other_field_id}字段5 :value5) AND field7:value7 AND datefield1:{* TO 2015-11-30T14:28:11Z} AND datefield2:{2015-11-30T14:28:11Z TO *}

請建議是否有其他方法是否有這樣做。

回答

0

這可以使用查詢參數完成。

(brand_name:Samsung OR {!join from=brand_id to=id v=$subquery}) 
&subquery=product_name:Desire 
相關問題