šljaker
šljaker

Reputation: 7374

SOLR 1.4 - sort by flag

I'm using SOLR 1.4. In search index I store products and categories. Each product may have multiple categories. Category should affect document's score.

e.g.

Category 1 (flag 8)
Category 2 (flag 4)
Category 3 (flag 2)
Category 4 (flag 1)


Product A: Category 1 + Category 2
Product B: Category 1 + Category 3 + Category 4

In this case, Product A should have the higher score than product B: 8 + 4 > 8 + 2 + 1

How can I implement this in SOLR 1.4? Any help would be greatly appreciated!

Upvotes: 0

Views: 192

Answers (1)

javanna
javanna

Reputation: 60215

If you don't care too much about relevance, like you said in your comments, I'd suggest you to use sorting and avoid trying to influence the solr score. You can add a field containing the sum of the flags related to the categories of the document, then sort using that field.

As you have pointed out you cannot use sort by function with solr 1.4, but it's useful to mention that if you upgrade to 3.x you could have a multivalued field containing the list of flags and compute the sum through a function, using it for sorting.

In both cases, for documents with same flag sum and same title you'll be looking at the solr score, which isn't that important for you.

Upvotes: 1

Related Questions