简体   繁体   English

AEM 查找用例 - 设计讨论

[英]AEM Lookup Use Case - Design Discussion

Use Case用例

  1. I have an Excel in DAM which contains 10 columns predefined.我在 DAM 中有一个 Excel,其中包含 10 个预定义的列。
  2. Rows varying from 3000 to 10000. No PI SPI data involved today or in future.行从 3000 到 10000 不等。今天或将来不涉及 PI SPI 数据。
  3. We need to display results on page where end-user input search term matches the excel column A.我们需要在最终用户输入的搜索词与 excel A 列匹配的页面上显示结果。
  4. It could be more complicated as - Give me those rows where the user input exists in Column A + C + D.它可能更复杂,因为 - 给我那些用户输入存在于列 A + C + D 中的行。
  5. This search that way DOES NOT align to typical "Search" in AEM - optimized Search API, indexing, etc.这种搜索方式与 AEM 中的典型“搜索”不一致 - 优化搜索 API、索引等。

Design-1设计一

  1. Have a component for lookup.有一个用于查找的组件。
  2. Have a resource based servlet bound to component resource.将基于资源的 servlet 绑定到组件资源。
  3. Read entire excel server-side (servlet) and generate JSON.读取整个 excel 服务器端(servlet)并生成 JSON。
  4. Cache the entire JSON on dispatcher.在调度程序上缓存整个 JSON。
  5. For every upcoming request, JSOn is served from cache and invalidated on excel data publish.对于每个即将到来的请求,JSOn 从缓存中提供并在 excel 数据发布时失效。
  6. Let client side have entire JSON and implement the search logic to display relevant result.让客户端拥有整个 JSON 并实现搜索逻辑以显示相关结果。

Pros - Optimized and efficient - Lower hits on server, entire data (which is not huge) is loaded into In-Memory DOM for quick and intuitive return of search results.优点 - 优化和高效 - 在服务器上的点击率较低,整个数据(不是很大)被加载到内存 DOM 中,以便快速直观地返回搜索结果。

Cons - Search logic which is business logic is implemented client-side.缺点 - 作为业务逻辑的搜索逻辑是在客户端实现的。 In future if there's an Use Case that do something like JCR lookup with the values matched in excel, then it has to be done for entire dataset to return all such fields in JSON.将来,如果有一个用例使用 excel 中匹配的值执行类似 JCR 查找的操作,则必须对整个数据集执行此操作以返回 JSON 中的所有此类字段。

How does the In-Memory DOM know that the data has been refreshed in the backend? In-Memory DOM 怎么知道数据在后台刷新了呢? On publish, dispatcher will invalidate the JSON response but how will browser DOM know that and update itself?在发布时,调度程序将使 JSON 响应无效,但浏览器 DOM 如何知道并更新自身?

Design-2设计二

  1. Have a component for lookup.有一个用于查找的组件。
  2. Have a resource based servlet bound to component resource.将基于资源的 servlet 绑定到组件资源。
  3. Read entire excel server-side (servlet), implement search logic and generate results JSON.读取整个 excel 服务器端(servlet),实现搜索逻辑并生成结果 JSON。
  4. On dispatcher JSON gets cached with selector as search-term.在调度程序 JSON 上使用选择器作为搜索词进行缓存。
  5. If same request comes with same search term, then only cached result will be delivered, else the request hits the server (AEM Publisher).如果相同的请求带有相同的搜索词,则只会传送缓存的结果,否则请求会到达服务器 (AEM Publisher)。
  6. Front-end JS gets only the JSON for search result and simply displays it.前端JS只获取JSON作为搜索结果并简单显示。

Pros - Search logic which is business logic is implemented server-side.优点 - 作为业务逻辑的搜索逻辑是在服务器端实现的。 More secured.更有保障。 Data transformation logic resides server-side.数据转换逻辑驻留在服务器端。 Not huge volume of data in perspective.数据量不大。

Cons - Less efficient - More hits on server (cache contains json with search term as selector - so the search-term needs to match for the JSON to be returned from cache), page refresh on every search.缺点 - 效率较低 - 服务器上的点击率更高(缓存包含 json,搜索词作为选择器 - 因此搜索词需要匹配 JSON 才能从缓存中返回),每次搜索都会刷新页面。

Which Design would you prefer?您更喜欢哪种设计? Or do you have any other design in mind that would be better?或者您有其他更好的设计吗?

I would go for option A. Parsing an Excel file is expensive and can add a latency of 1-2 seconds ( No matter which Java Spreadsheet API you are going to use: Apache POI, etc. ).对于选项 A,我会选择 go。解析 Excel 文件的成本很高,并且会增加 1-2 秒的延迟(无论您将使用哪个 Java 电子表格 API:Apache POI 等)。

10K rows is not that many and can be loaded on the client side. 10K 行并不多,可以在客户端加载。

How does the In-Memory DOM know that the data has been refreshed in the backend? In-Memory DOM 怎么知道数据在后台刷新了呢? On publish, dispatcher will invalidate the JSON response but how will browser DOM know that and update itself?在发布时,调度程序将使 JSON 响应无效,但浏览器 DOM 如何知道并更新自身?

It depends on your implementation.这取决于您的实施。 You can fetch the spreadheet JSON every time user searches, or you can fetch it once and cache in DOM.您可以在每次用户搜索时获取电子表格 JSON,也可以获取一次并缓存在 DOM 中。 In the latter case the data will be live until refresh.在后一种情况下,数据将一直存在直到刷新。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM