如何在solr中查询将过滤器应用于2个不同的集合?

时间:2019-05-06 11:29:38

标签: solrcloud

我有2个分别称为index1和index2的索引,我想基于最近一段时间内两个索引中可用的日期字段返回index2的所有字段?

尝试的网址列表:

http://localhost:8983/solr/index2/select?q=*:*&fl=updated_dt&fq={!join from=article_no to=article_no fromIndex=index1}store_s:SFCC&(dt:[2019-05-03 TO *] OR updated_dt:[2019-05-05 TO *]

http://localhost:8983/solr/index2/select?q=*:*&fl=article_no,updated_dt&fq={!join from=article_no to=article_no fromIndex=index1}store_s:SFCC&(dt:[2019-04-08 TO *] OR updated_dt:[2019-05-05 TO *]

http://localhost:8983/solr/index2/select?q=updated_dt:[2019-04-08T01:00:00Z TO *]&fl=article_no,updated_dt&fq={!join from=article_no to=article_no fromIndex=index1}store_s:SFCC&sort=updated_dt asc

http://localhost:8983/solr/index2/select?q=*:*&fl=article_no,updated_dt&fq=(store_s:SFCC AND dt:[2019-04-08T01:00:00Z TO *]) AND updated_dt:[2018-11-05T01:00:00Z TO *]&sort=updated_dt asc&collection=index2,index1

http://localhost:8983/solr/JoinResult/select?q=*:*&fl=article_no,updated_dt&fq=store_s:SFCC&fq=((dt:[2019-04-08 TO *]) OR (updated_dt:[2018-11-05T00:00:00Z TO *]))

http://localhost:8983/solr/JoinResult/select?q=*:*&fl=article_no,updated_dt&fq=store_s:SFCC&fq=((dt:[2019-04-08T01:00:00Z TO *]) OR (updated_dt:[2018-11-05T01:00:00Z TO *]))

http://localhost:8983/solr/JoinResult/select?&q={!join from=article_no to=article_no v=$q1} OR {!join from=article_no to=article_no v=$q2} 
&q1=store_s:SFCC AND dt:[2019-04-08T01:00:00Z TO *]&q2=updated_dt:[2018-11-05T00:00:00Z TO *]

http://localhost:8983/solr/JoinResult/select?q=*:*&fq=((dt:[2019-04-08 TO *]) AND (updated_dt:[2018-04-05T00:00:00Z TO *]))

index1数据


  {
    "ecom`":"TRUE",
    "dt":"2019-04-29",
    "str":"SFCCLOAD",
    "article_no":"FTW10001"},
  {
    "com":"TRUE",
    "dt":"2019-04-30",
    "str":"SFCCLOAD",
    "article_no":"FTW1206"},
  {
    "com":"TRUE",
    "dt":"2019-05-03",
    "str":"SFCCLOAD",
    "article_no":"FTW1207"},
  {
    "com":"TRUE",
    "dt":"2019-05-03",
    "str":"SFCCLOAD",
    "article_no":"FTW1208"},
  {
    "com":"TRUE",
    "str":"SFCCLOAD",
    "dt":"2019-04-20",
    "article_no":"FTW1210"}

index2数据


{
    "parent":"Parent01",
    "updated_dt":"2019-05-04",
    "article_no":"FTW1207"},
  {
    "parent":"Parent02",
    "updated_dt":"2019-05-05",
    "article_no":"FTW1208"},
  {
    "parent":"Parent02",
    "updated_dt":"2019-05-05",
    "article_no":"FTW1209"},
  {
    "parent":"Parent03",
    "updated_dt":"2019-05-05",
    "article_no":"FTW1210"}

从第二个索引中预期的是(FTW1207,FTW1208,FTW1210)

和同一个sql查询是:

select article_no,updated_dt 
from Index2 
where  updated_dt > 2018-11-05 
       and article_no in (select article_no from Index1 where str='SFCC' and dt > 2019-04-08)

0 个答案:

没有答案