Note that there are some explanatory texts on larger screens.

plurals
  1. POIs this a good way to implement a search feature in my Rails application that uses dbpedia and SPARQL? Is there a better way to do this?
    primarykey
    data
    text
    <p>I'm trying to put together a "movie search" application using Ruby on Rails 3. I'm pulling data from dbpedia using SPARQL (RDF and sparql/client). I want a potential user to be able to search for a movie, view the results, and then click to view a page that I generate on that movie that contains more information (both from dbpedia and my own local database). </p> <p>This is my first time using a huge data set and SPARQL and I've noticed it's very slow, and I guess that can't be helped. I would still very much like to use it as a data source though. </p> <p>I have my rails app set up to use MongoDB, so I was thinking that I can utilize that to cache some of the DBPedia data so users don't need to wait for a query every single time. However I'm stuck on the best way to implement something like this. My current thought is something along these lines:</p> <p>On the first search ever, I store details for each result in my local database (probably basic movie info such as title, overview, year, alternate titles)</p> <p>When a user does a search, the following occurs:</p> <ol> <li>Run the search query on my local database to get relevant stored movies (searching title and overview only, most likely). If the movie hasn't been updated from dbpedia in the past X days, I don't include it.</li> <li>Quickly display those relevant local results to the user and make a list of those movies.</li> <li>While the user views the stored results, dbpedia gets queried. From this query result I create a list of the relevant results from DBpedia.</li> <li>I remove any movies from the dbpedia query result set that are already in the initial local result set to prevent the user from seeing duplicate results.</li> <li>I display the remaining dbpedia query results underneath the local results, and save each of the new non-stored results in my local database (including last_updated time, and updating any existing local items as needed).</li> <li>When a user clicks through to a movie page, the basic information from dbpedia and my extra info I am storing are already stored locally and can be pulled up on the page quickly, but more advanced information (director, language, location, links to relevant sites) is queried from dbpedia at the time of loading. I show loading dialogs etc. on different sections while the new info is retrieved.</li> </ol> <p>I was thinking of doing something like the above so the user can see a few results quickly while the remaining results get loaded from dbpedia, and I am storing some things but not an insane amount.</p> <p>But I wanted to get some help on whether this is realistic and whether it is a good idea. I can imagine that searching my local db first might skew the user's initial results towards things that have been searched before, and if their particular desired movie (if they put in a title for example) hasn't been searched before it might show up further down the list. Would it make more sense to just store a copy of the relevant data set (i.e. all movies) locally and update it as needed? That would be too much, right?</p> <p>Anyway I would really appreciate some suggestions on a good way to make things as seamless as possible for the user while still dwelling within the boundaries of sanity. Thanks in advance!</p> <p>Edit: Here is the code for a test search query I am currently using. I thought I was making it super super basic for testing... but it times out a <em>lot</em>.</p> <pre><code>query = " PREFIX owl: &lt;http://www.w3.org/2002/07/owl#&gt; PREFIX xsd: &lt;http://www.w3.org/2001/XMLSchema#&gt; PREFIX rdfs: &lt;http://www.w3.org/2000/01/rdf-schema#&gt; PREFIX rdf: &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#&gt; PREFIX foaf: &lt;http://xmlns.com/foaf/0.1/&gt; PREFIX dc: &lt;http://purl.org/dc/elements/1.1/&gt; PREFIX : &lt;http://dbpedia.org/resource/&gt; PREFIX dbpedia2: &lt;http://dbpedia.org/property/&gt; PREFIX dbpedia: &lt;http://dbpedia.org/&gt; PREFIX skos: &lt;http://www.w3.org/2004/02/skos/core#&gt; PREFIX dbo: &lt;http://dbpedia.org/ontology/&gt; SELECT ?subject ?label ?abstract ?runtime ?date ?name WHERE { {?subject rdf:type &lt;http://dbpedia.org/ontology/Film&gt;} UNION {?subject rdf:type &lt;http://dbpedia.org/ontology/TelevisionShow&gt;}. OPTIONAL {?subject dbo:runtime ?runtime}. OPTIONAL {?subject dbo:releaseDate ?date}. OPTIONAL {?subject foaf:name ?name}. ?subject rdfs:comment ?abstract. ?subject rdfs:label ?label. FILTER((lang(?abstract) = 'en') &amp;&amp; (lang(?label) = 'en') &amp;&amp; REGEX(?label, '" + str + "')). } LIMIT 30 " result = {} client = SPARQL::Client.new("http://dbpedia.org/sparql") result = client.query(query).each_binding { |name, value| puts value.inspect } return result </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload