0

Currently working on a project that moving our search functionality from traditional SQL like queries to Solr. Everything is ok except one!

It's a similar e-commerce application that products have multiple categories, not single. Also each product has a value which represents their ordering index for each category. For instance, product-A is in the first place for category-X but third place for category-Y.

So that, when you want to list category-X or category-Y, products should be listed for their own orders.

In short, a bag may be listed in a men category or a leather category. For the man category it should be listed maybe 50th index, but for leather it should be listed maybe 8th index.

I tried different approaches in order to fetch results which depends on query input. I tried multiple cores but It does not work. In SQL it's easy that to do kind of things, just add sorting table join to main table; but solr side, things are not going well as I expected.

  • SQL --> MYSQL
  • Language --> Java8
  • Solr --> 8.5.X
Tugrul
  • 1,760
  • 4
  • 24
  • 39
  • What input do you have that you want to use for sorting? Usually dynamic fields (with docValues enabled) works fine for category specific sorting. – MatsLindh Jun 15 '20 at 08:23
  • Hello @MatsLindh, How to I use dynamic fields, is it compatible with MYSQL? I searched for details a little bit if you have a best practice example, share with me pls. – Tugrul Jun 15 '20 at 12:23
  • Yes, that doesn't matter. The important thing is that you use the part you want to sorting for your field name, so you have fields like `sort_order_category_y` and `sort_order_category_x` with the values you'd like to order by. – MatsLindh Jun 15 '20 at 12:49
  • How can I pass parameter sort_order_category_{my_param} as like that in data import query? And one note that, would you write your response below, I'd like to mark as approved If it's solved. – Tugrul Jun 15 '20 at 14:52
  • That depends on how you're getting the values now - you can generate the field names in SQL or use something like a script transformer: https://stackoverflow.com/questions/7917317/dynamic-column-names-using-dih-dataimporthandler – MatsLindh Jun 15 '20 at 18:53

0 Answers0