Say you want to create a page View to display an individual Solr record. Here is a rough list of the steps to do that:
1. Create a new View using your Sarnia index as the type.
2. Set it to display only one record.
3. Add the Solr fields you want to display.
4. Set the page's URL to something like "sarnia/sarnia-index-name/%"
5. Add a contextual filter which filters based on the ID field. This will be unique integer field that you picked during the Sarnia server setup.
Now you probably want to display some Solr field as the page title. You can do this in the settings for the contextual filter. The problem is that you get a limited list of options for the field you can display instead of the ID field. Go look at the settings for your Sarnia server in the Search API admin page. Click on the Sarnia tab and then the Solr properties local task. That list of options in the Views contextual filter contains all of the fields with "filter" in the Uses column of the Solr properties page.
What I would like is to see all of the fields with "display" in the Uses column. After all, I'm going to display this field. Plus, if you set up this View after following the instructions for setting up a trial Sarnia server including indexed content from ApacheSolr, you'll note that the label field is not in the list of "filter" fields. That means if you're querying an index of nodes, you currently can't display their titles as the title in Views.
I've attached a patch which makes the change to "display" fields.
| Comment | File | Size | Author |
|---|---|---|---|
| sarnia-views-title-options.patch | 807 bytes | dcam |
Comments
Comment #1
dcam commentedBy the way, if you're committing a patch then Drupal.org will provide you with a recommended commit message if you expand the "Credit & committing" fieldset just above the comment Save buttons. It will automatically include the names of patch authors in the commit message so they get credit. You can add more - for example if someone did a great review of the patch - by checking their name above the sample message.
I mention this because no one got credit for the patches in all of those other issues that recently got committed. I'm pretty sure you can't go back and add them after the fact either. That tends to make patch authors angry and not want to contribute anymore.
Comment #2
jmdeleon commentedRegarding the commit messages: My apologies for not properly crediting folks, as that was an effect of having to integrate an accumulation of almost three years worth of work. It certainly wasn't my intention to take all the credit for myself (though most of the most recent patches were mine). I'll try not to make that error again.
Comment #3
jmdeleon commentedTrying this patch here... what are the steps to reproduce the behavior you are suggesting?
Comment #4
dcam commentedExpected behavior:
The options of the select element should be a list of the fields marked for "display" in the Search API -> Sarnia Solr server -> Sarnia tab -> Solr properties local task.
Actual behavior:
The options of the select element are a list of fields marked as "filter" in the aforementioned page.
*That's a really terrible name for what this configuration option does and it should probably be changed too.
Comment #5
jmdeleon commentedTested this patch... I've not had the specific use-case in my projects where this was needed, but I can see the utility for this.
Comment #7
dcam commentedCool, thank you. It was confusing and annoying to not be able to use the 'label' Solr property as the page title.
Comment #8
jmdeleon commented