我正在尝试设置 Solandra (Solr + Cassandra),并使用 SolrJ 库来使用它。我设法使用 SolrJ 设置了所有内容并添加了一些文档,但是当我尝试进行查询时它失败了。我试图通过 url 执行查询,但它也失败了。我用了:
http://localhost:8983/solandra/my_core/select?q=*:*&wt=xml
在我的应用程序中,我使用了以下代码:
CommonsHttpSolrServer server = new CommonsHttpSolrServer(url);
server.setParser(new XMLResponseParser());
SolrQuery query = new SolrQuery();
query.setQuery("some");
query.setStart(0);
query.setRows(10);
QueryResponse response = server.query(query);
这是我得到的堆栈跟踪:
org.apache.solr.common.SolrException: java.lang.StackOverflowError at org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:281) at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase .java:129) 在 org.apache.solr.core.SolrCore.execute(SolrCore.java:1368) 在 org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:356) 在 solandra.SolandraDispatchFilter.execute( SolandraDispatchFilter.java:171) at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:252) at solandra.SolandraDispatchFilter.doFilter(SolandraDispatchFilter.java:137) at org.mortbay.jetty.servlet.ServletHandler$CachedChain .doFilter(ServletHandler.java:1212) 在 org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:399) 在 org.mortbay.jetty.servlet。org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766) 上 org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) 上的 SessionHandler.handle(SessionHandler.java:182) .mortbay.jetty.Server.handle(Server.java:326) 在 org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542) 在 org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:928 ) 在 org.mortbay.jetty.HttpConnection.handle(HttpConnection.java: org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212) 404) 在 org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228) 在 org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582) 引起:java.lang.StackOverflowError在爪哇。net.SocketInputStream.socketRead0(Native Method) at java.net.SocketInputStream.read(SocketInputStream.java:150) at java.net.SocketInputStream.read(SocketInputStream.java:121) at java.io.BufferedInputStream.fill(BufferedInputStream. java:235) 在 java.io.BufferedInputStream.read(BufferedInputStream.java:254) 在 org.apache.commons.httpclient.HttpConnection.isStale(HttpConnection.java:506) 在 org.apache.commons.httpclient.HttpConnection.closeIfStale (HttpConnection.java:431) 在 org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.closeIfStale(MultiThreadedHttpConnectionManager.java:1313) 在 org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:382) 在 org. org.apache 上的 apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)。commons.httpclient.HttpClient.executeMethod(HttpClient.java:397) at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323) at org.apache.solr.client.solrj.impl.CommonsHttpSolrServer.request( CommonsHttpSolrServer.java:422) 在 org.apache.solr.client.solrj.impl.CommonsHttpSolrServer.request(CommonsHttpSolrServer.java:244) 在 org.apache.solr.handler.component.HttpCommComponent$1.call(SearchHandler.java:421 ) 在 org.apache.solr.handler.component.HttpCommComponent$1.call(SearchHandler.java:393) 在 java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) 在 java.util.concurrent.FutureTask .run(FutureTask.java:166) 在 java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) 在 java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) 在 java. util.concurrent.FutureTask。在 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) 在 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) 在 java.lang.Thread 运行(FutureTask.java:166) .run(Thread.java:722)
难道是我错过了 schema.xml 中的某些内容?这是它的样子:
<schema name="my_core" version="1.1">
<types>
<fieldType name="string" class="solr.StrField"/>
<fieldType name="text_general_rev" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" />
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.ReversedWildcardFilterFactory" withOriginal="true" maxPosAsterisk="3" maxPosQuestion="2" maxFractionAsterisk="0.33"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" />
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
</types>
<fields>
<field name="url" type="string" indexed="true" stored="true"/>
<field name="content" type="text_general_rev" indexed="true" stored="true"/>
<field name="media" type="string" indexed="true" stored="true"/>
<field name="country" type="string" indexed="true" stored="true"/>
<field name="date" type="string" indexed="true" stored="true"/>
</fields>
<defaultSearchField>content</defaultSearchField>
<uniqueKey>url</uniqueKey>
</schema>