我有以下文件:嵌套小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
。我認爲解決方案將是一個嵌套的方面搜索,但我不知道,我不知道如何。
如果這是一個常見的查詢,你應該考慮索引非活動。就像一個領域「不活動:慢跑」。在索引方面儘可能多地完成工作,使查詢更快更清晰。 – Risadinha