我有一个运行SOLR 3.6的实例,JSON作为默认的updateHandler。
我可以使用以下内容删除单个文档:
curl "http://myURL/update?commit=true" -H 'Content-type:application/json' -d '{"delete": {"id":"1730887464"}}'
删除一系列ID的正确方法是什么?
我尝试了以下内容:
curl "http://myURL/update?commit=true" -H 'Content-type:application/json' -d '{"delete": {"id":"[* TO 1730887464]"}}'
curl "http://myURL/update?commit=true" -H 'Content-type:application/json' -d '{"delete": {"id":"[0 TO 1730887464]"}}'
我得到以下异常。任何帮助/指针将不胜感激。 我抬头看了看:
http://wiki.apache.org/solr/UpdateJSON
http://lucene.apache.org/solr/api/doc-files/tutorial.html
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<title>Error 500 For input string: "[* TO 1730887464]"
java.lang.NumberFormatException: For input string: "[* TO 1730887464]"
at java.lang.NumberFormatException.forInputString(NumberFormatException. java:65)
at java.lang.Long.parseLong(Long.java:438)
at java.lang.Long.parseLong(Long.java:478)
at org.apache.solr.schema.TrieField.readableToIndexed(TrieField.java:295 )
at org.apache.solr.schema.TrieField.toInternal(TrieField.java:307)
at org.apache.solr.update.DirectUpdateHandler2.delete(DirectUpdateHandle r2.java:288)
at org.apache.solr.update.processor.RunUpdateProcessor.processDelete(Run UpdateProcessorFactory.java:68)
at org.apache.solr.update.processor.LogUpdateProcessor.processDelete(Log UpdateProcessorFactory.java:137)
at org.apache.solr.handler.JsonLoader.processUpdate(JsonLoader.java:120)
at org.apache.solr.handler.JsonLoader.load(JsonLoader.java:75)
at org.apache.solr.handler.ContentStreamHandlerBase.handleRequestBody(Co ntentStreamHandlerBase.java:58)
at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandl erBase.java:129)
at org.apache.solr.core.RequestHandlers$LazyRequestHandlerWrapper.handle Request(RequestHandlers.java:244)
at org.apache.solr.core.SolrCore.execute(SolrCore.java:1376)
at org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter .java:365)
at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilte r.java:260)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(Servlet Handler.java:1212)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:3 99)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.jav a:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:1 82)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:7 66)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:450)
at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHand lerCollection.java:230)
at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection. java:114)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:1 52)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:54 2)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnectio n.java:945)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector. java:228)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.j ava:582)
</title>
</head>
<body><h2>HTTP ERROR 500</h2>
<p>Problem accessing /solr/update. Reason:
<pre> For input string: "[* TO 1730887464]"
java.lang.NumberFormatException: For input string: "[* TO 1730887464]"
at java.lang.NumberFormatException.forInputString(NumberFormatException. java:65)
at java.lang.Long.parseLong(Long.java:438)
at java.lang.Long.parseLong(Long.java:478)
at org.apache.solr.schema.TrieField.readableToIndexed(TrieField.java:295 )
at org.apache.solr.schema.TrieField.toInternal(TrieField.java:307)
at org.apache.solr.update.DirectUpdateHandler2.delete(DirectUpdateHandle r2.java:288)
at org.apache.solr.update.processor.RunUpdateProcessor.processDelete(Run UpdateProcessorFactory.java:68)
at org.apache.solr.update.processor.LogUpdateProcessor.processDelete(Log UpdateProcessorFactory.java:137)
at org.apache.solr.handler.JsonLoader.processUpdate(JsonLoader.java:120)
at org.apache.solr.handler.JsonLoader.load(JsonLoader.java:75)
at org.apache.solr.handler.ContentStreamHandlerBase.handleRequestBody(Co ntentStreamHandlerBase.java:58)
at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandl erBase.java:129)
at org.apache.solr.core.RequestHandlers$LazyRequestHandlerWrapper.handle Request(RequestHandlers.java:244)
at org.apache.solr.core.SolrCore.execute(SolrCore.java:1376)
at org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter .java:365)
at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilte r.java:260)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(Servlet Handler.java:1212)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:3 99)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.jav a:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:1 82)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:7 66)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:450)
at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHand lerCollection.java:230)
at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection. java:114)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:1 52)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:54 2)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnectio n.java:945)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector. java:228)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.j ava:582)
答案 0 :(得分:4)
您需要使用查询删除:
curl "http://myURL/update?commit=true" -H 'Content-type:application/json' -d '{"delete": {"query":"id:[* TO 1730887464]"}}'
我对json的工作不多,所以不确定'查询'部分是否正确......但我想你明白了我的意思