0
votes

I have 2 multivalued fields in my product doc :-

  1. Features
  2. Features_Score

Features field (type: string) has multiple features for the product. Each feature has a string value. Features_Score (type : integer) is a parallel multivalued field containing the score of the corresponding feature.

Obviously, both the fields would have same no. of entries

Now I want to query solr like this :-

Give me all those products (solr docs) where feature:'durability' AND features_score > '10'.

I want this query to return all products with features durability and durability feature for that product should have score above 10.

But, this won't return the expected results as there is no mapping (at indexing level) between features and features_score field.

How should I implement this? Is there any in-built support in Solr to do this?

1

1 Answers

2
votes

This can be achieved by having dynamic fields defined.

You would need to modify the schema to have field with {feature name}_feature as dynamic field name and score as its value.
This will help you map the feature with its score.

e.g.

durability_feature=11

Schema.xml

<dynamicField name="*_feature"  type="int"  indexed="true"  stored="true"/>

So you can input data as durability_feature with the respective feature score.

The filter queries will be able to match the exact mappings fq=durability_feature > 10