1

Is there a way to boost documents by the number of values in a particular multi-valued field - at query time? i.e. More the number of values, more the boost.

Is there something like bf="count(pets)^5.0" - where pets is a multivalued field?

I am aware I can store the count at index time and use a value boost using bf="number_of_pets^5.0" when querying. However, I am trying to find a query time solution for this, so that I can avoid modifying the schema (and re-indexing everything) just for achieving this.

techfoobar
  • 65,616
  • 14
  • 114
  • 135
  • You mean if i have 3 docs - (id=1, color=red; id=2, color=red,blue; id=3,color=black, red) and then you want to query this docs, so they come id2, id3, id1? even if you query *:*. Did i understand you correctly? – Mysterion Apr 02 '14 at 06:43
  • Exactly more number of values in a multi-valued field, more the boost. Since docs #2 and #3 have more values in the field color, they come before doc#1. That is correct. Is there any built-in way for achieving this? – techfoobar Apr 02 '14 at 06:51
  • 1
    So far, I have no idea how to do it in a built-in way. As a possible solution - use bf with custom written function query `count` – Mysterion Apr 02 '14 at 06:53

1 Answers1

2

This has already been asked multiple times before. Looks like a wanted feature!

Looking at the wiki I couldn't see any functions related to multivalue field so I think it is safe to assume that nothing has changed since after these answers were provided.

Community
  • 1
  • 1
mindas
  • 26,463
  • 15
  • 97
  • 154
  • Thank you for your answer. I did search before posting but somehow couldn't find this one! I ended up indexing the count separately (something I wanted to avoid originally). Anyway, thank you. – techfoobar Apr 10 '14 at 09:37
  • 1
    You could look at [CountFieldValuesUpdateProcessorFactory](http://lucene.apache.org/solr/4_1_0/solr-core/org/apache/solr/update/processor/CountFieldValuesUpdateProcessorFactory.html) which can do the trick, however I understand this will still require reindexing and is only for Solr 4.1. – mindas Apr 10 '14 at 09:39