Hybris电子商务

             hybris的学习及了解

<文档编号/版本号1.0>

 

 

 

 

 

 

 

文档作者: 熊敏

创建日期: December 12, 2016

更新日期: December 12, 2016

文档编号:  

当前版本: 1.0

 

Note: Title, Subject, Last Updated Date, Reference Number, and Version are marked by a Word Bookmark so that they can be easily reproduced in the header and footer of documents.  When you change any of these values, be careful not to accidentally delete the bookmark.  You can make bookmarks visible by selecting Tools->Options…View and checking the Bookmarks option in the Show region.

 

 

审批签字:

XX       项目经理

 

实施方  项目经理

 

Note: To add additional approval lines, press [Tab] from the last cell in the table above.

Note: You can delete any elements of this cover page that you do not need for your document.  For example, Copy Number is only required if this is a controlled document and you need to track each copy that you distribute.

 


文档控制

 

变更记录

3

日期

作者

版本

变更说明

 

 

 

 

14-nove-2016

Xiongmin

1.0

初版

 

 

 

 

 

 

 

 

 

 

 

 

 

 

审阅

 

姓名

职位

 

 

 

 

 

 

 

 

 

 

 

 

分发

 

拷贝编号

姓名

位置/岗位

 

 

 

1

 

 

2

 

 

3

 

 

4

 

 

Note: The copy numbers referenced above should be written into the Copy Number space on the cover of each distributed copy.  If the document is not controlled, you can delete this table, the Note To Holders, and the Copy Number label from the cover page.

 

目录

文档控制 1

1.sap hybris 概览 3

2.销售渠道 4

3.hybris 系统结构总览 5

4.hybris技术架构 6

5.hybris独特的价值-灵活的部署架构 8

6. hybris-FlexbleSearch 13

更改历史 26

 

Note: To update the table of contents, put the cursor anywhere in the table and press [F9].  To change the number of levels displayed, select the menu option Insert>Index and Tables, make sure the Table of Contents tab is active, and change the Number of Levels to a new value.

 


1.sap hybris 概览

Hybris是最大的B2C和B2B电子商务专家,最全面电子商务解决方案 (incl. WCMS, PCM),它具有模块化和服务导向架构,具有最多合作伙伴, 并且是资金实力及对电子商务的独家重点,全球超过400家客户。

新一代电子商务的需要:

灵活的,轻量级的,健壮的平台。全面集成的,一站式提供B2B、B2C、甚至B2B2C。全渠道接入。无缝隙生成。全面支持移动互联网。线上线下整合。卓越的、统一的客户服务。印刷方案集成。强大的主数据管理。全渠道订单管理。360度客户视角,会员等级&积分奖励。统一库存视图。运输与物流管理。全渠道促销执行。社会化电子商务。IN CHINA,FOR CHINA.

hybris B2C电商平台中国版

        中国页面模板、简化型订单流程优化、支付集成(支付宝)、中国社交网络集成、搜索关键字、利用百度地图,查找商店、市场集成(天猫)。 

 

2.销售渠道

销售渠道的演进与转型 

单渠道:库存目标客户商品,通知目标客户,吸引目标客户购买。

多渠道:各渠道库存目标客户商品,各渠道通知目标客户,各渠道吸引目标客户购买。

全渠道:设计统一且完整的客户体验,定制客户(群)特定的商品组合,运用各种沟通渠道通知客户(群),客户使用任一种渠道购买。

全渠道的定义:

“全渠道”是指企业能通过多种渠道与顾客互动,包括网站、实体店、服务终端、直邮销售目录、呼叫中心、社交媒体、移动设备、游戏机、电视、网络家电、上门服务,等等。传统行业应采用全新视角,把各种迥然不同的渠道整合成“全渠道”的一体化无缝式体验

“全渠道”的设计是以消费者为中心开展。消费者想要拥有一切。一方面,他们希望享受线上的好处:广泛的选择范围、丰富的产品信息、来自其他顾客的评价和提示。另一方面,他们也不想放弃实体店的好处:一对一的贴身服务、商品触摸和感知,以及把购物当成一种活动和体验。不同的消费群注重购物体验的不同方面,然而他们都希望能把线上和实体店购物两方面的体验完美地融合起来。

O2O是全渠道中的一种业务模式,O2O 的建设必须以整合的渠道为基础;所以,O2O 应该是当今的还在多渠道阶段中的企业,转型成为全渠道的第一步。

 

3.hybris 系统结构总览

 

电商平台需要具备的核心能力:灵活的开发构架,灵活的部署构架,平台的安全性,平台的开放性以及高性能。

hybris可插拔式的开发扩展

hybris产品模块通常包含一个或多个扩展,可以方便地为特定项目、特定功能创建定制扩展。

 

4.hybris技术架构

hybris技术架构 Extension ->Service ->Java代码

 

 

hybris独特价值 - 平台的开放扩展性

1.开放的技术标准。

2.全面的API接口。

3.定时任务。

4.全面的协议支持。

5.事件驱动的架构。

hybris使用的部分技术及比标准

Hybris采用了最新的J ava技术和Spring框架,可以根据需求变化快速二次开发实施和上线。

Spring Framework、Apache Tomcat、ZK Framework、Apache Solr 、Ehcache、Hibernate Validator、Apache Ant、Jasper Reports、Apache Commons 、Google Guava.

 

平台开放性 – 支持多种协议

 

 

 

 

5.hybris独特的价值-灵活的部署架构

hybris独特的价值-灵活的部署架构:

 

 

hybris灵活的集群扩展:

 

 

hybris独特价值—强大的安全管理:

认证, 权限:LDAP, 授权, 角色管理等

协议加密:HTTPS, FTPS,SSH等

内容加密:MD5, RSA, DES,邮件签名等

安全规范:PCI(Payment Card Industry Data Security Standard)

基础设施:Spring安全架构, 防火墙, 应用服务器补丁,

hybris产品组件架构:

 

实现电子商务线上线下整合O2O与最佳客户体验:

 

 

多渠道客服中心:

 

 

 

为什么使用hybris – 全渠道产品管控中心:\


 

订单管理重点功能:

1.跨多个库存节点的实时库存管理Advanced sourcing strategies

2.单一库存视图

3.可配置的自动化订单流程

4.订单管理中心可进行货物的分拣,打包,标签以及发运确认

5.与样本商店无缝集成

6.开放架构,可与其他系统轻松集成

Hybris OMS概览:

Web: 汇聚整个供应链条上的库存信息、In Store模块可以定位库存位置

In Store: In-Store模块可实现在实体店面的分拣及订单履行

Fulfillment: 支持厂送、支持第三方物流商集成 、支持与外部WMS 集成

Hybris OMS的关键好处:

1.在任意地点履行订单。

2.防止库存短缺导致的订单流失。

3.同意库存视图。

4.全面支持全渠道。

5.优化实体店面的客户购物经验。

可扩展订单流程:

 

Hybris OMS的部署结构

 

计算库存可用性:

库存可用性检查公式由三个部分组成:

库存状态、订单状态、安全库存设置(定义安全库存防止出现超买,可以设定安全库存为固定数量,或库存百分比库存可用性 会根据库存及订单状态自动更新)

 

 

6.hybris-FlexbleSearch

 采用hybris商务套房带有一个基于SQL的语法中,FlexibleSearch的一个内置的查询语言。该FlexibleSearch通过hybris商务套件使用搜索项

基础知识

    该FlexibleSearch是内置采用hybris Commerce Suite的一个强大的检索语言。它能采用hybris商务套件使用基于SQL语法搜索类型和物品。

    一个FlexibleSearch语句的执行发生在两个阶段:  pre-parsing(预解析)到一个SQL-compliant语句中和运行这个语句在数据库上 在预解析阶段,FlexibleSearch框架解析FlexibleSearch语法到SQL-compliant里。下面的两个代码段表现出一个FlexibleSearch查询和这个FlexibleSearch语句查询的结果,这是在数据库上执行的语句:

FlexibleSearch查询语句:    

elect {pk}, {code}, {name[de]} from {Product}

在数据库上执行的SQL语句:

SELECT  item_t0.PK , item_t0.Code , lp_t0.p_name

FROM products item_t0 JOIN productslp lp_t0 ON item_t0.PK = lp_t0.ITEMPK AND lp_t0.LANGPK= 9013632135395968

WHERE (item_t0.TypePkString IN  ( 23087380955301264 , 23087380955663520 , 23087380955662768 , 23087380955661760 ,

23087385363574432 , 23087380955568768 , 23087380955206016 ) )

FlexibleSearch采用hybris Commerce Suite的类型系统从实际的数据库表这样你就可以在类型相同级别运行查询。不同于常规的SQL语句,在一个FlexibleSearch查询中您不必指定明确的数据库表名。该FlexibleSearch框架解析类型和数据库表自动依赖关系并指定必要UNIONS和JOINS在哪里。类型系统和数据库表示之间的整个转换过程是自动进行的。要访问一个类型中FlexibleSearch查询,请用花括号{and},如类型代码:

 

SELECT * FROM {Product}

采用hybris Commerce Suite的在某一用户帐户的上下文中执行FlexibleSearch查询,使用一个会话。因为不同的用户帐户访问在采用hybris商务套件的不同项目,搜索结果的数量取决于用户的帐户。搜索结果的数目被按类型的访问权限定义(这些仅影响采用hybris管理控制台的搜索结果),限制,目录版本和类别。

更多的特权用户帐户是,在更多的搜索结果FlexibleSearch产量在用户帐户的上下文中。默认情况下,分配给会话的用户帐户是匿名的,所以任何FlexibleSearch查询返回的搜索结果相匹配的默认匿名帐户。

匿名不同用户帐户的情况下运行从FlexibleSearch查询,该会话需要被分配给不同的用户帐户,如:

import de.hybris.platform.servicelayer.user.UserService;

...// Injected by SpringuserService.setCurrentUser(userService.getUserForUID("myUserAccount"));

...

语法概要

FlexibleSearch查询的基本语法如下:

SELECT <selects> FROM <types> ( WHERE <conditions> )? ( ORDER BY <order> )?

一个FlexibleSearch查询包括:

    强制性的<selects>参数对SELECT子句。

    强制性的<type>参数为对FROM子句。

    强制性的一个可选的<conditions>字段的WHERE子句。

    一个可选的ORDER BY子句    

SQL Command / Keyword

Description / Comment

Code Example

ORDER BY {alias:attribute}

Display results ordered by the value of attribute.

SELECT ... FROM ... ORDER BY...

ASC

排序结果以升序 (a...z, 0...9).

SELECT ... FROM ... ORDER BY ... ASC

DESC

排序结果以降序(z...a, 9...0).

SELECT ... FROM ... ORDER BY ... DESC

DISTINCT

Eliminates double entries in the query result.

SELECT DISTINCT ... FROM ...

OR

Performs a logical OR compare between two queries.

... WHERE ... OR ...

AND

Performs a logical AND compare between two queries.

... WHERE ... AND ...

IS [NOT] NULL

Returns the results that are [not] null

... WHERE ... IS [NOT] NULL

[NOT] IN

Returns the results that are [not] part of the following statement ... WHERE ... [NOT] IN ...

 

[NOT] EXISTS

Returns the results that are [not] matching a given subquery.

...WHERE ... EXISTS ( {{ SELECT ... }} )

LIKE

Compares to a pattern.

... WHERE ... LIKE '...'

%

Wildcard matching any number of characters.

... WHERE ... LIKE '%...'||'...%...'||'...%'

_

Wildcard matching a single character.

... WHERE ... LIKE '...' || '......' ||'..._'

LEFT JOIN ON

Merges two tables into one.

... LEFT JOIN ... ON ... = ...

=

True if results are equal.

 

!=, <>

True if results are not equal.

 

<

True if result 1 is less than result 2.

 

<=

True if result 1 is equal to or less than result 2.

 

>

True if result 1 is greater than result 2.

 

>=

True if result 1 is equal to or greater than result 2.

 

CONCAT

连接两个结果 - 在右边侧的例子将返回字符串结果。

CONCAT ( 'resul', 't' )

:o

外连接参数用于包括与在ProductsLP表(=. 表包含本地化产品)以及缺少行匹配结果否则,例如查询将只返回产品 与ProductsLP表中现有行,因为它只会使用JOIN。

SELECT {p:PK}
   FROM {Product AS p}
   WHERE {p:description[en]:o} LIKE '%text%'
   OR {p:description[de]:o} LIKE '%text%'

 

<selects> 

<selects>字段中的值指定要返回的数据库列。星号(*)将返回所有数据库列,如SQL约定。要搜索一个属性,指定大括号,如属性标识符:SELECT{code}FROM {Product}。

要获取本地化的属性值,使用的语言标识符作为后缀属性名在,包含在方括号([and]),如:

SELECT * FROM {Category}

这个查询返回每个数据库列的Category表。

SELECT {pk},{code},{name[de]} FROM {Product}

从产品表查询返回的数据库pk,code,name[de]列.

<type>
该数值为<type>在FROM子句中字段中指定采用hybris Commerce Suite的类型,嵌套在大括号{and}这是要搜索,例如:

SELECT * FROM {Product}SELECT * FROM {Category JOIN Catalog}

你可以指定一个别名用于区分属性字段,使用AS运算符:

SELECT {p.code} FROM {Product AS p} ORDER BY {p.code

您也可以运行JOIN和LEFT JOIN的查询,如:

SELECT {cj.code}

    FROM {SyncItemCronJob AS sicj

         JOIN SyncItemJob AS sij

           ON {sicj:job} = {sij:pk}

     }

SELECT {p1.PK},{p2.PK}

    FROM {Product AS p1

         LEFT JOIN Product AS p2

            ON {p1.code} = {p2.code}

     }WHERE {p1.PK} <> {p2.PK}

    ORDER BY {p1.code} ASC

一定要记住,这是最重要的,整个<type>块必须由封闭{和}不管多种类型.不要试图在多个放<type>块在FROM子句中。尽管这看起来是工作,它可能会导致不可预知的错误。

子类型

默认情况下,指定类型搜索导致FlexibleSearch查询来搜索该类型和任何子类型。例如,下面的代码片段返回codes和PKs所有实例的Product与VariantProduct

SELECT {code},{pk} FROM {Product}

通过增加一个尾部的感叹号(!),在FlexibleSearch查询仅搜索指定类型和忽略所有subtypes,下面的代码片段搜索Product的唯一实例不是VariantProduct,

SELECT {code},{pk} FROM {Product!}

当搜索子类型所述FlexibleSearch首先检索字类型进行搜索,例如在Product的情况下,类型搜索是Product和VariantProduct。正如商务部的hybris一套房类型定义为一个项目,因此有一个主键(PK),在FlexibleSearch检索所有类型的PK进行搜索。搜索类型的PKs的清单放入IN子句WHERE子句内。

 

FlexibleSearch Query

SQL Statement

SELECT {p:code}, {p:pk}

SELECT  item_t0.Code , item_t0.PK
FROM products item_t0
WHERE (item_t0.TypePkString IN  (
   23087380955301264 , 23087380955663520 , 23087380955662768 ,
   23087380955661760 , 23087385363574432 , 23087380955568768 ,
   23087380955206016 )
)

 

 

SELECT {p:code}, {p:pk}

SELECT  item_t0.Code , item_t0.PK
FROM products item_t0
WHERE (item_t0.TypePkString =  23087380955206016 )

从搜索的类型中排除

如果你想确保某些类型从FlexibleSearch查询运行省略,有两种方法在您的处置:

    使用请将ItemType操作员和一个参数.这种方法是可行的,如果你可以准备,并通过一个Map,引用要排除作为FlexibleSearch参数,如类型:

final Set<ComposedTypeModel> excludedTypes = new HashSet<ComposedTypeModel>();

excludedTypes.add(getComposedType("mySuborderType"));

 

StringBuilder queryString = new StringBuilder("SELECT {").append(OrderModel.PK).append("} ");

queryString.append("FROM {").append(OrderModel._TYPECODE).append("} ");

queryString.append("WHERE {").append(OrderModel.ITEMTYPE).append("} NOT IN (?excluded)");

 final FlexibleSearchQuery query = new FlexibleSearchQuery(queryString.toString(), Collections.singletonMap("excluded", excludedTypes));

   使用JOIN子句.这种方法是可行的,如果你不能传递参数,例如,因为你需要直接输入FlexibleSearch声明:  

     SELECT {o.PK} FROM {Order AS o JOIN ComposedType AS t ON {o.itemtype}={t.PK} } WHERE {t.code} NOT IN ('Foo','Bar')

 <conditions>

在可选的WHERE子句缩小匹配的数量通过指定相匹配的所有搜索结果的至少一个条件的<conditions>字段中的值。

避免空间搜索条件条款一定要避免空间的开始和结束搜索条件来看,随着因为= 'al' = 'al '是不相同的搜索条件,导致不同的搜索结果。

SELECT * FROM {Product} WHERE {code} LIKE '%al%'

使用常见的SQL布尔操作符(AND,OR)可以连接条件,如:

SELECT * FROM {Product} WHERE {code} LIKE '%al%' AND {code} LIKE '%15%'

使用IS NULL操作员发现,没有价值的所有条目:

SELECT * FROM {Product} WHERE {code} IS NULL

使用SQL布尔运算符NOT否定的情况是可能的:

SELECT * FROM {Product} WHERE {code} NOT LIKE '%al%'

它有可能组合否定和连接条件:

SELECT * FROM {Product} WHERE {code} LIKE '%al%' AND {code} NOT LIKE '%15%'

否定IS NULL运算符是不为空:

SELECT * FROM {Product} WHERE {code} IS NOT NULL

WHERE子句还允许子选择使用双花括号({{and}}),如:

SELECT {cat:pk} FROM {Category AS cat} WHERE NOT EXISTS (

   {{ SELECT * FROM {CategoryCategoryRelation} WHERE {target}={cat:pk} }} /* Sub-select */

)

<order> 

FlexibleSearch符合SQL语法的排序方面。通过在ORDER指定属性BY子句,搜索结果列表是按照指定类型分类的。此外,可以选择指定ASC以升序排列搜索结果进行排序(NULL,0到9,A到Z)或DESC来(通过0到A,9 Z,NULL)降序排列搜索结果进行排序。 ASC和DESC是相互排斥的,ASC是默认的。例如:

下面FlexibleSearch查询按照code数据库列的值,按降序排列的搜索结果:

SELECT {code},{pk} FROM  {Product} ORDER BY {code} DESC

下面FlexibleSearch查询按照代码数据库列的值的搜索结果,按升序排列:(ASC是默认顺序):

SELECT {code},{pk} FROM  {Product} ORDER BY {code}

参数

一个FlexibleSearch查询包含可选参数,标有前缀问号。参数,使您能够传递值到FlexibleSearch查询。例如,在下面的代码片段,参数Product可用于传递一个搜索模式:

SELECT {p:pk} FROM {Product AS p} WHERE {p:code} LIKE ?product

下面FlexibleSearch查询有两个参数,的startDate和结束日期:

SELECT {pk} FROM {Product} WHERE {modifiedtime} >= ?startDate AND {modifiedtime} <=?endDate

使用使用的hybris Commerce Suite的API的FlexibleSearch

用使用的hybris商务套件的API FlexibleSearch查询发生在两个步骤,这两者都可以在一个Java的语句来完成:
设置查询
  运行查询

构建FlexibleSearch查询

一个FlexibleSearch查询被构造为包含该查询,例如字符串:

final String query = "SELECT {pk} FROM {Product}"// Flexible search service injected by Springfinal SearchResult<ProductModel> searchResult = flexibleSearchService.search(query);

到指在FlexibleSearch查询的hybris Commerce Suite的类型属性,如一个项目的主键(PK),需要构建查询时引用的属性。在情况下,属性是毫不含糊清晰,明确的属性就足以。静止,建议以引用属性的类型,以及用于消歧。采用hybris Commerce Suite的解析,并自动转换属性引用到FlexibleSearch查询:

例如:

final String query = "SELECT {" + ProductModel.PK + "} FROM {" + ProductModel._TYPECODE + "}";

String query =

   "SELECT {p:" + ProductModel.PK + "} FROM {" + ProductModel._TYPECODE + " AS p}\n"+

   "WHERE {" + ProductModel.VARIANTTYPE + "} IS NOT NULL"

调用FlexibleSearch

要调用使用API使用flexibleSearchService,这始终是可以通过Spring和必须正确注射到你的服务如下:一个 FlexibleSearch声明:

<bean id="myFancyService" class="de.hybris.platform.foobar.MyFancyService" >

  <property name="flexibleSearchService" ref="flexibleSearchService"/></bean>

public class MyFancyService implements FancyService{

...

  private FlexibleSearchService flexibleSearchService;

 

  @Required

  public void setFlexibleSearchService(final FlexibleSearchService flexibleSearchService)

  {

    this.flexibleSearchService = flexibleSearchService;

  }

...

}

flexibleSearchService.search(...)方法返回一个de.hybris.platform.servicelayer.search.SearchResult实例,它持有的单个搜索结果列表。要访问此列表,调用更多搜索类getResult()方法,如:

final String query = "SELECT {" + ProductModel.PK + "} FROM {" + ProductModel._TYPECODE + "}";final SearchResult<ProductModel> searchResult = flexibleSearchService.search(query);List<ProductModel> result = searchResult.getResult();

后,您可以像处理任何其他Collection情况下,这Collection实例:

Final String query = "select {" + ProductModel.PK + "} FROM {" + ProductModel._TYPECODE + "}";final SearchResult<ProductModel> searchResult = flexibleSearchService.search(query);final ProductModel product = searchResult.getResult().iterator().next();

慎重
通过SearchResult.getResult()返回的集合使用懒翻译方法。在第一次访问的集合元素,该元素被转换为一个项目。
如果该项目已收集的搜索结果和特定元素的翻译之间取出,返回的集合有在这个位置空值。

传递参数

传递参数,创建一个Map实例持有的参数,并通过Map search(...)方法,如:

final Map<String, Object> params = new HashMap<String, Object>();

 

String query ="SELECT {" + PriceRowModel.PK + "} FROM {" + PriceRowModel._TYPECODE "} "+"WHERE {" + PriceRowModel.PRODUCT      + "} = ?product AND "+

      "{" + PriceRowModel.NET          + "} = ?net AND "+

      "{" + PriceRowModel.CURRENCY     + "} = ?currency AND "+

      "{" + PriceRowModel.UNIT         + "} = ?unit AND "+

      "{" + PriceRowModel.UNIT_FACTOR  + "} = ?unitfactor AND "+

      "{" + PriceRowModel.UG           + "} = ?userpricegroup AND "+

      "{" + PriceRowModel.MIN_QUANTITY + "} = ?minquantity AND "+

      "{" + PriceRowModel.PRICE        + "} = ?price ";

 params.put("product",         product);params.put("net",         priceCopy.isNet());params.put("currency",        priceCopy.getCurrency());params.put("unit",        priceCopy.getUnit());params.put("unitfactor",  priceCopy.getUnitFactor());params.put("userpricegroup",  priceCopy.getUserPriceGroup());params.put("minquantity",     priceCopy.getMinQuantity());params.put("price",       priceCopy.getPriceValue());

 

final SearchResult<PriceRowModel> searchResult = flexibleSearchService.search(query, params);

搜索结果的实例化

如果你只检索PKS数据库列(也就是采用hybris CommerceS SuiteSSS项目只有PKsS),并提供了一种类型的作为一个Java类,你可以立即施放的PKs表示为实际的模型实例模型。换言之,执行以下代码返回CatalogModel实例,PKs的不是Collection的Collection:

final String query = "SELECT {" + CatalogModel.PK + "} FROM {" + CatalogModel._TYPECODE + "} ORDER BY {" + CatalogModel.PK + "} ASC";

final SearchResult<CatalogModel> searchResult = flexibleSearchService.search(query);

如果检索多个数据库列,您会收到结果每排几个单独的条目,你将不能够施展的搜索结果到项实例直接,没有就算检索的数据库列之一就是PK列。

使用的hybris管理控制台FlexibleSearch
    触发的hybris管理控制台内FlexibleSearch查询可以有两种方法:使用SavedQuery实例和使用ViewType实例。一个ViewType实例是一个数据库视图的采用hybris Commerce Suite的代表性。一个SavedQuery实例使用FlexibleSearch查询检索采用hybris Commerce Suite的项目,而不是使用GenericSearch的一种手段。在HMC的ViewType表示称为报表定义。该SavedQuery实例是HMC仅表示,它必须指定一个与resultType和仅适用于与resultType并与resultType亚型搜索。它适用于所有类型的电子商务的hybris套房。

Creating a SavedQuery

Go to Managing SavedQuery Items in the hybris Management Console document, section Creating a SavedQuery, for details on how to create aSavedQuery using the hybris Management Console (hMC).

Using a SavedQuery

Go to Managing SavedQuery Items in the hybris Management Console document, section Using a SavedQuery, for details on how to call aSavedQuery using the hMC.

Creating a Report Definition

Go to the Creating Report Definitions Using the hybris Management Console document for details on how to create a Report Definition using the hMC.

Hints 

Paging of Search Results 

Some FlexibleSearch queries run the risk of returning a very large number of search results, such asSELECT * FROM {Products} WHERE {code} LIKE ?search OR {name} LIKE ?search , where?search is a parameter from a text field. Managing more than some 50 or 100 search results in one single Collection is complicated and performs comparably slow. For this reason, the FlexibleSearch framework offers a paging mechanism.

To use this paging mechanism, use thesearch(...) method withFlexibleSearchQuery object as parameter. You have to set onFlexibleSearchQuery thesetNeedTotal totrue . If this parameter is set totrue , the FlexibleSearch framework splits the number of returned search results into pages. Using thestart andrange parameters, you can retrieve pages of search results. The following code snippet, for example, iterates over all the search results of the FlexibleSearch query, three at a time:

 

int start = 0;final int range = 3;int total;

 

String query = "SELECT {" + UnitModel.PK + "} FROM {"+ UnitModel._TYPECODE + "} ORDER BY " + UnitModel._TYPECODE;final FlexibleSearchQuery fQuery = new FlexibleSearchQuery(query);

fQuery.setCount(range);

fQuery.setNeedTotal(true);

 do

{

  fQuery.setStart(start);

  final SearchResult<LanguageModel> searchResult = flexibleSearchService.search(fQuery);

  total = searchResult.getTotalCount();

  start += range;

}while(start < total);

 

Be aware that every navigation, either backward or forward, through a paged search result triggers a new search query on the database. Internally, the FlexibleSearch runs the query in full and uses an offset parameter to specify the portion of all search results to return. The fact that every navigation causes a database query has three major consequences:

Complex queries cause heavy load on the database:
Executing a simpleSELECT statement is rather fast, even with millions of search results. However, if your FlexibleSearch query requiresJOIN  orUNION to execute, load on the database (and, by consequence, response times) increases rapidly. As a rule of thumb, remember that the more different items are involved, the longer the execution time is. For example, the following table gives some short examples of some rather basic FlexibleSearch statements and the actual SQL queries triggered:

 

 

更改历史

 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值