我在Solr中有以下文件:
(1) { date:"2013-01-01", person:"John", activity:"swimming" } // <-- watch out date/year
(2) { date:"2014-01-02", person:"John", activity:"cycling" }
(3) { date:"2014-01-03", person:"John", activity:"jogging" }
(4) { date:"2014-01-01", person:"Paul", activity:"swimming" }
(5) { date:"2014-01-02", person:"Paul", activity:"cycling" }
(6) { date:"2014-01-03", person:"Paul", activity:"jogging" }
(7) { date:"2014-01-01", person:"Ringo", activity:"swimming" }
(8) { date:"2014-01-02", person:"Ringo", activity:"cycling" }
(9) { date:"2014-01-03", person:"Ringo", activity:"climbing" } // <-- watch out activity
将所有字段设为indexed
和stored
。
现在,我想查找所有swimming
AND
cycling
但NOT
jogging
(全部在2014
内)的人。当然,正确的答案应该是Ringo
。我认为解决方案将是一个嵌套的方面搜索,但我不确定,我不知道如何。
答案 0 :(得分:0)
编辑:好的,我现在明白了...'游泳和骑自行车'你的意思是Lucene AND。当然,这是无效的。
然后,怎么样,你可以查询activity:(swimming) AND date:[2014-01-01T00:00:00.000Z TO 2014-12-31T23:59:59.999Z]
,并使用以下方面:
facet=on&facet.query=activity:cycling&facet.query=activity:jogging
只保留循环方面的值,但不要保持在慢跑方面。
需要一些客户端代码但应该有用吗?