0

Our Spring Java website's MySql database has got the following tables

  • CUSTOMER
  • PRODUCT
  • PRODUCT_CUSTOMER_XREF (Customers who bought a product)
  • CUSTOMER_CUSTOMER_XREF (Customers who are friends with other customer)

in SOLR we've indexed all PRODUCTS which have a unique id which is PRODUCT_ID.

My job

  • Display PRODUCTS current logged in CUSTOMER's friends bought in the past.
  • Let customer search for product descriptions and product reviews of Customers friends done in that past

Steps I used

  • SQL Query Get friends of current logged in CUSTOMER ( returns 500 CUSTOMERS)
  • JOIN SQL QUERY Get the PRODUCT(s) purchased by every friend CUSTOMER (returns 98,000 PRODUCTS_ID). This could possibly return 500,000
  • SOLR query id:(1 2 3 4 5 ....98000) returns maxBooleanClause exception.
  • MySQL Query - Get friends of Customer who bought or commented on the returns Product ids.

Problem - solr query

  • I cannot query for 98,000+ products in SOLR because this return maxBooleanClause exception. I can increase the maxBoolean in solr-config.xml file but this seems like a bad practice consider this number be in 100 of thousands.
  • I can add 98,000+ queries for the same field but this sounds like a bad practice aswell.
  • Costly to send 98,000+ ids to SOLR server over HTTP post.

Can someone please help me with a solution ?

Additional Note:I was thinking if there is a way I can group all CUSTOMER_IDs who bought or commented on a particular product into 1 number or token or some sort and then check if the logged in CUSTOMER's ID friends IDs belong to that group. But haven't figured out a formula yet.

4

2 回答 2

2

我会尝试这样的事情......

Solr指数

  • ID
  • 姓名
  • 朋友们
  • 产品_已购买

产品

  • ID
  • 标题

    1. 第一个查询 -fq=friends:id&facet.field=Products_Purchased
    2. 这会将结果限制为只有人,用户是朋友
    3. 购买产品的方面也是按产品数量排序
    4. 这也将确保您拥有产品的唯一 ID。

    5. 第二个查询 - 我会使用这些 Id 来查询 solr,可能在 20-50 的批次中,最多带有分页。

    6. 分页对构面也有效,因此您可以导航结果。
于 2013-06-04T04:07:00.623 回答
1

也许您可以将其拆分为几个请求,这比一次请求检索所有项目要好。

但我可能会更好地切换到另一种方法:)

您也可以将购买此商品的客户存储在 Solr 中。

因此,您的计划将更改为:

SQL 查询获取当前登录客户的朋友(返回 500 个客户) SOLR 查询客户:(1 2 3 4 5 ....500)与搜索请求。

这需要您在某些客户购买或评论项目时更新 Solr,但您在 READ 阶段获胜。例如 solr 查询更简单,您不需要提出加入请求。

于 2013-07-02T15:44:14.003 回答