Solr Query of download and view.

770 views
Skip to first unread message

Faiyaz Ahmed

unread,
Sep 6, 2016, 5:14:00 AM9/6/16
to DSpace Technical Support
Hello EveryOne. 

Hope every one is doing well :) 

I need some help regarding Solr Query of download and view of a file. As you can see at : http://demo.dspace.org/xmlui/handle/10673/419/statistics.

I need to filter on Total Visits and Total Downloads. How I can do that. I need to create report in another page.

Does any one have idea how this code or solr query works on total download and total views.

Regards,

Faiyaz Ahmed

Faiyaz Ahmed

unread,
Sep 16, 2016, 4:14:02 AM9/16/16
to DSpace Technical Support
Any luck on this ???? Please help..

Faiyaz Ahmed

unread,
Sep 18, 2016, 8:14:52 AM9/18/16
to DSpace Technical Support
Waiting for hope .... 


On Tuesday, September 6, 2016 at 2:14:00 PM UTC+5, Faiyaz Ahmed wrote:

Bruno Nocera Zanette

unread,
Sep 18, 2016, 1:02:44 PM9/18/16
to Faiyaz Ahmed, DSpace Technical Support
Faiyaz,
There are some important details that need to be addressed here.

First, by default, solr is only accessible on localhost. This means that you won't be able to query demo.dspace.org statistics. You'll need to install a dspace instance on some of your servers and access it from the same network. I recommend you to take a look at this: https://wiki.duraspace.org/display/DSPACE/Solr#Solr-Bypassinglocalhostrestrictiontemporarily

The query itself is made using SOLR query syntax (https://wiki.duraspace.org/display/DSPACE/Solr#Solr-Solrqueries). I don't fully understand it to be able to explain it to you, but there's a nice trick you can use to get the right queries. That trick is to use the solr.log file ([install-dir]/log/solr.log) to extract the queries used by xmlui interface. All you have to do is to access some statistic page on xmlui and read the last lines on the log file, where will be logged all the parameters used to get the informations used on xmlui page.

Using this method, i've ended on the following URL to get view statistcs on an item:
https://localhost:8443/solr/statistics/select?q=type%3A2+AND+(id%3A68056753-e460-4f80-a08a-f8febfbd07f7)&fq=statistics_type%3A%5B*+TO+*%5D+AND+statistics_type%3Aview&wt=json&indent=true

You can also use the SOLR interface to test the queries (https://localhost:8443/solr/#/statistics/query). I'm sending a printscreen of this page filled with the parameters that generated the URL.

Lastly, you will need to find a way to parse and use the response and maybe create a script to automatically generate the parameters and queries' url. That directly depends on what language/framework you're using, so i won't be able to help you with this, but it shouldn't be hard to get this done.

I hope this helps you! Cheers!

--
You received this message because you are subscribed to the Google Groups "DSpace Technical Support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dspace-tech...@googlegroups.com.
To post to this group, send email to dspac...@googlegroups.com.
Visit this group at https://groups.google.com/group/dspace-tech.
For more options, visit https://groups.google.com/d/optout.
--
Bruno Nocera Zanette
+55 41 9992-2508
solr_query.png

Faiyaz Ahmed

unread,
Sep 19, 2016, 7:59:30 AM9/19/16
to Bruno Nocera Zanette, DSpace Technical Support
Thank you so much Bruno for response and now I understand to run Solr Query.

Below query I got from solr.log file : 

2016-09-19 15:57:44,851 INFO  org.apache.solr.core.SolrCore @ [statistics] webapp=/solr path=/select params={facet=true&shards=localhost:8080/solr/statistics-2015,localhost:8080/solr/statistics&facet.mincount=1&q=type:+2+AND++id:64&facet.limit=10&facet.field=id&wt=javabin&fq=-isBot:true&fq=-(bundleName:[*+TO+*]-bundleName:ORIGINAL)&fq=-(statistics_type:[*+TO+*]+AND+-statistics_type:view)&version=2&rows=0} hits=23 status=0 QTime=4

I run : facet=true&shards=localhost:8080/solr/statistics-2015,localhost:8080/solr/statistics&facet.mincount=1&q=type:+2+AND++id:64&facet.limit=10&facet.field=id&wt=javabin&fq=-isBot:true&fq=-(bundleName:[*+TO+*]-bundleName:ORIGINAL)&fq=-(statistics_type:[*+TO+*]+AND+-statistics_type:view)&version=2&rows=0


Got response but not able see total hits / view which I see at solr logs that is "hits=23".

Where I can get only "hits=23" response from solr query?

Hope you understand what I'm looking for :)

Many Thanks ... 

Faiyaz Ahmed

To unsubscribe from this group and stop receiving emails from it, send an email to dspace-tech+unsubscribe@googlegroups.com.

To post to this group, send email to dspac...@googlegroups.com.
Visit this group at https://groups.google.com/group/dspace-tech.
For more options, visit https://groups.google.com/d/optout.

Bruno Nocera Zanette

unread,
Sep 19, 2016, 11:13:34 AM9/19/16
to Faiyaz Ahmed, DSpace Technical Support
Hey! Glad it helped!!

As a said, you will have to parse the response to get this info. The field of interest for you is "numFound".

For example, when i execute the query that i cited in the first message i get the following response:
{
  "responseHeader":{
    "status":0,
    "QTime":2,
    "params":{
      "q":"type:2 AND (id:68056753-e460-4f80-a08a-f8febfbd07f7)",
      "indent":"true",
      "fq":"statistics_type:[* TO *] AND statistics_type:view",
      "wt":"json"}},
  "response":{"numFound":4,"start":0,"docs":[
      {
        "ip":"127.0.0.1",
        "referrer":"http://localhost:8080/xmlui/",
        "dns":"localhost.",
        "userAgent":"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:48.0) Gecko/20100101 Firefox/48.0",
        "isBot":false,
        "id":"68056753-e460-4f80-a08a-f8febfbd07f7",
        "type":2,
        "owningColl":["88c16bca-e689-4a71-b8f3-112191758c9a"],
        "owningComm":["bc362b91-eb6d-4c95-bf2c-77dc2aeb20d4"],
        "time":"2016-09-18T13:16:47.936Z",
        "epersonid":"041c27dd-7c00-49c4-9192-55a3aed42994",
        "statistics_type":"view",
        "uid":"6d845ff5-2a9d-441f-a081-8190485f231c",
        "_version_":1545826895597142016},
      {.......}
}

In the beggining of the response there are the params that were used. Then it comes the important part, that is the response itself. As any other query, it says how many results were found and then the results itself. So, if you are looking for some kind of statistic, the result will be how many statistics were found.

How you will do it depends on the language you are using, but almost definitely will be something like this (written on Ruby):
parsedResponse = JSON.parse(response)  # Parse the result
numFounds = parsedResponse["response"]["numFound"] # Access the response field and then the attribute numFound.

And then you can iterate through the results if you want:
parsed_response["response"]["docs"].each do |r|
puts r["ip"]
end

If the number of found results isn't the same as it appears on the xmlui interface you have to revise the query, because it should be.

To unsubscribe from this group and stop receiving emails from it, send an email to dspace-tech...@googlegroups.com.

To post to this group, send email to dspac...@googlegroups.com.
Visit this group at https://groups.google.com/group/dspace-tech.
For more options, visit https://groups.google.com/d/optout.
--
Bruno Nocera Zanette
+55 41 9992-2508

--
You received this message because you are subscribed to the Google Groups "DSpace Technical Support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dspace-tech...@googlegroups.com.

To post to this group, send email to dspac...@googlegroups.com.
Visit this group at https://groups.google.com/group/dspace-tech.
For more options, visit https://groups.google.com/d/optout.

Karol Sokalski

unread,
Jun 8, 2022, 5:55:03 AM6/8/22
to DSpace Technical Support
Hi,

Can you please tell me how I can find the internal-id for Community? Thanks,

Karol

Sean Carte

unread,
Jun 8, 2022, 8:04:57 AM6/8/22
to Karol Sokalski, DSpace Technical Support
Hi Karol

If you're comfortable trawling through the solr.log, you'll find the community uuid referenced when you access that community, e.g.:

2022-06-08 13:50:26,967 INFO  org.apache.solr.core.SolrCore @ [search] webapp=/solr path=/select params={f.has_content_in_original_bundle.facet.limit=3&facet.field=author_filter&facet.field=subject_tax_0_filter&facet.field=has_content_in_original_bundle&fl=handle,search.resourcetype,search.resourceid&start=0&fq=NOT(withdrawn:true)&fq=NOT(discoverable:false)&fq=location:m333b0c4a-db89-422f-9d1d-3bbcb9a5d3ae&fq=read:(g186b0bff-3460-4266-b003-ddc0c4e08bb3+OR+g186b0bff-3460-4266-b003-ddc0c4e08bb3)&f.author_filter.facet.sort=count&rows=0&version=2&f.subject_tax_0_filter.facet.limit=11&facet.query=dateIssued.year:[2010+TO+2020]&facet.query=dateIssued.year:[2008+TO+2009]&q=*:*&f.subject_tax_0_filter.facet.sort=count&facet.mincount=1&facet=true&f.has_content_in_original_bundle.facet.sort=count&wt=javabin&facet.offset=0&f.author_filter.facet.limit=11} hits=2640 status=0 QTime=1

Probably easier to query the database, though:

SELECT * FROM community;
 community_id |                 uuid                 | admin | logo_bitstream_id
--------------+--------------------------------------+-------+-------------------
            8 | 333b0c4a-db89-422f-9d1d-3bbcb9a5d3ae |       |
            9 | 9558b065-ff99-48b8-b7a0-d8393700c5f1 |       |
           10 | 8921fc45-ab5c-4e44-9c49-927ecaa888eb |       |
           11 | 1899b53d-608a-4010-ba7a-88b22f217529 |       |
           12 | d5198570-ffe8-4977-ac2c-a88439c0d8ef |       |
           13 | 4f620c0e-ec85-48a5-b2e6-9bf6f6e9508c |       |
(6 rows)

I'm assuming you're using DSpace 6.

(I'm fairly certain there was some trick you could use to get the community/collection id from the UI, but I can't remember how to do it.)

Sean


--
All messages to this mailing list should adhere to the Code of Conduct: https://www.lyrasis.org/about/Pages/Code-of-Conduct.aspx
---
You received this message because you are subscribed to the Google Groups "DSpace Technical Support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dspace-tech...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages