2006/12/21, Jean-Francois Dockes <<a href="mailto:email@example.com">firstname.lastname@example.org</a>>:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Mikkel Kamstrup Erlandsen writes:<br> > Having a unique handle for each document is a really handy thing. A unique<br> > handle could be many other things than an uri, fx a unique integer or<br> > anything as well. The way you describe this handle is just a number
<br> > specifying an entry in an array and is in this way not unique (except in the<br> > context of a query).<br><br>That is right, the result sequence entry number is only usable in the<br>context of a given query.
<br><br> > The uri is just a more convenient handle than fx an integer - for<br> > applications at least (the toolkit and platform libs often handle uris<br> > directly).<br><br>It depends, this is only true in the case of documents with a well-known
<br>URI-based access method, which is not the general case (ie: not true for email<br>messages).</blockquote><div><br><br>Well URL and file URIs are readily usable for the apps, and they account for a very large portion of the results in many cases. Also, if there ever comes a standard URI for pointing at emails, apps could start using that right away.
<br> </div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> > I respect your disagreement, and would really like to hear what the other
<br> > guys think...<br><br>Me too ... I am going to restate the problem as I see it, in a way which is<br>probably somewhat xapian-specific. Hopefully someone will be able to concur<br>or contradict this for other engines.
<br><br>After it has received and processed a query, the backend has some kind of<br>structure that represents the results. This is an ordered sequence of<br>documents, the order depends on the kind of sorting that was<br>
requested. Typically and by default this will be by order of relevance.<br><br>The result set is mostly organized to be accessed by sequence number, and<br>things are set up so that you can retrieve auxiliary data for a given
<br>result: a result entry will have some kind of document number which can be<br>used in turn to access document data efficiently.<br><br>Access by URI is not part of the scheme.<br><br>This means that a backend for the current WasabiSimple api would have to:
<br><br> - In response to Query(), run a query, then walk the result set to request<br> document data, select URIS, and return these only (while it has access to<br> all the documents field at the same time at no additional cost).
<br><br> - In response to GetProperties() or GetSnippets() either run another,<br> different query to get the corresponding document data (this is an<br> actual db query using the URI as a unique term, not the simpler and more
<br> efficient access to data by document number), or use some kind of cache<br> that it would hopefully have built in response to the first Query()<br> call, hoping that the requested URI->document association is
<br> actually cached.<br><br>This is very awkward, and offers no real benefit to the application, which<br>would as well decide initially what kind of metadata it wants back, and get<br>it all in response to the Query() call.
</blockquote><div><br><br>I think the much the same applies to Lucene. I'll have to ask some of the Lucene experts in the office in the new year.<br><br>Anyway, it is not a herculean task for the search engine to keep a ring-buffer-like hashmap of the last 100 hits, uri->doc_id. Easier said than done of course since hashmaps has no obvious way of acting as a ring buffer. There is also synchronization issues when the underlying index changes of course...
<br> </div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> > Pasting in Jean-Francois' follow up mail:<br> > > As an afterthought to my previous message (sorry), the result list could
<br> > > change if the query has to be re-run. This is a good reason for keeping<br> > > the uris as document identifiers for getSnippets().<br> ><br> > It would feel akward if you had to request a specific property (the uri) to
<br> > be able to obtain a snippet IMHO.<br><br>Sorry, but I can't see why. It would be vastly less awkward than the current<br>proposal, where you initially get a set of data for which you have no use<br>(try displaying a list of bare URIS to the user and see how they like it),
<br>and then immediately make other calls to request data for each and every of<br>the initial results (because there is no way to select among them).<br><br> > Ok, my central point is: We need a unique handle for each document/object in
<br> > store - this should be used to identify the returned hits from Query().<br> > Whether or not an opaque handle of some undefined sort or it is defined to<br> > be the uri is another matter.<br><br>The nice thing with the URI is that it is independant of the query. The fact
<br>that queries are only identified by the query string sort of implies that<br>the query result list might not be fully stable across calls, so that using<br>result sequence numbers as identifiers would be inappropriate.
<br><br>So either we need a unique *query* identifier which would at least<br>enable detecting that the result set is stale, or we use URIS as document<br>identifiers for calls subsequent to the initial Query(). If we really want
<br>to keep a separate GetSnippets() call, my proposal would be to:<br><br> - Return all desired metadata with the initial Query() call as an<br> appropriately ordered sequence (as determined by the user query sort<br> parameters).
<br> - Request snippets by URI (which may imply running a different query for<br> each snippet on the backend side, but hopefully not for all initial<br> results).</blockquote><div><br><br>Ok. In this case I suggest always including a
Object.URI property in the return values. This way platform bindings can have a Hit.GetUri() method that is guaranteed to make sense. With platform-binding-niceness in mind, there could even be a *small* set of obligatory properties to return (including uri) - I can't think of any other right now.
<br> </div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Note that both in this approach and in the current WasabiSimple proposal,<br>
it may probably happen under some circonstances that the result sequence<br>obtained by successive Query() calls would be unperfect, with duplicates or<br>holes (if the database has changed and the backend had to run the query
<br>again for some reason). This forces requesting Snippets by URI.</blockquote><div><br><br>Yeah right. The simple api has inevitable shortcomings when it comes to query integrity. I suspect most apps using the simple query to only call Query() once per actual user query (ie don't do paging), in this case query integrity is less compromised.
<br> </div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> > To the sorting problem I see two solutions.<br> > 1) Always return a score property as part of the response properties as
<br> > defined in my proposal.<br> > 2) Always include the UniqueHandle property as part of the response as<br> > defined by your proposal.<br><br>1) would have to be extended to some sort of ordinal value (not always
<br>representing a score, the results might have been requested ordered by ie,<br>date), and it burdens the application with sorting the results again. Why<br>make things so complicated ?<br><br>About 2), URI *is* an appropriate handle, and probably the best as long as
<br>we can't guarantee the stability of the result set (that is: *if* we need<br>separate Query() and GetSnippets() calls, *then* the URI is probably the<br>best identifier to ensure consistency).</blockquote><div><br>
<br>The thing is that I think we should keep an eye out for keeping the Simple and Live interfaces as consistent as possible. Returning and using similar data structures and such. In the Live interface you simply have to include some sorting data in the hits because they can be added and removed dynamically.
<br><br>I suggested making URI a obligatory property to return. Maybe we have to have some sorting info available too... In the simple api the sorting property(ies) would be redundant though.<br><br><br><br>Cheers,<br>Mikkel