如何在弹性Serach查询(UNION)中使用ORDERBY

时间:2019-07-01 13:10:55

标签: hybris flexible-search

我正在尝试如下创建灵活的搜索查询:

SELECT uniontable.PK FROM
(
   {{
      SELECT {p1:PK} AS PK FROM {Product AS p1},{Product AS p2} 
      WHERE {p1.code} = {p2.Att1}
   }}
   UNION ALL
   {{
      SELECT {p:PK} AS PK FROM {Product AS p}
      WHERE {p1.Att1} is not empty
   }}
) uniontable

有人可以告诉我如何在上述查询中使用产品关键字的“ ORDER BY”创建时间吗?

1 个答案:

答案 0 :(得分:0)

尝试一下,它更简单:

 SELECT {p1:PK} AS PK FROM {Product AS p1},{Product AS p2} WHERE {p1.code} = {p2.Att1} AND {p1.Att1} is not empty ORDER BY {p1.creationtime}

希望这会有所帮助