Reputation: 77
Not sure if I can achieve this
I have the below documents in the index
{
"name": "nissan",
"type": "product",
"features":["build_100",
"stability_80"]
}
{
"name": "toyota",
"type": "product",
"features":["stability_100",
"design_30"]
}
{
"name": "Audi",
"type": "product",
"features":["build_70",
"design_100"]
}
For a search of build in the features field "design" I get doc 2 and 3 back from recall and my question is that is there a way I could sort/rank the documents based on the number after the "_", so that in the above case I would get doc3 first and then doc 2?
If this can be achieved by changing the document structure then that is also fine with me.
Upvotes: 1
Views: 206
Reputation: 52912
Index them as independent fields and make sure to enable docValues on them (enabled by default on recent version of Solr).
<dynamicField name="features_*" type="int" indexed="true" stored="true"/>
You then index each feature as a separate field:
"feature_design": 100,
"feature_build": 70,
and so on. Sorting by the field can then be done in the same was you'd sort on any other field (sort=feature_design
).
Upvotes: 1