我正在从这里运行 Apache Solr 教程:
http://lucene.apache.org/solr/guide/7_6/solr-tutorial.html
Solr 正在运行,我可以在 Web 浏览器中运行查询。
该教程提到cURL
了我不熟悉的内容。
我已经解压CURL
到C:\Curl
Curl 并将其包含在PATH environment variable
:C:\Curl\curl-7.63.0-win64-mingw\bin
在 Windows 命令提示符下运行以下命令时出现错误。我用谷歌搜索试图找到一个无济于事的解决方案:
下面的代码:
C:\Curl\curl-7.63.0-win64-mingw\bin>curl -X POST -H 'Content-type:application/json' --data-binary '{"add-field": {"name":"name", "type":"text_general", "multiValued":false, "stored":true}}' http://localhost:8983/solr/films/schema
生成以下错误:
curl: (3) unmatched brace in URL position 1:
{name:name,
^
curl: (3) URL using bad/illegal format or missing URL
curl: (3) URL using bad/illegal format or missing URL
curl: (3) unmatched close brace/bracket in URL position 12:
stored:true}}'
^
{
"responseHeader":{
"status":400,
"QTime":1},
"error":{
"metadata":[
"error-class","org.apache.solr.common.SolrException",
"root-error-class","org.apache.solr.common.SolrException"],
"msg":"no stream",
"code":400}}
我尝试添加一个-g
来关闭通配符。
curl -g -X POST -H 'Content-type:application/json' --data-binary '{"add-field": {"name":"name", "type":"text_general", "multiValued":false, "stored":true}}' http://localhost:8983/solr/films/schema
这产生了几乎相同的错误:
C:\Curl\curl-7.63.0-win64-mingw\bin>curl -g -X POST -H 'Content-type:application/json' --data-binary '{"add-field": {"name":"name", "type":"text_general", "multiValued":false, "stored":true}}' http://localhost:8983/solr/films/schema
curl: (3) URL using bad/illegal format or missing URL
curl: (3) URL using bad/illegal format or missing URL
curl: (3) URL using bad/illegal format or missing URL
curl: (3) URL using bad/illegal format or missing URL
{
"responseHeader":{
"status":400,
"QTime":1},
"error":{
"metadata":[
"error-class","org.apache.solr.common.SolrException",
"root-error-class","org.apache.solr.common.SolrException"],
"msg":"no stream",
"code":400}}
然后我尝试删除单引号并转义双引号,但随后出现以下错误:
curl -g -X POST -H Content-type:application/json --data-binary {\"add-field\": {\"name\":\"name\", \"type\":\"text_general\", \"multiValued\":false, \"stored\":true}} http://localhost:8983/solr/films/schema
ScopedHandler.nextHandle(ScopedHandler.java:255)\r\n\tat org.eclipse.jetty.server.handler。ContextHandler.doHandle(ContextHandler.java:1317)\r\n\tat org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:203)\r\n\tat org.eclipse.jetty.servlet。 ServletHandler.doScope(Serv letHandler.java:473)\r\n\tat org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1564)\r\n\tat org.eclipse.jetty.server .handler.ScopedHandler.nextScope(ScopedHandler.java:201)\r\n\tat org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1219)\r\n\tat org.eclipse.jetty .server.handler.ScopedHandler.handle(ScopedHandler.java:144)\r\n\tat org.eclipse.jett y.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:219)\r\n\tat org. eclipse.jetty.server.handler.HandlerCollection。runTask(EatWhatYouKill .java:333)\r\n\tat org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:310)\r\n\tat org.eclipse.jetty.util。 thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java :168)\r\n\tat org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:126)\r\n\tat org. eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:366)\r\n\tat org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:762)\r\n \tat org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:680)\r\n\tat java。lang.Thread.run(Unknown Source)\r\n", "code":500}} EatWhatYouKill.tryProduce(EatWhatYouKill.java :168)\r\n\tat org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:126)\r\n\tat org.eclipse.jetty。 util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:366)\r\n\tat org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:762)\r\n\tat org. eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:680)\r\n\tat java。lang.Thread.run(Unknown Source)\r\n", "code":500}} EatWhatYouKill.tryProduce(EatWhatYouKill.java :168)\r\n\tat org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:126)\r\n\tat org.eclipse.jetty。 util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:366)\r\n\tat org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:762)\r\n\tat org. eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:680)\r\n\tat java。lang.Thread.run(Unknown Source)\r\n", "code":500}} 762)\r\n\tat org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:680)\r\n\tat java。lang.Thread.run(Unknown Source)\r\n", "code":500}} 762)\r\n\tat org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:680)\r\n\tat java。lang.Thread.run(Unknown Source)\r\n", "code":500}}
我知道关于这个问题有很多类似的问答,但它们并不完全相同,而且我尝试过的解决方案都没有解决我的问题。