【问题标题】:delete documents from solr index - index is not touched从 solr 索引中删除文档 - 未触及索引
【发布时间】:2012-08-07 17:51:50
【问题描述】:

我试图理解为什么我删除整个索引时甚至没有触及我的 Solr 索引!

到目前为止,我已经尝试直接向 solr 查询:

curl 'http://localhost:8080/solr/update?stream.body=<delete><query>*:*</query></delete>&commit=true'

我也试过 pysolr:

In [242]: from pysolr import Solr

In [243]: conn = Solr('http://localhost:8080/solr/')

In [244]: conn.delete(q='*:*')

以上两条命令在catalina日志中的输出是一样的。

无论我如何尝试(甚至从管理面板尝试过),索引仍然显示相同数量的文档:

Num Docs:
323
Max Doc:
323
Version:
52
Segment Count:
1

起初我以为是我的 solr/data 文件夹的权限问题,但事实并非如此。 我在我的 solrconfig.xml 中注释掉了我的缓存,结果是一样的。

如果有人有任何提示,那就太好了!


后期编辑:

每次我运行上述命令时,只有具有较晚时间戳的文件被修改(仅来自拼写检查器目录) - 您还可以看到用户所有权从 www-data 更改为 root - 当我手动运行这些命令时

data/index:
total 2112
-rw-r--r-- 1 www-data root 1268535 2012-08-10 13:41 _f.fdt
-rw-r--r-- 1 www-data root    2618 2012-08-10 13:41 _f.fdx
-rw-r--r-- 1 www-data root    1135 2012-08-10 13:41 _f.fnm
-rw-r--r-- 1 www-data root  201513 2012-08-10 13:41 _f_Lucene40_0.frq
-rw-r--r-- 1 www-data root  207400 2012-08-10 13:41 _f_Lucene40_0.prx
-rw-r--r-- 1 www-data root  419705 2012-08-10 13:41 _f_Lucene40_0.tim
-rw-r--r-- 1 www-data root   11199 2012-08-10 13:41 _f_Lucene40_0.tip
-rw-r--r-- 1 www-data root     245 2012-08-10 13:41 _f_nrm.cfe
-rw-r--r-- 1 www-data root    2751 2012-08-10 13:41 _f_nrm.cfs
-rw-r--r-- 1 www-data root     382 2012-08-10 13:41 _f.si
-rw-r--r-- 1 www-data root      20 2012-08-10 13:41 segments.gen
-rw-r--r-- 1 www-data root      98 2012-08-10 13:41 segments_h
-rw-r--r-- 1 root     root       0 2012-08-10 13:55 write.lock

data/spellchecker:
total 792
-rw-r--r-- 1 root root 129251 2012-08-10 14:16 _q.fdt
-rw-r--r-- 1 root root  84282 2012-08-10 14:16 _q.fdx
-rw-r--r-- 1 root root   1119 2012-08-10 14:16 _q.fnm
-rw-r--r-- 1 root root 288855 2012-08-10 14:16 _q_Lucene40_0.frq
-rw-r--r-- 1 root root 257208 2012-08-10 14:16 _q_Lucene40_0.tim
-rw-r--r-- 1 root root   9355 2012-08-10 14:16 _q_Lucene40_0.tip
-rw-r--r-- 1 root root    306 2012-08-10 14:16 _q.si
-rw-r--r-- 1 root root     69 2012-08-10 14:16 segments_1p
-rw-r--r-- 1 root root     20 2012-08-10 14:16 segments.gen

data/tlog:
total 444
-rw-r--r-- 1 www-data root 363169 2012-08-10 12:11 tlog.0000000000000000019
-rw-r--r-- 1 www-data root  79280 2012-08-10 12:11 tlog.0000000000000000020

Catalina 日志被截断,conn.delete(q=':') 运行 - 这是 catalina.log 中记录的内容

Aug 10, 2012 3:17:57 PM org.apache.solr.update.DirectUpdateHandler2 commit
INFO: start commit{flags=0,version=0,optimize=false,openSearcher=true,waitSearcher=true,expungeDeletes=false,softCommit=false}
Aug 10, 2012 3:17:57 PM org.apache.solr.search.SolrIndexSearcher <init>
INFO: Opening Searcher@1d4eeb5 main
Aug 10, 2012 3:17:57 PM org.apache.solr.core.QuerySenderListener newSearcher
INFO: QuerySenderListener sending requests to Searcher@1d4eeb5 main{StandardDirectoryReader(segments_h:52 _f(4.0):C323)}
Aug 10, 2012 3:17:57 PM org.apache.solr.core.QuerySenderListener newSearcher
INFO: QuerySenderListener done.
Aug 10, 2012 3:17:57 PM org.apache.solr.handler.component.SpellCheckComponent$SpellCheckerListener buildSpellIndex
INFO: Building spell index for spell checker: default
Aug 10, 2012 3:17:57 PM org.apache.solr.update.DirectUpdateHandler2 commit
INFO: end_commit_flush
Aug 10, 2012 3:18:02 PM org.apache.solr.core.SolrCore registerSearcher
INFO: [collection1] Registered new searcher Searcher@1d4eeb5 main{StandardDirectoryReader(segments_h:52 _f(4.0):C323)}
Aug 10, 2012 3:18:02 PM org.apache.solr.update.processor.LogUpdateProcessor finish
INFO: [collection1] webapp=/solr path=/update/ params={commit=true} {deleteByQuery=*:*,commit=} 0 5608

稍后编辑:

我尝试按 id 删除,它有效!所以出于某种原因删除了

q=*:*

失败...

【问题讨论】:

  • pysolr.Solr 类的删除方法默认具有 commit=True,在我的 curl 查询中我有 &commit=True。这还不够吗?
  • 很奇怪! solr 日志文件说什么?如果我没记错的话,它应该在提交发生时记录,即使在执行删除时也是如此。对不起,如果我问,这是你唯一的索引吗?你找对了吗?
  • @javanna 从 pysolr 中删除所有内容后,我添加了 catalina 日志的输出...我只有一个集合!
  • 提交显然发生了......但是您是否以 root 身份运行 Solr?
  • 是的,solr 以 root 身份在 tomcat6 上运行,我手动运行 catalina.sh run - 目前

标签: python solr pysolr


【解决方案1】:

我发现问题出在我的 schema.xml 中

我重写了它,现在就像一个魅力!

【讨论】:

  • 我们能知道您在 schema.xml 中的问题吗?
【解决方案2】:

我认为您需要切换 commit 和 stream.body 参数的顺序。从您的 catalina 日志中查看最后一个条目,提交值似乎未包含在删除查询中。

试试这个:

 curl 'http://localhost:8080/solr/update?commit=true&stream.body=<delete><query>*:*</query></delete>'

【讨论】:

  • 我试过了,没用 :( ...那些是获取参数,我认为顺序不重要
【解决方案3】:

试一试 curl,过去曾为我工作过:

curl http://localhost:8080/solr/update/?commit=true -H "Content-Type: text/xml" --data-binary '<delete><query>*:*</query></delete>'; 

希望对你有帮助。

【讨论】:

  • 上面的命令没有使用默认端口,但对我有用。
猜你喜欢
  • 1970-01-01
  • 2012-09-25
  • 1970-01-01
  • 1970-01-01
  • 2017-03-05
  • 1970-01-01
  • 2014-05-05
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多