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.

CommentFileSizeAuthor
sarnia-views-title-options.patch807 bytesdcam

Comments

dcam’s picture

Status: Active » Needs review

By 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.

jmdeleon’s picture

Regarding 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.

jmdeleon’s picture

Trying this patch here... what are the steps to reproduce the behavior you are suggesting?

dcam’s picture

  1. Create a View to display a single Solr record as described in this comment. Use a contextual filter to get a single result based on the record's unique ID.
  2. In the contextual filter's modal form, inside the "WHEN THE FILTER VALUE IS IN THE URL OR A DEFAULT IS PROVIDED" fieldset there will be a form autocomplete-select element labeled "Argument name solr property"*. It will only show up if the contextual filter is filtering based on the [Sarnia index name]: Id field. The element contains a list of Solr properties that can be substituted for the View's title instead of the unique ID.

Expected 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.

jmdeleon’s picture

Tested 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.

  • jmdeleon committed fc673b9 on 7.x-1.x authored by dcam
    Issue #2491811 by dcam: Use display fields as options in Views...
dcam’s picture

Status: Needs review » Fixed

Cool, thank you. It was confusing and annoying to not be able to use the 'label' Solr property as the page title.

jmdeleon’s picture

Status: Fixed » Closed (fixed)