Skip to content

A javascript library to help you create a GUI frontend for Solr

License

Notifications You must be signed in to change notification settings

mamort/serendip

Repository files navigation

Note: Currently incomplete

************************************************************************************
* Introduction                                                      
************************************************************************************

Serendip is a javascript library that is intended to make it easier to create a GUI frontend
using the search engine Solr. 

The purpose of the Serendip library is to make it easy to display search results generated by
Solr. In the simplest scenario you just need to edit the configuration options:
 
js/config/serendip.config.main.js
js/config/serendip.theme.config.js files 

And also, of course, configure your Solr search engine correctly.

It is likely many will want to change the search appearance to fit their own needs. There are 
basically three ways to do it depending on the flexibility you want. The easiest way is to just change 
the serendip.css file adding or changing the styles you want. If you want or need to change the html 
that is output you can change the html prototypes that are specified in the search.html file. 

************************************************************************************
* Features                                                   
************************************************************************************
- All JSON parsing taking care of. Just change the HTML prototypes specified in the search.html file

- All search, sorting, paging and filtering is done async without reloading the page.

- All search, sorting, paging and filtering events are saved in the browser history.
    - This means that:
      - Browser back and forward buttons work as expected.
      - Copying the URL into a new window will give you the exact same results along 
        with the sorting, paging and filtering parameters.
      - Allows you to bookmark any result.

- Sort results ascending/descending based on Solr fields. Possible to display/use multiple sort fields.
  
- Display highlighted results (based on any Solr field) with easy configuration.

- Use any number of facets to filter the search results with powerful and easy configuration.
    - The filter can include multiple values from the same facet field (OR'ed) to display the 
      combined results for those values.
    - Facet values from different facet fields are used to filter results.
    - Possible to use facets to create faceted navigation.
    - "Show more" functionality to display more facets based on limits specified in configuration.
    - Three types of facets supported
        - Regular text value facets
        - Dynamic date range facets created by specifying a startdate, enddate and dategap.

- Add any additional Solr config options easily in configuration


************************************************************************************
* Solr configuration (serendip.config.main.js)                                           
************************************************************************************

// Add the url to you solr server
serendip.setSolrUrl("http://localhost:8080/solr/select");

// Add more available fields
serendip.addFieldConfig({ name: "id", id: "id", header: "ID", selected: false, enabled: false });
serendip.addFieldConfig({ name: "url", id: "url", header: "Url", selected: false, enabled: false });
serendip.addFieldConfig({ name: "date", id: "bda", header: "Date", selected: false, enabled: true , isDate: true, dateFormat: "dd.mmm.yyyy"});

serendip.setSearchAllFields(true);
 
serendip.init("index.html");     

************************************************************************************
* Facet / Filter config (serendip.config.facets.js)                                           
************************************************************************************
// Example simple facet / filter
facets.push(new Serendip.Facet({
    id: "name", // Must be unique for all filters/facets
    selected: true, // If it is initially displayed
    name: "name_opf_s", // This is the name in Solr schema
    activeHeader: "Name", // The header used when displaying active facets
    header: "Filter by name", // The header used when displaying available facets
    minFacetsToDisplay: 5, // Facets shown
    maxFacetsToDisplay: 30 // Facets that can be shown by by clicking "show more" link
}));

// Date facet
facets.push(new Serendip.DateFacet({
    id: "date",
    selected: true,
    name: "date_opf_d",
    activeHeader: "Date",
    header: "Filter by date",

    minFacetsToDisplay: 5,
    maxFacetsToDisplay: 10,

    dateStart: "NOW/YEAR-10YEARS", // Uses Solr/Lucene constants
    dateEnd: "NOW/YEAR+1YEAR",
    dateGap: "+1MONTH",

    dateFormat: "mmmm yyyy", // Look in documentation 'Date formats' for all available formats
    sortDir: "desc" // Or 'asc' for ascending
}));
	
************************************************************************************
* Date formats                                          
************************************************************************************

See this link for info on what values are available for specifying the date ranges:
http://lucene.apache.org/solr/api/org/apache/solr/util/DateMathParser.html

These are options for the dateformat:
d  	  Day of the month as digits; no leading zero for single-digit days.
dd 	  Day of the month as digits; leading zero for single-digit days.
ddd 	Day of the week as a three-letter abbreviation.
dddd 	Day of the week as its full name.
m 	  Month as digits; no leading zero for single-digit months.
mm 	  Month as digits; leading zero for single-digit months.
mmm 	Month as a three-letter abbreviation.
mmmm 	Month as its full name.
yy 	  Year as last two digits; leading zero for years less than 10.
yyyy 	Year represented by four digits.
h 	  Hours; no leading zero for single-digit hours (12-hour clock).
hh 	  Hours; leading zero for single-digit hours (12-hour clock).
H 	  Hours; no leading zero for single-digit hours (24-hour clock).
HH 	  Hours; leading zero for single-digit hours (24-hour clock).
M 	  Minutes; no leading zero for single-digit minutes.
MM 	  Minutes; leading zero for single-digit minutes.
s 	Seconds; no leading zero for single-digit seconds.
ss 	Seconds; leading zero for single-digit seconds.

For more dateformat options see:
http://blog.stevenlevithan.com/archives/date-time-format

About

A javascript library to help you create a GUI frontend for Solr

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published