Combining 2 different queries in flexible search: 在灵活搜索中合并两个不同的查询。

huangapple go评论99阅读模式
英文:

Combining 2 different queries in flexible search

问题

我们计划在我们的自定义索引器中创建一个删除操作。这个索引器中的文档包括多个类别和产品。当我们删除一个类别时,我们将其存储在一个名为SolrDeletedItem的新表中。对于产品,我们只将批准状态设置为未批准。我们希望将两个不相关的查询合并,以获取存储在SolrDeletedItem和Product表中的所有已删除项目。以下是这些查询。

  • 从{SolrDeletedItem as sdi join ComposedType as ct on {sdi.deletedItemType} = {ct.pk}}中选择{deletedItemPK},其中{ct.code} = 'Category'且{sdi.modifiedtime} >= ?lastIndexTime
  • 从{Product as p join ArticleApprovalStatus as aas on {aas.pk} = {p.approvalStatus}}中选择{p.PK}作为pk,其中{aas.code} = 'unapproved'且{p.modifiedtime} >= ?lastIndexTime
英文:

We plan to create a delete operation in one of our custom indexers. A document in this indexer consists of several categories and product. When we delete a category, we store it in a new table called SolrDeletedItem. For products, we only set the approval status to unapproved. We want to combine 2 different queries without any relation to get all deleted items stored both in SolrDeletedItem and Product tables. Below are the queries.

  • select {deletedItemPK} from {SolrDeletedItem as sdi join ComposedType as ct on {sdi.deletedItemType} = {ct.pk}}
    where {ct.code} = 'Category' and {sdi.modifiedtime} >= ?lastIndexTime
  • SELECT {p.PK} AS pk FROM {Product AS p join ArticleApprovalStatus as aas on {aas.pk} = {p.approvalStatus}}
    WHERE {aas.code} = 'unapproved' and {p.modifiedtime} >= ?lastIndexTime

答案1

得分: 0

SELECT uniontable.PK FROM
(
   {‌{选择 {deletedItemPK} 作为 PK  {SolrDeletedItem as sdi join ComposedType as ct on {sdi.deletedItemType} = {ct.pk}} where {ct.code} = 'Category'}}
   UNION ALL
   {‌{选择 {p.PK} 作为 PK  {Product AS p join ArticleApprovalStatus as aas on {aas.pk} = {p.approvalStatus}} WHERE {aas.code} = 'unapproved'}}
) uniontable
英文:

SELECT uniontable.PK FROM
(
{{
select {deletedItemPK} as PK from {SolrDeletedItem as sdi join ComposedType as ct on {sdi.deletedItemType} = {ct.pk}} where {ct.code} = 'Category'
}}
UNION ALL
{{
SELECT {p.PK} AS PK FROM {Product AS p join ArticleApprovalStatus as aas on {aas.pk} = {p.approvalStatus}} WHERE {aas.code} = 'unapproved'
}}
) uniontable

huangapple
  • 本文由 发表于 2023年5月18日 11:13:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/76277493.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定