I have a data stored with my preferred colour in DB as : red,yellow,black..... suppose 20 colours, Now whenever I search using SOLR I want my results to be boosted on basis of my preferred colour? how can we do this.... I tried map function of SOLR but for so many preferred colours my solr url length increases considerably. is there any easier way to do that?
Asked
Active
Viewed 96 times
1 Answers
0
Split the value into separate tokens or pre-process it to a multi valued field, then use a boost query to boost any results that match your query.
You can use a PatternTokenizer to split the field into separate tokens:
<fieldType name="text_color" class="solr.TextField" positionIncrementGap="100">
<analyzer>
<tokenizer class="solr.PatternTokenizerFactory" pattern="," />
</analyzer>
</fieldType>
<field name="color" type="text_color" indexed="true" stored="true" />
.. and the boost it in your query, using (e)dismax:
&bq=color:red^10

MatsLindh
- 49,529
- 4
- 53
- 84
-
Thanks for the solution. Just need to add some thing I have made the field as a multivalued field i.e now i have colors as multivalued. In this case I have a dependency for example I want to boost my results with cases for example only if my title is an exact phrase as **"RED APPLES"** and color is red than only provide the boost is it possible using AND in bq – Nishkarsh Dixit Jan 03 '18 at 08:38
-
Yes. The boost query is a regular query, so `field:"RED APPLES" AND color:red` should work. – MatsLindh Jan 03 '18 at 08:55