Using jquery and jquery-ui libraries we'll try to setup the autocomplete functionality on every textbox of advanced search page, we'll take advantage of Discovery Solr cores to add an additional search core for JSPUI. Check first on development server before moving this modifications to production
Note: This implementation will display only words or partial words when using autocomplete funcionality because JSPUI indexes fields splitting it in words and removing some suffixes, this is bad for searching full text like author names. In a future section I will describe how to set custom text indexers to our custom fields.
Once finished our textboxes must work like this:
...
We'll use a servlet class to query a SOLR core to generate a JSON responseresponses, this response responses will be wired to a textbox with autocomplete functionality. Here is a simple diagram of this dataflow.
...
Wiki Markup |
---|
We'll create a new folder inside \[dspace-source\]/dspace-jspui/dspace-jspui-webapp/src/main/webapp/static/js/*jqueryui* and copy all previously described files inside it.. Structure will look like this: |
Wiki Markup |
---|
\[dspace-source\]/dspace-jspui/dspace-jspui-webapp/src/main/webapp/static/js/jqueryui/*{_}jquery-1.7.2.min.js{_}* |
Wiki Markup |
---|
\[dspace-source\]/dspace-jspui/dspace-jspui-webapp/src/main/webapp/static/js/jqueryui/*{_}jquery-ui-1.8.21.custom.min.js{_}* |
Wiki Markup |
---|
\[dspace-source\]/dspace-jspui/dspace-jspui-webapp/src/main/webapp/static/js/jqueryui/*css/...* |
Wiki Markup |
---|
We'll edit \[dspace-source\]/dspace-jspui/dspace-jspui-webapp/src/main/webapp/search/advanced.jsp |
Creating a new SOLR core
Wiki Markup |
---|
Now we must create a new SOLR core inside \[dspace-source\]/solr directory. To do so we'll use one of the existing cores and copy it's structure with this command: |
Code Block |
---|
bash$ cp -R [dspace-source]/dspace/solr/search [dspace-source]/dspace/solr/searchJSPUI
bash$ mkdir [dspace-source]/dspace/solr/searchJSPUI/data
bash$ mkdir [dspace-source]/dspace/solr/searchJSPUI/data/index
|
Wiki Markup |
---|
We'll edit \[dspace-source\]/dspace/solr/solr.xml and add one extra line with our new search core. |
...
Wiki Markup |
---|
Now we'll modify new solr core configuration file \[dspace-source\]/dspace/solr/searchJSPUI/conf/schema.xml
\\
\\
\\ to handle lucene generated indexes: |
Wiki Markup |
---|
Then we'll edit \[dspace-source\]/dspace/config/dspace.cfg and modify default JSPUI search index folder: |
Code Block |
---|
# Where to put search index files
search.dir = ${dspace.dir}/solr/searchJSPUI/data/index
|