wiki:Handbook/SearchArchive

[ First Steps | Handbook | The Nabu Ontology ]

Search the Archive

Once Nabu logs your conversations, you probably want to search them at some point (otherwise archiving would not make that much sense). For querying the archive, Nabu uses the SPARQL query language. SPARQL is a language for querying RDF stores, similar to SQL. Being powerful and versatile, it allows arbitrary complex queries (Unfortunately it's also quite complex for everyday use, so a GUI for the most common queries would be desirable).

Example: You want to search for all messages containing "Nabu". use the following command (it's splitted over multiple lines for readability, but must be sent in one message):

QUERY SPARQL
PREFIX nabu: <http://www.opendfki.de/ont/nabu#>
DESCRIBE ?msg
WHERE { ?msg nabu:body ?body . FILTER REGEX(?body, "Nabu", "i") }

('QUERY SPARQL' is the Nabu command used to send SPARQL queries. 'PREFIX nabu: ... REGEX(?body, "Nabu")' is the actual query in SPARQL format). The query returns all messages ?msg that have a body ?body matching the regular expression "Nabu". A bit too complex for a simple string search? Well, for this specific case, searching a string in message bodies, a shortcut exists:

QUERY SEARCHMSG Nabu

executes the same query with much less typing. This is the only shortcut though; for anything more complex SPARQL is the way to go.

Nabu will return the messages matching the query as RDF/XML. For instance, Nabu might return one message, containing "Me thinks, Nabu rocks big time!":

210 <rdf:RDF
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:nabu="http://www.opendfki.de/ont/nabu#">
  <nabu:Message rdf:about=
  "http://foo#instances/Messages/kafka/frank2/kafka/frank/20050714-094210.520">

   <nabu:body>Me thinks, Nabu rocks big time!</nabu:body>

   <nabu:previousMessageInRoom rdf:resource=
       "http://foo#instances/Messages/kafka/frank2/kafka/frank/20050710-143802.712"/>
   <nabu:inRoom rdf:resource=
       "http://foo#instances/P2PRooms/kafka/frank/kafka/frank2/"/>
   <nabu:subject></nabu:subject>
   <nabu:messageType>chat</nabu:messageType>
   <nabu:streamID></nabu:streamID>
   <nabu:sender rdf:resource=
       "http://foo#instances/Accounts/Jabber/kafka/frank2"/>
   <nabu:receivers rdf:resource=
       "http://foo#instances/Accounts/Jabber/kafka/frank"/>
   <nabu:datetime>2005-07-14T09:42:11.054+0200</nabu:datetime>
 </nabu:Message>
</rdf:RDF>

Note: Nabu returns only RDF data that is accessible by you. By default, this includes all messages you have sent yourself or received from others. Normally you won't see messages exchanged between other users. If a user decides so, he can grant you access to a conversation log (for example, co-workers might decide to share the log of an online meeting with other team members). Read in the 'Log Sharing and Privacy Settings' section for more detailed information on privacy settings.

Another example:

Return a list of all messages sent by schwarz@… since the beginning of the year:

QUERY SPARQL
PREFIX nabu: <http://www.opendfki.de/ont/nabu#> SELECT ?msg ?date  WHERE { ?msg nabu:datetime ?date . ?msg nabu:sender <http://km.dfki.de/xmpp/nabu#instances/Accounts/Jabber/km-intern.opendfki.de/schwarz>. FILTER (xsd:dateTime(?date) >= xsd:dateTime("2005-01-01")) 

Read about the Nabu ontology to learn more about the data structures Nabu uses for logging.

[ First Steps | Handbook | The Nabu Ontology ]

Last modified 12 years ago Last modified on 08/04/05 10:11:51