what is the best practice to implement SOLR in Ecom applications?

时光怂恿深爱的人放手 提交于 2019-12-04 12:30:19

One good case practice I encountered while developing e-commerce solution and SOLR as the search provider is to retrieve from SOLR only the IDs and get the data from SQL server.

I created a single schema that was updating every time some new products were added in the database.(In my case products were added by a user in an admin console, in your case you can use the @Mauricio Scheffer comment to have latest updates)

One field in the schema was the ID - representing the ID of the product in the database. After querying SOLR I was receiving N documents suiting the query and with the ID field I was getting all the information from my database and display it to the user.

So the good part is that the user will always get the data from your database ( real time data), and will have his search results displayed very fast because of SOLR.

You can add to the schema different fields that you can use to filter your results such as

  • category
  • date
  • price
  • size
  • etc...

And also differnet fields that you need to query upon:

  • headline
  • description
  • name
  • etc...

And also add the product ID.

So after making the query to SOLR you have a list of product IDs, now the only thing you need to do is to implement a function that will get the products from database based on the ID and display it on the search results page.

This approach performance is pretty good because selecting from database elements based on primary key is the fastest way to retrieve data from sql.

I worked on a website with 1.000.000 products and searching time was always under 0.2 seconds and page loading time in the browser was under 0.6 seconds on single user queries. ( the server where SOLR and SQL was running was 8Gb ram and quad core 1.8 gb as I remember)

Hope this type of implementation is useful for you.

You can set up a database trigger or data access layer event to send data to Solr whenever there's a change, and configure autoCommit to control freshness.

See also:

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!