Reputation: 662
I'm new to Solr and I'm wondering if the next example is possible.
Let's say I have a core with 2 fields, a string field 'name' and a multiValued field 'ids'. With doc 1:
and doc 2:
Now I want a query that gives me a result array with the following elements:
So the query returns each document per value in the multiValue field, first sorted on the value in 'ids' and second sorted on the name.
You could say, just select all the documents and handle the other stuff after the query, but I have a lot of data and I only want the first 20 documents sorted and per value in the multiValued field.
I hope this is possible and someone can help me! Thanks in advance.
Upvotes: 1
Views: 294
Reputation: 52799
If you want the documents to be returned multiple times and sort on both the fields, you have the insert individual records for each combination.
This is a lot of duplication of data and but presume thats the only way you can achieve it.
You could have used Grouping feature, however it does not work on Multivalued fields.
Upvotes: 0
Reputation: 1802
I don't know much about solr but
i think through SolrPhpClient you can do like this:
$arr1 = explode(":","Name: Tim");
$arr2 = explode(":","Ids: 1,2,3");
$arr2 = explode(",",$arr2[1]);
for($i=0;$i<$arr2.length;$i++){
array_push( $arr3 ,array( $arr2[i] ,arr1[1] ) );
}
do same for second
and by array_merge and sort u can get desired result.
Upvotes: 0