我们有以下结构的solr文件。
<doc>
<field name="id">200</field>
<field name="document_type">Student</field>
<field name="first_name_s">Suren</field>
<field name="last_name_s">Raju</field>
<doc>
<field name="id">300</field>
<field name="document_type">Address</field>
<field name="address_line1_s">18th Main Road</field>
<field name="address_line2_s">Hsr Layout</field>
<field name="country_i">100</field>
<field name="city_s">Bangalore</field>
</doc>
</doc>
<doc>
<field name="id">100</field>
<field name="document_type">Country</field>
<field name="document_type_id">100</field>
<field name="country_code_s">IND</field>
<field name="country_name_s">India</field>
<field name="currency_code_s">INR</field>
<field name="currency_name_s">Indian Rupee</field>
</doc>
在上述文件格式中,如何查询来自印度国家的所有学生?我尝试过使用solr block join和join但收到以下错误。
查询:
{!parent which="document_type:Student"} {!join from=id to=country_i} country_code_s:IND AND document_type:Country
响应:
"error": {
"msg": "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'",
"trace": "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'\r\n\tat org.apache.solr.search.JoinQuery.hashCode(JoinQParserPlugin.java:594)\r\n\tat org.apache.solr.search.QueryResultKey.<init>(QueryResultKey.java:53)\r\n\tat org.apache.solr.search.SolrIndexSearcher.getDocListC(SolrIndexSearcher.java:1305)\r\n\tat org.apache.solr.search.SolrIndexSearcher.search(SolrIndexSearcher.java:476)\r\n\tat org.apache.solr.handler.component.QueryComponent.process(QueryComponent.java:461)\r\n\tat org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:217)\r\n\tat org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:135)\r\n\tat org.apache.solr.core.SolrCore.execute(SolrCore.java:1916)\r\n\tat org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:768)\r\n\tat org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:415)\r\n\tat org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:205)\r\n\tat org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1419)\r\n\tat org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:455)\r\n\tat org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)\r\n\tat org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:557)\r\n\tat org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)\r\n\tat org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1075)\r\n\tat org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:384)\r\n\tat org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)\r\n\tat org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1009)\r\n\tat org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)\r\n\tat org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255)\r\n\tat org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)\r\n\tat org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)\r\n\tat org.eclipse.jetty.server.Server.handle(Server.java:368)\r\n\tat org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:489)\r\n\tat org.eclipse.jetty.server.BlockingHttpConnection.handleRequest(BlockingHttpConnection.java:53)\r\n\tat org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:942)\r\n\tat org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:1004)\r\n\tat org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:640)\r\n\tat org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)\r\n\tat org.eclipse.jetty.server.BlockingHttpConnection.handle(BlockingHttpConnection.java:72)\r\n\tat org.eclipse.jetty.server.bio.SocketConnector$ConnectorEndPoint.run(SocketConnector.java:264)\r\n\tat org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)\r\n\tat org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)\r\n\tat java.lang.Thread.run(Thread.java:812)\r\n",
"code": 500
}
是否可以在Solr中同时使用块连接和连接?
使用以下查询,我可以访问国家/地区的地址。
{!join from=id to=country_i} country_code_s:IND AND document_type:Country
从地址文档如何访问学生文档?
答案 0 :(得分:0)
{!parent which=document_type:Student v=$subQuery}&subQuery={!join from=id to=country_i} country_code_s:IND AND document_type:Country