Comments (9)
Some notes on possible alternatives to searching the Solr index directly:
-
There is a Drupal Search API, but it requires (significant) configuration so the library website admins likely haven't set it up.
-
The HTML they return is structured with classes, so perhaps we could use the regular search interface and extract the title, description, and url from the HTML. For example, there's
ol.search-results
container anddiv.views-field-title
anddiv.views-field-body-value
for the result. They do not, however, have facet support or return the total number of results AFAICT, so this approach might be moot.
<ol class="search-results">
...
<li class="views-row views-row-2 views-row-even">
<div class="views-field views-field-title">
<span class="field-content"><a href="/blogs/digital-library-blog/2016/02/inaugural-geo4libcamp-forges-new-collaborations">Inaugural Geo4LibCamp forges new collaborations</a></span> </div>
<div class="views-field views-field-body-value">
<span class="field-content">From January 25th to 29th, we hosted Geo4LibCamp 2016 at the Hartley Conference Center and Branner Library. Inspired by the success of LDCX 2015,...</span> </div>
<div class="result-breadcrumbs">
<span class="raquo"> » </span> <a href="/">Home</a> › <a href="/about">About</a> › <a href="/blogs">Blogs</a> › <a href="http://library.stanford.edu/blogs/digital-library-blog">Digital Library Blog</a></div>
</li>
...
</ol>
from sul-bento-app.
@jkeck I looked in https://github.com/sul-dlss/sul-solr-configs but didn't see a core that might be connected to the library website. Do you know where the core is?
from sul-bento-app.
@drh-stanford see: sul-cms-*
from sul-bento-app.
Looks like the relevant fields are:
tm_title
ss_url
(orss_search_api_url
)tm_body:value
(yes with a colon)tm_search_api_viewed
(the text snippet untokenized)label
(unformatted title of node, but not present)spell
(full text index which works)
I can issue a search for tm_title
and it works fine, but searching for 'tm_body:value':*
doesn't find anything. That body field is supposed to be the full text of the document. The default search handler doesn't appear to have a default field that it searches, so we might be able to look at the Solr logs to see exactly how it's passing queries to Solr. Or, I might be missing something in the query syntax...
See https://www.drupal.org/project/search_api_solr
from sul-bento-app.
from sul-bento-app.
From https://www.drupal.org/node/1999386
Advanced » Retrieve result data from Solr
This option allows you to retrieve the result data (the fields of the result items) directly from Solr instead of loading it from the database. This might have advantages regarding performance (though benchmarks indicate this isn't usually the case) or security (as access checks will always be made against the data that will also be shown).
However, due to technical restrictions this won't work for functionality which needs the complete entity to work. This includes showing Field API fields in Views, rendering an entity in a certain view mode (with Views or Pages), linking a displayed field in Views to its entity (you can use a custom link rewrite with the item ID to circumvent this) or using the "Additional access checks on result entities" option in Views.
So, if we do need to scrape the HTML from the library search form interaction directly, then we can use CSS classes like .search-results
, .view-field-title
, .view-field-body-value
, .result-breadcrumbs
, etc.
from sul-bento-app.
Requirements
We need to be able to issue a simple search (q=my+query
) against the library website search interface, and get the following results for the top 3 relevant documents:
- Title of document
- URL to document
- Description (brief snippet is ok)
- Breadcrumbs (e.g.,
Home › About › Blogs › Digital Library Blog
) - Facet values and counts for resource type (e.g., Blog (4), Person (2))
- Total number of hits
Approach
-
We initially thought we could implement this by querying the Drupal Solr index directly (e.g.,
sul_cms_prod
in thesul-solr
cluster). But the index appears to lack the data requirements above -- see this comment above. -
Our next approach would be to find a JSON API that we could query the Drupal server with that will return the required data in a structured format. Something like http://library.stanford.edu/search/website?search=hardy&format=json (which doesn't work), for example. Perhaps there's a Drupal plugin that provides a structured data API for search?
-
Finally, our last resort approach is to "screen scrape" the search from the user-interface version of the Drupal server (e.g., http://library.stanford.edu/search/website?search=hardy).
from sul-bento-app.
Here's an example of a screen scrape for the hits (from WIP branch 3-scraper
):
def results
doc.css('.search-results .views-row').collect do |hit|
result = AbstractSearchService::Result.new
result.title = hit.at_css('.views-field-title .field-content a').text
result.link = hit.at_css('.views-field-title .field-content a')['href']
result.description = hit.at_css('.views-field-body-value .field-content').text
result.breadcrumbs = hit.at_css('.result-breadcrumbs span').text
result
end
end
from sul-bento-app.
(2) is pretty straightforward, there is a module for building such endpoints (https://www.drupal.org/project/services) but it is probably overkill for this, since we could write up a fairly simple module to execute the search via solr and return the desired data.
from sul-bento-app.
Related Issues (20)
- [sul-bento-app/prod] OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=error: certificate verify failed (certificate has expired) HOT 1
- Replace "COVID-19 Libraries update" text in nav bar with "2021 Access"
- Guides no results link should go to guides homepage
- Update Yewno widget HOT 2
- standardize term for e-books HOT 1
- Migrate Universal Analytics (UA) to Google Analytics 4 (GA4) HOT 5
- Earthworks results in Bento Box HOT 1
- Valid Earthworks result URLs not created in Bento results
- Replace Earthworks image
- Migrate off sassc to dart sass
- Upgrade to Bootstrap 5
- use new Drupal 9 endpoints for Library Website search results HOT 3
- Javascript error
- Clean up D9 migration code
- D9 footer links update
- Update link for "More search tools"
- Display Stanford "S" for stanford-only links HOT 1
- Help button doesn't rotate like it does in SW
- Extra white bar at bottom of footer
- Set a user-agent on Faraday requests
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sul-bento-app.