After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 653120 - Search action always gives NumberReturned 1
Search action always gives NumberReturned 1
Status: RESOLVED FIXED
Product: rygel
Classification: Applications
Component: general
git master
Other Linux
: Normal normal
: ---
Assigned To: Robert Swain
Depends on:
Blocks:
 
 
Reported: 2011-06-21 17:51 UTC by Robert Swain
Modified: 2012-01-29 11:33 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Screenshot of gupnp-universal-cp (47.32 KB, image/png)
2011-07-02 02:20 UTC, Zeeshan Ali
  Details
Screenshot of the issue (44.60 KB, image/png)
2011-07-02 07:37 UTC, Jens Georg
  Details
core: Return proper search result if Offset > All (1.20 KB, patch)
2012-01-28 14:21 UTC, Jens Georg
none Details | Review
core: Fix simple search for offset > 0 (2.64 KB, patch)
2012-01-28 23:53 UTC, Jens Georg
none Details | Review
tests: Add test for simple_search (6.35 KB, patch)
2012-01-28 23:56 UTC, Jens Georg
committed Details | Review
core: Fix simple search for offset > 0 (2.77 KB, patch)
2012-01-28 23:57 UTC, Jens Georg
committed Details | Review

Description Robert Swain 2011-06-21 17:51:41 UTC
With the following search action from tracker-miner-upnp-content-directory.vala at around line 200, NumberReturned is 1 when the starting index given is what should be one after the last item. Is this correct?

                _service.begin_action ("Search", index_cb,
                                       "ContainerID", typeof (string), cont.id,
                                       "SearchCriteria", typeof (string), "*",
                                       "Filter", typeof (string), "*",
                                       "StartingIndex", typeof (uint), cont.index,
                                       "RequestedCount", typeof (uint), ITEMS_PER_REQUEST,
                                       "SortCriteria", typeof (string), "",
                                       null);

Apparently some UPnP servers return fewer than the requested number of items, though I assume always some, despite there being more items remaining that can be requested within the container in question. This means that subsequent requests need to be made to be sure that all items have been obtained. And then one needs to have some condition based on which one knows that there are no further items.

An easy one would be if NumberReturned were 0, though this seems to have some other semantics perhaps, e.g. if TotalMatched is 0 because the CDS cannot calculate it, and if NumberReturned were 0 because there are no more items to provide at the requested starting index. Given TotalMatched = 0, if NumberReturned = 0 is reserved for error cases and so NumberReturned is set to 1 even if no items are returned, I suppose that is classifiable too.
Comment 1 Jens Georg 2011-06-21 18:16:01 UTC
Back-end in question was tracker, though I don't know yet if it's really a problem in there or in core.
Comment 2 Zeeshan Ali 2011-07-02 02:11:32 UTC
(In reply to comment #0)
> With the following search action from tracker-miner-upnp-content-directory.vala
> at around line 200, NumberReturned is 1 when the starting index given is what
> should be one after the last item. Is this correct?

  Looking at the Rygel sources, NumberReturned in both Browse and Search action responses is directly taken from the number of objects in the result (src/rygel/rygel-media-query-action.vala:77):

this.number_returned = results.size;

  Are you sure this is not on client-side?
Comment 3 Zeeshan Ali 2011-07-02 02:20:16 UTC
Created attachment 191136 [details]
Screenshot of gupnp-universal-cp

Here is a screenshot of gupnp-universal-cp demonstrating this bug to be invalid, AFAICT. Please do re-open if i misunderstood.
Comment 4 Jens Georg 2011-07-02 07:32:52 UTC
Yes, you misunderstood the bug.

In the screenshot, try setting StartingIndex to 1449 (TotalMatch + 1). Then NumberReturned == 1 and indeed there's one container in the result
Comment 5 Jens Georg 2011-07-02 07:37:36 UTC
Created attachment 191138 [details]
Screenshot of the issue
Comment 6 Jens Georg 2011-08-29 09:09:38 UTC
Can you retest with latest master? I fixed a similar issue recently, maybe we got this one as well.
Comment 7 Jens Georg 2011-09-16 14:56:59 UTC
Or current stable (0.12.1)
Comment 8 Jens Georg 2011-10-06 09:49:03 UTC
Still there...
Comment 9 Robert Swain 2011-10-06 09:58:27 UTC
I spotted the issue when using Mex [1] I think and I don't have that running right now so haven't got to testing it yet. Apologies, I will try to do so sometime soon.

[1] http://media-explorer.github.com/
Comment 10 Jens Georg 2011-10-06 10:04:19 UTC
Still there.. meant "I can still reproduce it on master". Sorry :)
Comment 11 Jens Georg 2012-01-28 14:02:59 UTC
Seems a problem in SimpleSearch. MediaExport which does its own SQL searching is not affected, but Mediathek is.
Comment 12 Jens Georg 2012-01-28 14:21:20 UTC
Created attachment 206328 [details] [review]
core: Return proper search result if Offset > All

On a search request where Offset was larger than the totel number of
matching items the search previously returned one item found and
doesn't know how many there are.

Now we correctly? return "no item found" + total matches.
Comment 13 Jens Georg 2012-01-28 14:26:04 UTC
Review of attachment 206328 [details] [review]:

totel → total

::: src/rygel/rygel-searchable-container.vala
@@ +111,3 @@
         }
 
+        if (offset > result.size) {

Probably needs >=, need to think about that.
Comment 14 Jens Georg 2012-01-28 18:43:55 UTC
Actually the combination offset > 0 && max_count == 0 seems to be broken. It always returns "1" then.
Comment 15 Jens Georg 2012-01-28 23:53:50 UTC
Created attachment 206338 [details] [review]
core: Fix simple search for offset > 0

On a search request where offset was > 0 and limit was 0 due to
limiting the result set to offset the result was always a set of one.

Also total_matches was set to 0 in this case although we know the
number of total matches since using a start offset doesn't limit the
results.
Comment 16 Jens Georg 2012-01-28 23:56:52 UTC
Created attachment 206339 [details] [review]
tests: Add test for simple_search
Comment 17 Jens Georg 2012-01-28 23:57:14 UTC
Created attachment 206340 [details] [review]
core: Fix simple search for offset > 0

On a search request where offset was > 0 and limit was 0 due to
limiting the result set to offset the result was always a set of one.

Also total_matches was set to 0 in this case although we know the
number of total matches since using a start offset doesn't limit the
results.
Comment 18 Jens Georg 2012-01-29 11:33:36 UTC
Attachment 206339 [details] pushed as 8cbc983 - tests: Add test for simple_search
Attachment 206340 [details] pushed as e8cdb95 - core: Fix simple search for offset > 0