-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow facet level sorting #300
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@whikloj as always, thanks for this. You are way more concrete and faster than me. I would just ask for some minor corrections:
Travis is failing because of some minor coding standard issues
See: https://travis-ci.org/Islandora/islandora_solr_search/jobs/184075282#L455-L457
It passes other tests because, as we all already known, in many modules and versions codesniffer is simply not running.
includes/results.inc
Outdated
@@ -854,6 +854,17 @@ class IslandoraSolrFacets { | |||
} | |||
|
|||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing short description of the function here
includes/results.inc
Outdated
@@ -854,6 +854,17 @@ class IslandoraSolrFacets { | |||
} | |||
|
|||
/** | |||
* | |||
* @return mixed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems like codeSniffer is expecting a comment after/partof @return statement? Kinda new for me, or i'm just getting old.
@DiegoPino Oops, I made that function and then never used it. I have removed it, that should remove those errors. |
@whikloj thanks. Will test and should be ready to merge by today. =) |
@whikloj will wait until we reach the 24hr mark. I'm fine with this by the way 😃 |
includes/results.inc
Outdated
} | ||
|
||
if (isset($this->settings['solr_field_settings']['sort_by']) && $this->settings['solr_field_settings']['sort_by'] == 'index') { | ||
ksort($buckets); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running this way... this would return the top number of results by count, ordered by value; while, it may be expected that it gives the top values (how I first read it, anyway). For example, say you're limiting the number of values returned, and by numbers, would only get things near the bottom of things lexicographically... Could end up with strange results.
May have to go jam things into the $params_array
... Untested, but thinking something like:
$facet_array = islandora_solr_get_fields('facet_fields', TRUE, FALSE);
[...]
$params_array = array(
'facet' => 'true',
'facet.mincount' => variable_get('islandora_solr_facet_min_limit', '2'),
'facet.limit' => variable_get('islandora_solr_facet_max_limit', '20'),
'facet.field' => explode(',', $facet_fields),
);
foreach ($facet_array as $field => $info) {
$settings = $info['solr_field_settings'];
if (($settings['sort_by'] == 'count' && $params_array['facet.limit'] < 0) ||
($settings['sort_by'] == 'index' && $params_array['facet.limit'] > 0)) {
// Avoid specifying default behaviour:
// @see https://wiki.apache.org/solr/SimpleFacetParameters#facet.sort
// "The default is count if facet.limit is greater than 0, index otherwise."
$params_array["facet.{$field}.sort"] = $settings['sort_by'];
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adam-vessey I did that, but the problem was that you then still have to sort it this way as (for example) sorting by content model in solr you are sorting
islandora:compoundCModel
islandora:bookCModel
islandora:pageCModel
but then in Islandora you see the transformed text but still sorted based on the old text values.
I can go do what you are suggesting, but we still need to sort here to account for the later transformations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adam-vessey Just re-reading your comments
For example, say you're limiting the number of values returned, and by numbers, would only get things near the bottom of things lexicographically... Could end up with strange results.
This is totally true, but all I am providing is a way to re-order the facets you have from by count to by value. I was trying not to sell this as anything more than adjusting the sort order of your existing facets.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just trying to avoid confusion... The JIRA ticket indicates:
This would implement facet.sort ...
... which is not happening here... Should this be a distinct ticket?
Also, I feel that there may be mixups between the two... Could expand on the description beside the option, to be more explicit in the difference.
... Dealing with the transformations... I'm not sure there's any clean way to do it generally... Almost feeling like it may be more reliably done with something concatenating things together into a purpose-built field in the index... something like the text to display/the:pid
, and having something strip off the /the:pid
bit when displaying (some arbitrary separator could be used instead of a forward-slash... just using it here as an example)... Dunno...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adam-vessey Oops, that is my mistake. I did try that until I ran in issue of sorting by one value then displaying a different one (ie. replace with object label). I'll update the ticket with the issue I had with that method.
I'll also work on some more descriptive wording for the options (maybe switch to radio buttons).
As for transformations, I see what you are suggesting. Which isn't a bad idea, but would require a wholesale change to the way facets are created...I think. If not, I'm open to it. But I might need a little direction.
@adam-vessey @whikloj are we OK with this one? Would love to see this in the new release (as a new feature). Thanks |
@DiegoPino, @whikloj: Were it described as a feature separate from ISLANDORA-1337 (as in, a separate ticket entirely)... I think it would be fine? The original discussion (linked from ISLANDORA-1337) regarded ordering dates/years, which could end up with holes as described above with "strange results". ... Also, thinking we should be more explicit about what this new ticket does... As if/when ISLANDORA-1337 is actually implemented using |
@adam-vessey Those are fair points... I can see a clear path to using facet.sort with dates and numbers. Its just handling the renderText which changes the text value we sorted on to the object label. That could cause you to get odd results. But I'll move back to that attempt and perhaps you can help me solve any issues that arise. @DiegoPino I'm not sure this will be complete for code freeze, but I'll see what I can do. |
@whikloj no worries. Thanks for taking care of this. @adam-vessey thanks for the reviews. Even if not ready for code freeze, i really appreciate the work implied 😄 |
includes/query_processor.inc
Outdated
@@ -236,6 +236,19 @@ class IslandoraSolrQueryProcessor { | |||
$params_array = array_merge($params_array, $params_date_facets); | |||
} | |||
|
|||
// Determine the default facet sort order. | |||
// https://cwiki.apache.org/confluence/display/solr/Faceting#Faceting-Thefacet.sortParameter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 240 is giving "Line exceeds 80 characters; contains 96 characters". Since It's a link, so not sure how you want to split that into 2 lines.
@whikloj give me ping when you feel you are ready for another review. Thanks! |
Sorry for the delay, so this seems to work. But again if you add (for example) the content model and replace the entry with the object label, then the order will be wrong again. Not sure there is a simple solution to that problem...so I think this is a handy feature so long as you are aware of that. |
bump |
@whikloj i got confused by your comment, sorry. how do we make people aware of the limitations? is that another ticket? |
@DiegoPino I'm not sure what the best way to handle that would be. Perhaps just a warning that if you use this sort on a field that you have already enabled "Replace PID with Object Label" then the sort order will not work. But I'm not really sure. |
@whikloj I feel that what you suggest there is fine, a warning/little comment on the UI side should be enough. No rush on this. I'm not the best at wording stuff, so feel free to suggest/commit and we can ask @manez or @adam-vessey to review? |
@whikloj this just needs that last piece of wording and we should be ready to merge. Thanks |
@DiegoPino I stuck that under the radio buttons on the facet configuration... I think that is probably the best place for it. |
bump |
@whikloj oh... i had forgotten about this. I will merge now. This was checked and tested, and wording was Ok for me. |
JIRA Ticket: https://jira.duraspace.org/browse/ISLANDORA-1337
https://groups.google.com/forum/#!topic/islandora/-sO_VrHBIQg
What does this Pull Request do?
Add a configuration option to facets to allow you to change the sort order from by count to by labels.
What's new?
New
solr_field_settings
parametersort_by
with either count or index (count is default).How should this be tested?
Counts
.Labels
. Save settings.Example:
Interested parties
@DiegoPino (as he was working Islandora-1337)