首页 > 解决方案 > 奇怪的 Solr 弹簧行为

问题描述

当我使用 Spring 数据构建查询时,它会生成以下查询:

http://localhost:8983/solr/pride_projects/select?q=accession:*PXD*+OR+accession:*PRD*+AND+publication_date:[2012\-12\-31T00\:00\:00.000Z+TO+2012\-12\-31T00\:00\:00.000Z]

这没有给我任何结果。我已手动将 Solr 中的查询更改为:

http://localhost:8983/solr/pride_projects/select?q=accession:*PXD*+OR+accession:*PRD*+publication_date:[2012\-12\-31T00\:00\:00.000Z+TO+2012\-12\-31T00\:00\:00.000Z]

这里的输出:

{ accession: "PXD000002", project_title: "The human spermatozoa proteome", project_description: "The human spermatozoa proteome was in depth characterized using shotgun iterative GeLC-MS/MS method with peptide exclusion lists.", project_sample_protocol: "This LC-MS/MS analysis was repeated twice by digested band using an identified peptide exclusion list, generated by Proteome Discoverer, from the previous LC-MS/MS runs of the same sample.", submission_date: "2012-01-02T00:00:00Z",

删除最后一个AND,现在查询有效。我希望这两个查询都有类似的行为,但不是。

有任何想法吗?

标签: solrlucenesolrjspring-data-solr

解决方案


当您删除 AND 要求时,没有理由结果应该相同 - 您的设置的默认行为可能是所有子句都是可选的,除非您明确要求它(通过AND)。

由于您的publication_date时间间隔仅匹配一毫秒,因此它不匹配任何文档 - 因此在您的最后一个查询中它被忽略(如果文档匹配,则会影响分数)。

2012-12-31T00:00:00.000Z TO 2012-12-31T00:00:00.000Z

..间隔的开始与间隔的结束相同,但是由于您使用了[and ](这意味着包含该值本身),您将获得与以该毫秒为索引的文档的匹配项。

您可能打算过滤更广泛的范围。


推荐阅读