Skip to content
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

Highlights from Solr & Alternative Fields for display #3

Merged
merged 4 commits into from
Apr 27, 2015

Conversation

almohsin
Copy link
Contributor

Alternative Fields

alternative_field' can be added to result_display so that it is used if the specified 'field' does not exist.

e.g. assume we are displaying the 'title' of the results but for those results with no title, we would like to display the file name instead:

result_display: [
                    [
                        {
                            "pre": "<h4>",
                            "field": "title",
                            "alternative_field": "file_name",
                            "post": "</h4>"
                        }
                    ]
                ]

Highlightings from Solr

First, you should specify the following facetview options:

{
    solr_doc_id: "id",
    highlight_fields: ["text"],            // you can specify more than one
    highlight_pre: "<mark>",
    highlight_post: "</mark>"
}

Then, you can display the highlightings by adding them to result_display. Check out this example:

result_display: [
                    [
                        {
                            pre: "<a target='_blank' href='",
                            field: "url",
                            post: "'>"

                        },
                        {
                            pre: "<h4>",
                            field: "title",
                            post: "</h4></a>"
                        },
                    ],
                    [
                        {
                            pre: "<span class='text_highlightings'>",
                            highlight_field: "text",
                            post: "</span>"
                        }
                    ]
                ]

@almohsin almohsin changed the title Highlights from solr Highlights from Solr & Alternative Fields for display Apr 25, 2015
@darth-pr
Copy link
Owner

Thanks this is great!

darth-pr added a commit that referenced this pull request Apr 27, 2015
Highlights from Solr & Alternative Fields for display
@darth-pr darth-pr merged commit 792642a into darth-pr:master Apr 27, 2015
@almohsin almohsin deleted the highlights-from-solr branch May 5, 2015 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants